Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Making A Variable Decrease in a Certain Amount of Time -DBP-

Author
Message
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 16th Jan 2007 16:19
ok, i have a hunger and energy float, i want them to decrease every minute automatically so when you sleep or eat it actually does something valuable and brings your sleep up from 99 to 100 (which they already increase the amount).

example:

hunger : 100
energy : 100

1 minute later:
hunger : 95
energy : 94

can you help me?

thanks!

Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 16th Jan 2007 16:32


That should do it.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Jan 2007 17:05 Edited at: 16th Jan 2007 17:05
Timer() gets you real time in milliseconds...





Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 16th Jan 2007 17:39
That also works...

nut i never experimented with Timer() before,so i didnt want to use it in the example

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Jan 2007 18:47
The original snippet only works at 1000 FPS.

Timer() uses the Windows timer, which is hardware driven. So the speed of the game is irrelevant.



Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 16th Jan 2007 20:24
It wont work with the LOOP command, can you format to work with this code?



Thanks Anyway!

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Jan 2007 09:21
Quote: "It wont work with the LOOP command"


Timers do work with do/loops... you just mean you don't have do/loops in your code, right? Timers can work anywhere in any kind of loop and/or function.

This also has two commands you may have not seen before "remstart" and "remend" for those times you want a huge amount of "rem"s without typing "rem" each line (also good for reming off sections of code when your trying to track down hard to find nesting errors).

Login to post a reply

Server time is: 2024-09-25 15:29:27
Your offset time is: 2024-09-25 15:29:27