Code:world
New()
hungerdrop()
proc
hungerdrop()
sleep(60)
for(var/mob/M in world)
if(M.hunger==0)
var/damage=rand(1,4)
M<<"You lose [damage] hit points due to hunger."
M.hp-=damage
else
M.hunger-=1
if(M.hunger==0)
M<<"You are starving, you should go eat something."
hungerdrop()
Problem description: First off this is not my coding, but coding used from a demo provided by Satans Spawn. The only reason I am using this code as an example, as I could not get my own to work to see if it was an issue with my code or not. I had all the same variables, I don't know why this will not work correctly or any similar proc.
So if this code works in a demo, I don't know why I can't get this or similar proc's to work. Something must be conflicting but what could do so? I have a Login() proc being used. It is used to choose my classes, could that delay cause the proc not to "kick in" or "cancel out?". The demo had no login, just run and you were in. That is my best bet, so my question is, how can I get this and other proc's that run in loops to constantly run? I am not actually going to use the code provided, but if I can solve this code issue, I can solve my real actually issues. My guess is the Login() proc but I am not sure, any feedback idea's, etc, are appreciated.:P
ID:264227
Nov 3 2008, 2:03 pm
|
|
In response to Jeff8500
|
|
THANK YOU THANK YOU THANK YOU. Ok maybe I went a little over the top, but I tried everything including mob/proc (As I also thought that might be the cause.) I tried using for() using while(), etc. The main issue was the Login().
You have shown me the light, and now I can get back to coding my game. Thanks again. -Shaken EDIT: Alright now I have a totally new question. Can I call two proc's at the same time? My Login() looks something like this: mob Now I have tried different combinations, and I can't find a way for them both run at the same time. I can either get one to run then the other, or just one to run. So my question is, is it possible to run 2 procs at the same time? |
In response to Shaken_bacon
|
|
Yes, this is very possible. However if one of your procs is an infinite loop, it'll never get to the next line of the procs. Use spawn proc1() to let it execute the rest of your code before returning to the infinite loop.
|
I'll lay out an Example:
world This is how you do it. |
In response to Speedro
|
|
Thank you everyone, with some tinkering around I got my code working. (properly, or so I think :P)
I could not have done it without every piece of advice, so thank you so much! |
Also, you can't always trust demos. Satans spawn programs accordingly.
It sounds like the reason that this doesn't work is that it's a global proc, and you're calling it upon login, making it affect every mob. Then, it calls it again for every mob in the world, and will eventually boost your CPU usage so high that the world freezes.