ID:146064
 
Code:
mob
Login()
Hunger_Check()
Thirst_Check()
Stat()
statpanel("Character")
stat("Thirst: ","[usr.thirst]")
var
health = 100
thirst = 10
proc
Thirst_Check()
spawn(600)
usr.thirst -= 5
Dehydration_Check()
return Thirst_Check()
Dehydration_Check()
if(usr.thirst <= 0)
usr.health = 0
Death_Check()
Death_Check()
if(usr.health <= 0)
usr << "<strong>You have died..."
usr.loc = (locate(30,27,1))
usr.health = 100
usr.hunger = 100
usr.thirst = 100
usr.endurance = 100
usr.tool = null
usr.thirst = 100


Problem description:
I get no errors or warnings on Dream Maker, and I personally belive this is not my fault, but when I run the game, the thirst counter does not go down on the stat panel. It is exactly the same as my hunger system, which works, execept of course the varibles. Am I missing something?

If you need more information, I'll be happy to provide that...

Don't use 'usr' in procs.
In response to Mega fart cannon
Well, I had basically the same thing used for another purpose, and it worked with usr. It makes no difference with or without it in the code.
In response to Mega fart cannon
Mega fart cannon wrote:
Don't use 'usr' in procs.

Don't use 'usr' in MOST procs.

Usr Lecture and Usr Unfriendly are two good articles explaining why.
In response to Bobthehobo
You shouldn't use it anyway.
In response to Kalzar
But could anyone explain my problem?
1.) No usr in proc ( It's splattered all over that code. )

2.) Use sleep instead of spawn

3.) Use a while loop

mob
Stat()
statpanel("Character")
stat("Thirst: ","[thirst]")
proc
Thirst_Check()
while( src )
thirst -= 5
Dehydration_Check()
sleep( 600 )
Dehydration_Check()
if(thirst <= 0)
health = 0
Death_Check()
Death_Check()
if(health <= 0)
src << "<strong>You have died..."
loc = (locate(30,27,1))
health = 100
hunger = 100
thirst = 100
endurance = 100
tool = null


I just rewrote your code without using usr at all. Also took out that redundant line you had.
In response to Audeuro
Thank you!

EDIT: It's still not working, now I know its a software glitch!
In response to Bobthehobo
I did nothing for you. I took the lesson everyone else was trying to teach you and simply applied it, as well as making a few changes that might have made the code faster.

Note: You also had an infinite loop there with your return Thirst_Check(). The while( src ) fixed that.
In response to Audeuro
Well, I just foudn the real problem. Because the checks are repeaters, the hunger check kept going on and on, thereby not running anything under it in the login proc.
In response to Bobthehobo
mob
Login()
Hunger_Check()
Thirst_Check()
Stat()
statpanel("Character")
stat("Thirst: ","[usr.thirst]")
var
health = 100
thirst = 10
proc
Thirst_Check(mob/M)
sleep(600)
M.thirst -= 5
Dehydration_Check()
Thirst_Check()
Dehydration_Check(mob/M)
if(M.thirst <= 0)
M.health = 0
Death_Check()
Death_Check(mob/M)
if(M.health <= 0)
M << "<strong>You have died..."
M.loc = (locate(30,27,1))
M.health = 100
M.hunger = 100
M.thirst = 100
M.endurance = 100
M.tool = null
M.thirst = 100

That will fix some stuff.
In response to Popisfizzy
Well, I figured it out, everything works now, thank you everyone!
In response to Sinoflife
Sinoflife wrote:
Mega fart cannon wrote:
Don't use 'usr' in procs.

Don't use 'usr' in MOST procs.

Usr Lecture and Usr Unfriendly are two good articles explaining why.

In my view, Click() and DblClick() aren't true procs, since they are called when something is 'clicked'/'double clicked'.
In response to Mega fart cannon
Mega fart cannon wrote:
Sinoflife wrote:
Mega fart cannon wrote:
Don't use 'usr' in procs.

Don't use 'usr' in MOST procs.

Usr Lecture and Usr Unfriendly are two good articles explaining why.

In my view, Click() and DblClick() aren't true procs, since they are called when something is 'clicked'/'double clicked'.

Login()? Stat()?
In response to Sinoflife
I'm pretty usr that the usr friendly procs are Enter(),Entered(),Exit(),Exited(),Click(),DblClick(),Login() ,Logout(), and Stat(). Correct me if I'm wrong though.
In response to Popisfizzy
Popisfizzy wrote:
I'm pretty usr that the usr friendly procs are Enter(),Entered(),Exit(),Exited(),Click(),DblClick(),Login() ,Logout(), and Stat(). Correct me if I'm wrong though.

Not Logout().
In response to Sinoflife
What about Move()?
In response to Sinoflife
'mob/Login() can't use usr safely if you call it manually or if character loading is used'

'mob/Stat(), where usr is the player who sees the statpanel, and src is client.statobj which is usually the same.'
In response to Mega fart cannon
Mega fart cannon wrote:
usr is valid in:
'mob/Login() can't use usr safely if you call it manually or if character loading is used'

'mob/Stat(), where usr is the player who sees the statpanel, and src is client.statobj which is usually the same.'
In response to Sinoflife
The only usr safe procs are, Click(), Dblclick(), rarely mob/Login(), mob/Stat(), and when not forcefully called, mob/Logout().

[edit] Whoops, I forgot about the others, client/New() takes the same precautions as mob/Login(), and client/Del() also has the same precautions as mob/Logout(). client/North(), ..., ..., etc., are also usr friendly.