Discussion

saving time started and exited in a program to calculate idle earnings

2

CLIGUI 2023-01-11 01:55 (Edited)

I am trying to make a clicker game with offline earnings. I don’t know how to creat an economic system that pays the player a whole number integer of a variable or if the system would even work since the timers reset, but I imagine there is a solution.


was8bit 2023-01-11 06:34 (Edited)

I am having trouble understand exactly what you want... but i will try to help...

NUM=INT(3.1418) will make NUM=3

You can save player progress using PERSISTENT memory... however lowresNX does NOT access real time, so there is no way to track how much time has passed since the player played the game...

... you CAN store how much time a player has spent playing the game.... then you can use that to trigger events based on that... so say if a player plays for 30 minutes... assuming you predict a player will play your game 30min/day, then when they come back into the game again, your code could assume a whole day has passed... if their last play time was only 5 minutes, then when they come back to the game again, the game could assume its still the same day...

... this could be a compromised best guess for the code simulating keeping track of how much time has passed between game plays...



CLIGUI 2023-01-11 14:47 (Edited)

I see, thanks for the example.


CLIGUI 2023-01-11 14:56

Also to clarify what I mean is if you save the time a player starts a program and exits the program you could subtract the difference next time they run the code and use that number to calculate the money they made offline. Because the timers reset it could have a maximum of 24hrs that when reached will stop tracking the time so the earnings are accurate.


nathanielbabiak 2023-01-11 16:21

This console does not have a real time clock. What you envision is not possible.

The system variable TIMER represents how many frames the system has been running since. It persists through restarts.


was8bit 2023-01-11 18:30

If your main game loop is...

DO

WAIT VBL
LOOP

I had precisely 60 cycles per second... so

DO

INC T
IF T=60 THEN
INC S
T=0
END IF
WAIT VBL
LOOP

and S then counts how many seconds goes by... if you add another IF statement at 60 seconds, you could update and save to persist memory the total number of minutes that go by...

When the code starts, you check the persist memory of how many minutes saved, and reset that back to zero to track current game time :)


CLIGUI 2023-01-11 20:36 (Edited)

This is sort of what I am trying to make, thought I would check if it worked. (I used a pic from My zombie game just to be quick).

Idle Earnings.nx | Open in app
2023-01-11 20:36

CLIGUI 2023-01-11 20:37 (Edited)

It has to be downloaded to be used, also since money is reset to zero each time you save for this example it only counts the seconds that have passes since it was saved last. But it is usually wrong especially the longer you wait.


was8bit 2023-01-13 15:59

For long term playing, you will encounter an error when the timer value flips back to zero...

I forget what the maximum number for timer is.... i will try to find it...


was8bit 2023-01-13 16:05 (Edited)

You might want to provide an honor system of letting the player input how much time has passed since their last play...

Maybe like H,D,W,M,Y... it does allow for cheating, but at least the player is in control of that...


was8bit 2023-01-13 16:08

... here you go...

=TIMER

TIMER
Returns the number of frames shown since LowRes NX was started. The value wraps to 0 when 5184000 is reached, which is about 24 hours.


was8bit 2023-01-13 16:10 (Edited)

You should be able to detect how many hours has passed with your system, with a fix for the flip... but you wont be able to track how many days....

At game start up, you will have to have an option for "time passed <24 hours, >24 hours" if less than, your system works... >24 hours, you need to provide player input for how many days...

... that would be the best and simplest approach :)


CLIGUI 2023-01-13 16:43

Thanks for the info. Another good mechanisms for idle earnings could be a currency which gives 24hrs of pay when used. This would additionally allow the player to save up the currency for more pay later when they are making more money.


CLIGUI 2023-01-13 16:45

It would be best if it was given to the player once a day, it would be easier to code as well (I think).


was8bit 2023-01-13 18:14

So in that case, you could forgo tracking time and just offer a prompt at start like “same day or new day” and apply the added $ only when they select “new day”


Log in to reply.