I'd like to make a timer so that only when the player is standing still for a series of cycles, it could trigger a nice action like saying something, or scratching or looking at the clock. Something like
if(!player.Moving)
{
SetTimer(1,10000);
if (IsTimerExpired(1))
{
player.Say("I'm getting bored");
,,,,any other action....
}
}
but I don't know where to place it and how to make it work correctly...
Characters already have a "Idle View" mechanic that practically does that, you could use that directly, or use a "dummy" idle view to trigger your code. Set a "idle view" and configure "idle delay" for a character. Then in "repeatedly_execute" test whether idle view had started, and do your thing.
function repeatedly_execute()
{
if (player.View == player.IdleView) {
// your actions
}
}
Relevant articles in the manual:
https://adventuregamestudio.github.io/ags-manual/Character.html#characteridleview
https://adventuregamestudio.github.io/ags-manual/Character.html#charactersetidleview
oh thanks! I solved it!!
Without the idle mechanic you could do this:
int idleFrames;
// inside on_mouse_click
idleFrames = 0;
// inside repeatedly_execute
idleFrames++;
if (idleFrames >= GetGameSpeed() * 10) ... // 10 seconds idling
This works because during a blocking interaction like examining something, rep_ex doesn't run, so the timer will correctly start to run again as soon as the game returns to idling.