Trigger to create a timer

Posted by ErockMahan on Tue 09 Dec 2008 06:56 PM — 4 posts, 21,823 views.

#0
I think what I'm trying to do is simple: I want a trigger to create a timer. It can't be a "do after special" deal, because if it fails, I want to try again.

Something like this (in alias form):

I type: fart Bob

It creates a timer called FartBob if possible. I want it to have a unique name so it can be deleted later...

After 5 seconds it sends to world "fart Bob"

If successful ("you fart on bob!"), I can have a trigger "deletetimer fartbob" delete it.

Otherwise ("You don't see bob here..."), it will try again in another 5 seconds.

I've tried the world.addtimer function, but that seems like it will fire at a certain time of day, not at a certain interval.

I suppose it would be easier to make a "only fire once" timer that would re-create itself on the failed message somehow, but I haven't seen anything like that in the help files either.

It isn't THAT important that I fart on dear Bob, so if this is going to be overly complicated, just let me know and I'll drop it. I'm sure people have better things to do with their time. (And in case you're wondering, the practical application of this is to be able to cast spells on a target when they are in another room so they'll be cast when I see them again. I don't go around farting!)
Netherlands #1
There's a number of ways to get what you want. Your primary issue is that you cannot seem to figure out how to set the timer to be an interval rather than a specific time of day. You could use ImportXML() to load a pre-written trigger, or alternatively you could use SetTimerOption() with your current AddTimer call. The option you'd try to set with SetTimerOption can be found by copying a timer with the interval option set and looking at it in notepad.

If you want, I can work out an example or stuff, but I think this should help you along for now.

Australia Forum Administrator #2
AddTimer lets you set intervals. See:

http://www.gammon.com.au/scripts/doc.php?function=AddTimer

Check out the flags.

In any case, you could just do it with a trigger on "you don't see Bob here" which tests a flag, and if that flag is set, redoes the timer.
#3
Thank you, once again! It never ceases to amaze me how many answers you're still able to provide!

In case anyone finds this thread, the script to use is this:

world.addtimer "name", 0, 0, 10, "what you're doing", 5, ""