Ok, I want it to take from health and happiness every 60 ticks, but the code only does it once. I'm not sure what to do.
New()
usr.Move(locate(5,6,1))
. = ..()
spawn()
healthdown()
proc/healthdown()
if(health) spawn(60) health -= 5
if(happy) spawn(60) happy -= 5
return
ID:149362
May 15 2002, 4:33 am
|
|
Likwiddraino000 wrote:
Ok, I want it to take from health and happiness every 60 ticks, but the code only does it once. I'm not sure what to do. Huge problems in your code, here.
New() Lummox JR |
In response to Shadowdarke
|
|
I put the code in there but it never takes health or happiness from the player.
New() //This is called when the atom enters the world ..() spawn(60) healthdown() proc/healthdown() health=max(health-5,health) happy=max(happy-5,happy) spawn(60) healthdown() |
In response to Likwiddraino000
|
|
Likwiddraino000 wrote:
I put the code in there but it never takes health or happiness from the player.[snip] proc/healthdown() You botched both calls to max(). Shadowdarke and I both showed you the same code (I guess we posted more or less simultaneously) but with a different order to the arguments. Instead of pointing you back to our code right away, I'm gonna give you another look at what you did here so I can say "DUH!" health=max(health-5,health) max() returns the bigger of two values. Which is bigger, health or health-5? DUH! Now back to our code. Shadowdarke and I both put this instead (except Shadowdarke put the 0 first): health=max(health-5,0) Slightly different, isn't it? This says to use health-5 for the new health value, unless it's less than 0--then 0 is greater, and it's used instead. Lummox JR |
New()
usr.Move(locate(5,6,1))
. = ..()
spawn()
healthdown() <font color=#ffffa0>// extra tab here</font>
proc/healthdown()
health = max(0,health - 5) // if health-5 is less than 0, then health will be 0
happy = max(0,happy - 5)
spawn(60) // in 6 seconds
healthdown() // do this proc again