| Blockland Forums > Modification Help |
| how would i slow a for statement? |
| << < (2/5) > >> |
| phflack:
ahh, thanks, is there anyway to stop a function while it's running? as i'm using this in the console to auto eat for the stranded gamemode, as i'm building and i don't want to die when i forget, would this work? function eat(%i){commandtoserver('consume', "purifiedwater");commandtoserver('consume', "banana");if(%i != 5){schedule(10000, 0, eat);}else{break;}} so, when i type eat(); it would loop, when i type eat(5);, it would stop? edit: forgot ask in the OP, how would i put a message before a variable when talking, when using this: commandtoserver('messagesent', %i); |
| Placid:
--- Quote from: phflack on August 27, 2010, 05:14:10 PM ---ahh, thanks, is there anyway to stop a function while it's running? as i'm using this in the console to auto eat for the stranded gamemode, as i'm building and i don't want to die when i forget, would this work? function eat(%i){commandtoserver('consume', "purifiedwater");commandtoserver('consume', "banana");if(%i != 5){schedule(10000, 0, eat);}else{break;}} so, when i type eat(); it would loop, when i type eat(5);, it would stop? --- End quote --- you would do this: --- Code: ---function eat(%i) { commandtoserver('consume',"purifiedwater"); commandtoserver('consume',"banana"); if(%i !="5") { $eatsched=schedule(10000,0,eat); } else { cancel($eatsched); } } --- End code --- This would make it so when %i is anything but 5, it will eat and purifiedwater every 10 seconds. If %i is 5, then the schedule will stop. |
| phflack:
but, it will update when i use 5, right? and by the way, i'm just using this for in the console, not for a client_eatcommand thing edit: thanks, it worked, also, what is the $ sign for? i figured out % is for a variable |
| Placid:
--- Quote from: phflack on August 27, 2010, 05:59:49 PM ---but, it will update when i use 5, right? --- End quote --- yes --- Quote from: phflack on August 27, 2010, 05:59:49 PM ---and by the way, i'm just using this for in the console, not for a client_eatcommand thing --- End quote --- i would suggest just making it as a function in a script so you won't have to retype the whole thing over and over again, which is always a pain. that way, you could call it at any time without having to type the full function. |
| phflack:
true, i might go do that, basicaly that's the client.cs, and then add a description.txt and put it in client_eatcommand? edit: i can put multiple functions in the same client.cs, right? |
| Navigation |
| Message Index |
| Next page |
| Previous page |