![]() |
|
help with a code pls - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17) +---- Thread: help with a code pls (/showthread.php?tid=319) Pages:
1
2
|
help with a code pls - Clu - 23-09-2006 ya i was trying out the paperdoll code on the old forums, and it kees giving me an "next without for" error heres the sub Code: Sub SendIndexWornEquipmentFromMap(ByVal Index As Long) hock:
- Misunderstood - 23-09-2006 sometimes that also means that you have an if without an end if or an end if without an if inside the for tobody should even try to help you till you learn how to indent your code. It makes it much easier to find problems like this anyway. - Clu - 23-09-2006 oh wait, thx misunderstood, that bit of advice, helped me i notice there were 4 end ifs missing in various places - pingu - 23-09-2006 Code: Sub SendIndexWornEquipmentFromMap(ByVal Index As Long)The problem was that you had some "If" statements without "End If"s. You don't need the "End If" only if your code is on the same line, so I fixed it up. - Clu - 23-09-2006 so if u do it the way u just posted u dont need the End Ifs?, thats cool, ill note that lol - William - 23-09-2006 Hehe.. you kinda messed the whole thing up Here you got it:Code: Sub SendIndexWornEquipmentFromMap(ByVal Index As Long)That should work! Edit: Didn't see Pingu posted a fix.. =/ - pingu - 23-09-2006 William needs to learn to indent a bit better. The only things that should be without indents is the sub declaration and the "Dim"s. After that, you start out with one indent and add another each time an "If", "For", "While", "With", or "Select" is used. you obviously remove one when you end each one. I don't know if what you posted it your actual style or something quick you did, so ignore this post if you normally don't format like that. - William - 23-09-2006 pingu Wrote:William needs to learn to indent a bit better.Hehe, it's nice that you try to teach me. But how I program isn't really anybodies business. And sure, I havnt taken classes in how to indent. But the way I code, is the way I want, the way I think it looks easiest
- grimsk8ter11 - 23-09-2006 pingu everyone ahs their own coding standard, some diffrent some the same, i prefer to indent starting with the dims then everything else is 2 + whatever else (meaning ifs, for, whiles, ect.) and a space between EVERY line. - pingu - 23-09-2006 I know everybody has their own style, but there are some styles that are easier to read than others. William's is very difficult to read. All styles that have a bunch of code at the far left are always hard to see. The indenting of Dims doesn't really matter, though. Heck, I used to intent mine until I saw how it was done in Elysium and I started doing the same. I don't see a readability issue with adding a line between code, but it's more of a scrolling thing. I'd rather not scroll down if I don't have to, so I try to compact it enough so it can still be read but less scrolling is needed (I have a laptop without a mouse, so I need to use that little furry thing to move the mouse). It really doesn't matter, but it's another form of fasion. I like the person that wears the nicest clothes over someone who got a $2 shirt at K-Mart that is 3 sizes too big. It's not that important when you don't go outside (giving out the code), but it's important for people who need to impress with their coding skills. - Misunderstood - 23-09-2006 William Wrote:pingu Wrote:William needs to learn to indent a bit better.Hehe, it's nice that you try to teach me. But how I program isn't really anybodies business. And sure, I havnt taken classes in how to indent. But the way I code, is the way I want, the way I think it looks easiest You haven't taken intenting classes? For shame! Its simple. Each block of code is indented. Blocks of code go between for's if's while's and select cases, like pingu said. You dont have a line of code right inline with the for loop if its inside the for loop, like you have Code: For i = 1 To MAX_PLAYERSand from there, you don't randomly and stupidly indent 2 tabs instead of 1 a la here: Code: For i = 1 To MAX_PLAYERSThis is good: Code: If GetPlayerArmorSlot(i) > 0 ThenEste es muy mal! Code: Packet = "itemworn" & SEP_CHAR & i & SEP_CHAR & Armor & SEP_CHAR & Weapon & SEP_CHAR & Helmet & SEP_CHAR & Shield & SEP_CHAR & END_CHARthe end if should be indented 1 tab to the right of the Next and the next would be better indented one tab to the right of end sub. - William - 23-09-2006 Just to point one thing out, I did think about the indents when I made the code. But didnt really wanna spend time on it.. So it was a ruff thing of what I wanted. This is actually how it would look if I made it my correct way: Code: Sub SendIndexWornEquipmentFromMap(ByVal Index As Long)Still it might differ from the Correct Lesson of it, but its my way. If you want to cry, look at this (I made it long ago when i used rpgtoolkit): http://www.key2heaven.net/bs.txt - pingu - 23-09-2006 Quote: That's much better, but there are two things to do and then it would be perfect (in my sense of style at least). 1. Indent that whole For loop one time. It's much easier to tell where a sub or function starts and ends if the start and end are the only lines that are on the far left side. The next doesn't effect that too much in this example, but any other code not in one of those statements would ruin the effect more. 2. "If IsPlaying(i) Then" looks so much nicer than adding a "= true" and they do the same thing. It's always best to make it logical, so that you can read it out like a sentence. "If this guy is playing then" makes more sense than "If this guy is playing and that is true, then". It's better for variables like "InEditor", because it makes so much more sense. "Do While NotDone" is my favorite... - William - 23-09-2006 pingu Wrote:1. Indent that whole For loop one time. It's much easier to tell where a sub or function starts and ends if the start and end are the only lines that are on the far left side. The next doesn't effect that too much in this example, but any other code not in one of those statements would ruin the effect more.You do have some good points, some
- Misunderstood - 23-09-2006 Ohh and another thing to bully/pester you about! I know in this case you might not have known that the packet line would wrap to the next line, but when in the vb ide you have something wrap to the next line, make the 2nd line indented atleast 1 from the first like sooo: Code: Packet="blah" & sep_char & "stupid" &- Clu - 23-09-2006 nvm got it working - pingu - 23-09-2006 Misunderstood Wrote:Ohh and another thing to bully/pester you about! I've never tried it, but don't you need a "_" at the end of a line to signal that it continues on the next line? - William - 23-09-2006 Yes you do, without the quotes ("")
- Clu - 23-09-2006 yaaa i have no idea why, but it just randomly stopped workign, and it wasnt working "right" before, by any chance can any1 get me a copy of mirage with paperdoll already implemented?, or maybe a gueranteed tutorial? - Misunderstood - 24-09-2006 oh yea, you need a _ to tell vb you are going to the next line. I forgot this was crappy vb. In most languages you don't need to do that
- Clu - 24-09-2006 kk got this workign xD, but uhh, it doesnt work until you liek walk into another map, any1 kno a fix? - William - 24-09-2006 Because its called: SendIndexWornEquipmentFromMap And it probably is called upon map switch. - Dark Echo - 25-09-2006 pingu Wrote:I've never tried it, but don't you need a "_" at the end of a line to signal that it continues on the next line? Actually dude.. You do need an underscore.. In visual basics it means the line of code has been divided onto another line.. - Rian - 25-09-2006 Dark Echo Wrote:pingu Wrote:I've never tried it, but don't you need a "_" at the end of a line to signal that it continues on the next line? ftw? Are you dyslexic (sp?) Echo?
- Clu - 25-09-2006 kk fixed it lol, i just had it call that sub everytime you used an item lol |