Resource Timer

In Aveyond 2, there's a feature where you can get eggs and milk from your farm every couple of hours or so. I want to add something like that to my game, but I have no idea how to do it. I get the feeling the feature in Aveyond 2 was done through a mixture of scripts and event commands, but as I said, I have no idea how I would achieve this.

Here's how it worked in Aveyond 2, at least from a player's perspective: You have the chickens. They lay eggs. You get the eggs. If you come back before a certain time after you get the eggs there aren't any eggs to pick up. After a certain time you can get more eggs, etc. With the milk it's the same thing except you have a cow. I think even the tournament in the game used the same system. I say this because you had to wait actual time to continue through it, instead of simply exiting and reentering the area.

I don't know how I would achieve this, and I can't seem to find a script out there that does this.

I'd like something like what Aveyond 2 has because my game has a crafting system, and I'd like the player to be able to get items from the environment and not just from enemies, stores, and chests.
search for "event timer", Shaz wrote a script exactly for that.
Not sure about Aveyond 2.
But, in NEOLITHIC, there are 2 types of timers.
The in-game time timer is using "Graphics.frame_count / Graphics.frame_rate"
When you collect some resource you record the current "Graphics.frame_count / Graphics.frame_rate" into a variable. Each time you get near the "resource" you just need to check "Graphics.frame_count / Graphics.frame_rate" against the previously recorded variable to see if enough time has passed.

Another timer is using the system time by calling "Time.now" it will give you the "Linux time". However, it will no longer work after 2038.

Not sure if any other games will still update after that day. But, a much safer solution will be to call win32API to get system time. Personally, I also made a DLL just for that purpose.
Not sure about Aveyond 2.
But, in NEOLITHIC, there are 2 types of timers.
The in-game time timer is using "Graphics.frame_count / Graphics.frame_rate"
When you collect some resource you record the current "Graphics.frame_count / Graphics.frame_rate" into a variable. Each time you get near the "resource" you just need to check "Graphics.frame_count / Graphics.frame_rate" against the previously recorded variable to see if enough time has passed.

Another timer is using the system time by calling "Time.now" it will give you the "Linux time". However, it will no longer work after 2038.

Not sure if any other games will still update after that day. But, a much safer solution will be to call win32API to get system time. Personally, I also made a DLL just for that purpose.
I think the in game timer is how it was done in Aveyond 2, because time didn't pass outside of the game.

How would I use the "Graphics.frame_count / Graphics.frame_rate"? I'm not sure how to set it up so it would run properly.
Code:
module Graphics
  def self.seconds() frame_count / frame_rate end
end

Call Graphics.seconds to get the seconds that have passed ever since the game started running. Use modulo or % 60 to get minutes, and so on.

You could also search for my XP script KTimers I had published long time ago.
Code:
module Graphics
  def self.seconds() frame_count / frame_rate end
end

Call Graphics.seconds to get the seconds that have passed ever since the game started running. Use modulo or % 60 to get minutes, and so on.

You could also search for my XP script KTimers I had published long time ago.
I looked up your script and it seems like it's close to what I'm looking for.
I do have one question: Does this script allow for multiple resources? Say, for instance, I want a timer for a cow to produce milk and a timer for chickens to produce eggs. Could I do that with how the script is currently, and if not is there an addition that could be made to achieve this?

I apologize if this was answered on the forum you posted the script in. I am not a smart woman when it comes to scripts.
Edit: To clarify what I mean by that: I've probably have seen the answer to my question, but I haven't processed it in a way that makes me know "oh that's the answer to my question."
In terms of scripting language, I am illiterate.
I looked up your script and it seems like it's close to what I'm looking for.
I do have one question: Does this script allow for multiple resources? Say, for instance, I want a timer for a cow to produce milk and a timer for chickens to produce eggs. Could I do that with how the script is currently, and if not is there an addition that could be made to achieve this?

I apologize if this was answered on the forum you posted the script in. I am not a smart woman when it comes to scripts.
Edit: To clarify what I mean by that: I've probably have seen the answer to my question, but I haven't processed it in a way that makes me know "oh that's the answer to my question."
In terms of scripting language, I am illiterate.
Each event creates its own timer, so you can do this with the script as-is.
Looks like it's solved, and KTimers is a pretty good script indeed as far as I know.
But just in case, I have a script for Event Timers as well, so you can check it out.
Each event can have its own timer, but only one by default. It should be enough, though.

You could also do it using Self Variables to define the timer, with that you can have many timers in just one event, but it's a bit more complicated to use.

Also, just to clarify, you don't need a Win32API call to get the system time as orochi2k said, because Ruby (and RGSS) has a Time class already integrated that does that for you:

Code:
Time.now

That being said, I don't recommend this; I think using the internal game timer (frame count) is better in this case. (Funnily enough, my script has both options on the configuration.)

Original thread: https://forums.rpgmakerweb.com/threads/resource-timer.137974/