# Playtime or Timer Variable as Gold?

#### Kikanai

##### Villager
So my idea is to let the hero own a shop. Every once in a while he can check in and get an amount of gold depending on how long it has been since he last checked. What would I need to do in order to make this work out? Also I want to start the "timer" for this when he first visits it, not when the game is started for the first time. I guess for that I need a switch, and that would be no problem for me. Still, this might be important to know for giving me some help.
I was looking through variables and found the "Playtime" operand. Is this measured as seconds?

----

I am still pretty new to variables and try to process what exactly you can and can't do with them.
I've been doing tutorials and practicing variable stuff over the last few days, but sadly I can't really find anything similar to this. Either that, or I don't have enough imagination to copy it onto this case.

#### MushroomCake28

##### KAMO Studio
The "time unit" used to calculate time in RPG Maker (XP, VX, VX Ace, MV) is the number of frames. I put time in "" because it's not really a measure of time, but a measure of how many frames the game engine has output. Since the game engine is designed to run constantly at 60 fps (even if you can run it higher, or slower), you could say that 60 frames = 1 second.

As for your mechanic, wouldn't it be better to start the timer when the player first builds the shop? At that moment, set a variable to the amount of total frames (the playtime), and when the player comes to collect the money calculate the difference between the current time and the time when the player built the shop.

So if the player builds the shop at 10 mins of gameplay, you'll store 600 in a variable.
If the player comes back to collect money at 15 mins of gameplay, you'll store 900 in another variable.
The profit will be calculated this way:

Code:
``````initial_time    = 600;
current_time = 900;
profit_rate     = 1.5; // Gold per frame

profit = (current_time - initial_time) * profit_rate;``````

Of course, when that happens, the initial_time becomes the current_time (so initial_time is now set to 900), and the next time the player comes to collect money form the shop, the playtime will be the new current_time variable.

#### Kikanai

##### Villager
Thank you for the explanation.

I tried to get it to work, but sadly it's too complicated for me. I can't get it to work.
Either it doesn't count the time at all, doesn't reset the timer, or
... well I don't know, the event says I played like "123" seconds / frames / minutes, does not reset the timer and the second time I talk to the event it's like "7", 3rd time talking to it I'm at "124" seconds / frames / minutes and the fourth time its "8".

I don't know what mistake I made and I think my brain is not able to process what is happening xD

So I guess I will throw that idea over board, since it's too hard for me.

#### Andar

##### Veteran

I suggest not simply ignoring this because it sounds as if your problems are with variables, and even if you don't do this specific thing, I can guarantee you that you will need variables sooner or later in your game.

#### Kikanai

##### Villager
I don't think a screenshot would help since its in german, but here's what I did:

Eventpage 1:
>Message (Smt like "I'm the Shopkeeper, timer starts now blah blah")<
>Variable "Shop opened" = Playtime<
>Selfswitch A on<

Eventpage 2 condition Selfswitch A:
>Variable "Shop Timer = Playtime<
>Variable "Shop Timer" - Variable "Shop opened"<
>Variable "Shop Timer" / 60<
(Bc 60 frames = 1 Second)
>Message (Smt like "you waited x Seconds")<
>Message (Smt like "you gain x amount of Gold")<
>Variable "Shop opened" = Variable "Shop Timer"<

Though it seems like the dividing with 60 part aren't seconds anymore, but minutes...
Aside from that, when I talk to the Event a second time, when it's on page 2, it says "You waited 0 seconds / you gain 0 Gold"

#### Andar

##### Veteran
I don't think a screenshot would help since its in german, but here's what
The language doesn't matter, because there are only a limited number of commands and we know how they look like.

edit: snipped, I mixed up two cases in my unedited answer, forget what I wrote in this part before

So please, give screenshots of BOTH event pages.

besides - if you even tried to check the user data you would have seen that I'm also german, so please give the screenshots if you want help.

#### Kikanai

##### Villager
you would have seen that I'm also german
Oh oops. Didn't notice that. Sorry.

Here are the screenshots. And I am aware, I haven't added the actual Gold yet.

#### Kes

##### Veteran
[pirate]IgnoreMe[/pirate]

### Latest Profile Posts

Draw something
Me: No problemo! ''draws something''
Now draw the same thing from a different angle
Me: So....You have discovered my weakness...
I got a new PC... Nothing wrong with my lil laptop at all! Still works great, and I'll be using it for school. But, the specs for gaming were falling off fast. So I was selfish and bought myself a beast of a PC ^-^

Held hostage in my own house half the day by an old man that cant take hints or read body language, STILL manage to make some pixels! booyah! I should get a promotion!....No wait...I should get a job
Potions are to be hoarded, not used...
Moar screenshots!!!