1
2
ID:266200
Sep 17 2001, 9:32 am
|
|
What is the command to end a proc? I tried return, but it just sends it to the beinig of the proc... How would i do this?By the way my frien DRAGONBOY25 just found out about this by me and he has a little experience with C++.TRUST ME I ENSURED HE ISNT GOING TO MAKE THE SAME MISTAKE I DID!!!
|
In response to Alathon
|
|
Alathon wrote:
Air _King wrote: Let me try it. |
In response to Air _King
|
|
Air _King wrote:
Alathon wrote: HERE IS MY CODE: mob/trainer icon='trainer.dmi' mob/trainer/var beingused = 0 mob/trainer/Click() if(beingused == 0) switch(input("Skill","What SKILL?")in list("SWORDS","MACES")) if("SWORDS") usr.PSW() beingused=1 if(beingused == 1) switch(input("Stop?","Stop training?")in list("Yes","No")) if("Yes")beingused=0 if("Yes")return if("No")beingused=1 mob/proc/PSW() src.Sowrds +=05 spawn(50) PSW() var beingused=0 mob/proc/PRAC() if(beingused == 1)PSW() IT JUST SAYS WHAT SKILL?I click swords then it says stop training same click, i click No and it starts training me, when i click it again it says stop training?i click yes and then pops up what skill and if i click maces which doesn't have a proc yet it still trains swords..WHY and how do i fix this??? |
In response to Air _King
|
|
Air _King wrote:
Air _King wrote: ...You really don't know how to code anything. This code is so basic I say we let him get this to work on his own. |
In response to Nadrew
|
|
Nadrew wrote:
Air _King wrote: I have tried for 2 hours!!!Thats why i came here!!! |
In response to Nadrew
|
|
Here's the culprit:
if(beingused == 1) The switch statement exits as soon as it finds a match. This means the second if("Yes") will never be checked, which is why you're incorrectly assuming that it doesn't return here. Instead, code it like this: if(beingused == 1) Or even more simply: if(beingused == 1) |
In response to Skysaw
|
|
Skysaw wrote:
Here's the culprit: > if(beingused == 1) The switch statement exits as soon as it finds a match. This means the second if("Yes") will never be checked, which is why you're incorrectly assuming that it doesn't return here. > if(beingused == 1) Or even more simply: > if(beingused == 1) It gives me an identation error when i know i've got it right ive even tried hit space and compile, but still it doesn't work!!!HEEEEEEEEELLLLLLLLLLPPPP!!!!!!!!!!!!! |
In response to Air _King
|
|
Did you copy paste from the code Sky gave you? Cause you should NEVER do that you should rewrite the code in your own form and not the one given to you.
|
In response to Air _King
|
|
Air _King wrote:
It gives me an identation error when i know i've got it right ive even tried hit space and compile, but still it doesn't work!!!HEEEEEEEEELLLLLLLLLLPPPP!!!!!!!!!!!!! what do you mean you "hit space and compiled?" |
In response to Air _King
|
|
Air _King wrote:
Skysaw wrote: > > if(beingused == 1) The switch statement exits as soon as it finds a match. This means the second if("Yes") will never be checked, which is why you're incorrectly assuming that it doesn't return here. > > if(beingused == 1) Or even more simply: > > if(beingused == 1) It gives me an identation error when i know i've got it right ive even tried hit space and compile, but still it doesn't work!!!HEEEEEEEEELLLLLLLLLLPPPP!!!!!!!!!!!!! I hope you know you cant copy code directly from the forum (thank god, atleast make em type it in themselves :P), and that you use TAB to indent, not space.. Alathon |
In response to Alathon
|
|
Alathon wrote:
Air _King wrote: > > > if(beingused == 1) The switch statement exits as soon as it finds a match. This means the second if("Yes") will never be checked, which is why you're incorrectly assuming that it doesn't return here. > > > if(beingused == 1) Or even more simply: > > > if(beingused == 1) It gives me an identation error when i know i've got it right ive even tried hit space and compile, but still it doesn't work!!!HEEEEEEEEELLLLLLLLLLPPPP!!!!!!!!!!!!! The tab won't work it sends me clear to the other side of the screen!!! |
In response to Air _King
|
|
Air _King wrote:
Alathon wrote: > > > > if(beingused == 1) The switch statement exits as soon as it finds a match. This means the second if("Yes") will never be checked, which is why you're incorrectly assuming that it doesn't return here. > > > > if(beingused == 1) Or even more simply: > > > > if(beingused == 1) It gives me an identation error when i know i've got it right ive even tried hit space and compile, but still it doesn't work!!!HEEEEEEEEELLLLLLLLLLPPPP!!!!!!!!!!!!! What is a code block? I typed compiled it, but now it says Procs.dm:38:error::expected a constant expression Procs.dm:41:error::expected "if" or "else" Procs.dm:42:error:if :expected code block Procs.dm:42:error::expected "if" or "else" |
In response to Air _King
|
|
Air _King wrote:
Air _King wrote: > > > > > if(beingused == 1) The switch statement exits as soon as it finds a match. This means the second if("Yes") will never be checked, which is why you're incorrectly assuming that it doesn't return here. > > > > > if(beingused == 1) Or even more simply: > > > > > if(beingused == 1) It gives me an identation error when i know i've got it right ive even tried hit space and compile, but still it doesn't work!!!HEEEEEEEEELLLLLLLLLLPPPP!!!!!!!!!!!!! Constant expression means you cant pass an argument into it(heres an example) this does not work, because switch needs a constant expression switch(src) if(gold > 20) // DOESNT WORK return How about giving us the line the problem is at, that way we can see the problem lines. Also a few lines before and after Alathon |
In response to Air _King
|
|
Even if you get this code to "work", but if I'm reading it correctly, it still won't work... even if you hit stop practicing, it will still keep spawning PSW(). You need to learn to read through your code, line by line, and follow what is called the "thread of execution." That is, start at the first line of the proc, and in your mind, think about what will happen when that executes. Then go to the next line, and do the same. Don't just decide to stop at the point where you want the code to stop. Keep reading, following all the spawns and loops, doing any math and changes in your head, until you get to a point where the code actually does stop.
|
In response to LexyBitch
|
|
LexyBitch wrote:
Even if you get this code to "work", but if I'm reading it correctly, it still won't work... even if you hit stop practicing, it will still keep spawning PSW(). You need to learn to read through your code, line by line, and follow what is called the "thread of execution." That is, start at the first line of the proc, and in your mind, think about what will happen when that executes. Then go to the next line, and do the same. Don't just decide to stop at the point where you want the code to stop. Keep reading, following all the spawns and loops, doing any math and changes in your head, until you get to a point where the code actually does stop. Ok, so when i put a if isbeingused in the proc it gives me errors.WHY? |
In response to Alathon
|
|
Alathon wrote:
Air _King wrote: > > > > > > if(beingused == 1) The switch statement exits as soon as it finds a match. This means the second if("Yes") will never be checked, which is why you're incorrectly assuming that it doesn't return here. > > > > > > if(beingused == 1) Or even more simply: > > > > > > if(beingused == 1) It gives me an identation error when i know i've got it right ive even tried hit space and compile, but still it doesn't work!!!HEEEEEEEEELLLLLLLLLLPPPP!!!!!!!!!!!!! Ok let me get them... |
In response to Air _King
|
|
Air _King wrote:
Ok, so when i put a if isbeingused in the proc it gives me errors.WHY? Who knows? Since we're being so vague, I'll give you a vague answer: Because there is an error. Seriously, think about your question. What if I said to you "there is something wrong with my car. What is it?"... do you think you could answer it? |
In response to Air _King
|
|
Air _King wrote:
I hope you know you cant copy code directly from the forum (thank god, atleast make em type it in themselves :P), and that you use TAB to indent, not space.. ...Here it is mob/trainer/Click() if(beingused == 0) switch(input("Skill","What SKILL?")in list("SWORDS","MACES")) if("SWORDS") usr.pswords() beingused=1 if(beingused==1) switch(input("Stop?","Stop training?")in list("Yes","No")) if("Yes")beingused=0 return if("No")beingused=1 else Ok there it is, i have a pswords proc here it is: mob/proc/pswords() src.SWORDS +=5 spawn(50) pswords() |
In response to Air _King
|
|
Air _King wrote:
...Here it is Your switch statement has two code sections under it... the first if the user inputs "SWORDS", and a second section which is meaningless, because the user cannot input beingused==1 Read up on switch in the Reference. |
1
2
Return WILL end a proc, it doesnt restart it. Which is why you can do something like this
mob/verb/Blaah(mob/M)
if(!M.key)
return // END THE PROC, if they dont have a Key
src << "Baah"
M << "Baah"
M.loc = src.loc
or whatever.
Alathon