How to add experience to a player over an amount of time

What is the basic function to start the clock when a character goes on a quest and add 10 experience per 20 minutes on the quest. [import]uid: 35843 topic_id: 27591 reply_id: 327591[/import]

You are talking about a timer not a clock, I believe. (Unless you actually want to access the device clock?)

If a timer;
[lua]local function addXp()
–add experience here
end
timer.performWithDelay(1200000, addXp, 1)[/lua]

That said checking the device time when certain conditions are met and then calculating elapsed time may be better. Have you considered that? [import]uid: 52491 topic_id: 27591 reply_id: 112168[/import]

thank you soo much and sorry about the extra threads :confused: [import]uid: 35843 topic_id: 27591 reply_id: 112223[/import]

i’m kinda new corona so not very good at coding o what do you mean by calculating elapsed time? [import]uid: 35843 topic_id: 27591 reply_id: 112224[/import]

It’s OK, just be mindful of it with the threads; it’s much easier to keep track of one per topic :wink:

As to calculating elapsed time, you could get the time from the device when you start the question, for example it might be 10:20 (you’d also get seconds but I’m using minutes to keep it simple) and then you could check the time later on, say when the hero entered/exited a building, picked up an item, etc. - really any events that will happen through the course of game play. Then you would take that time and calculate the time different between the two.

Eg; if the time was 10:41 and the previous time was 10:20 as per our example then you’d know 21 minutes had passed and you should reward the extra experience. [import]uid: 52491 topic_id: 27591 reply_id: 112265[/import]