ID:1539171
 
(See the best response by FishMan123.)
Code:
mob
var
-hunger= 100
-thirst= 100
-health= 100
Login()
-sleep(300)
-world << "I'm Thirsty."
-usr.thirst -= 10
-sleep(600)
-world << "I'm getting Thirsty."
-thirst -= 10</b>


Problem description: Im trying to get the timer working. I need two things, first, it wont work. reads NO errors though. Second I need a way that it starts when player logs in, not sure if the New() command works for this? And I need a way that it will repeat the same code over and over. Thanks guys, I love this so far :)

also, how do I clear invent during deathcheck? usr.content = null
and how do i del two objects at the same time? for instance, i want to make player load pistol, but also del ammo at the same time. How? so many questions...
Best response
Sorry, wrote this on phone but this should be what you're looking for:

mob/Player
var
Thirst = 0
Health = 100
MaxHealth = 100

proc
Thirst_Check()
while(src && src.Thirst<100)
sleep(300)
src.Thirst+=10
src<<"You're thirsty."
src.Health-=round(src.MaxHealth/10,1)
src<<"\red Health: [src.Health]%"
src.DeathCheck()

DeathCheck()
if(src.Health<=0)
src<<"\red You've died!"
src.loc=locate(1,1,1)
src.Health=100
src.Thirst=0

Login()
..()
src.Thirst_Check()
Sorry for the lack of documentation but it was already a huge pain in the ass getting all that spacing etc..
wow thanks man
Ok, got that written down in my code file, i compiled and it said undefined var. For this line: scr<<"\red Health: [src.Health]%"

Np
You can if u want to but that wouldn't be very productive would it xD? you should preferably look at it and try to understand it and then make your own system.

Anyways, the reason yours wasn't working was because u didn't add the ..() in your Login() which basically tells it to do this behavior on top of any other actions u may have added under Login() else where.

You should check for wherever you have Login() and add this if you don't want it to interfere later on in the road.

Also, there's no need to add all those dashes. All you need is to directly copy your code from DM under the DM tags

Finally, you should look into the
while
function in order to easily create loops, while certain conditions are met
Dude, your awesome, but its not quite working.
scr<<"\red Health: [src.Health]%"

this says undefined var. hmm
That should be src, not scr
LOL. Thanks ;)
So this won't reduce my thirst stat? The code was supposed to lower the thirst slowly then when depleted kill player, does this happen now?
Yes, I just switched your logic around. As decreasing your thirst making you die doesn't make much sense.

I've made it so your default thirst is 0 but will gradually increase by 10 every 30 seconds, until it reaches 100. Every time your thirst increases, your health will decrease by 10% of your maximum hp. Meaning that once your thirst reaches 100, you'll die. Unless of course you managed to die before that were to happen (let's say you got stabbed or something)
hmm not working yet.
Wow thats cool logic, but I screwed it ;P
Make sure to head my warning about Login()
Also, you probably just need to change your default mob to mob/Player, which you can accomplish by doing this:

world
mob = /mob/Player
I would like the player to be able to drink water and put his thirst back up to original.
pretty please?
ok, now its working, but the deathcheck isn't.
Nope, fixed deathcheck, but when i die the process doesn't restart?
Nope ;)
Fixed that too...
Now, how do i get an obj to fill up Thirst var?
Just use a obj verb
obj/Usable_Items

verb/Get()

Water
icon='Water.dmi'

verb/Drink()
In response to Flying1ace
Flying1ace wrote:
yes, did that and now it works! Your a genius! Just quickly, could you give me the code that would get a drinkbottle to refill his thirst?
Page: 1 2