Timers

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Timers
Shaper
Member # 22
Profile #0
Are timers in any way possible in BoA?

The most obvious way, as I saw it, was to do the following -

inc_flag(0,0,1);
if(get_flag(0,0) == 5)
{
code chunk
}
break;

Unfortunately, when I put this in the START_STATE in a town script, it tells me I have an improper command. I figured this was because the game thought I was creating an eternal loop (though I wasn't - the code I'm using is a bit more complex then that), but I'm not entirely sure what to do about it. I also tried it with variables.

Any ideas for making this work, or an alternative timer?

Scrap that. I found me a workaround -

beginstate START_STATE;

if(get_flag(180,1) == 0)
{
timer = get_current_tick();
set_flag(180,1,1);
}

if((get_current_tick()) == (timer + 6))
{
add_dialog_str(0,"This is working",0);
add_dialog_choice(0,"Done");
run_dialog(0);
}

break;

Where timer is (obviously) a variable.

[ Wednesday, April 28, 2004 09:28: Message edited by: Morgan ]
Posts: 2862 | Registered: Tuesday, October 2 2001 07:00
Shock Trooper
Member # 4180
Profile #1
If I'm understanding you correctly, and you're wanting an event that happens every nth tick, an alternative would be:

if ((get_current_tick() % n) == 0) {
// do stuff here
}

(where n is the number of ticks between occurences). Of course, that doesn't allow you to start on a particular tick and then every nth one after that... it just hits every nth one starting with the next multiple of n.

--------------------
-spyderbytes
Posts: 200 | Registered: Wednesday, March 31 2004 08:00
Shaper
Member # 22
Profile #2
No - it's linking into a creature script, where the monster teleports away for five turns, then returns. Your's would be better alternatively, though.
Posts: 2862 | Registered: Tuesday, October 2 2001 07:00