Creating a timer

Posted by Nyell on Tue 12 Aug 2014 05:18 PM — 5 posts, 21,873 views.

#0
Hey all. I'm trying to get back into MUD's because its a chance to refine some programming skills.

I'm trying to get a trigger to create a timer, but am running into some difficulty. I understand that there might be better ways to do what i'm doing, but please bear with me. My goal at the moment is just trying to get a trigger to create a timer that I can see in the timers menu, edit, and use as i please. At the moment, the trigger is set up as follows

<triggers>
<trigger
enabled="y"
group="Beetle"
match="* Happy hunting!"
send_to="12"
sequence="100"
>
<send>AddTimer("BeetleTimer", 0, 0, 1,"Say Good", 1 , " ")</send>
</trigger>
</triggers>


The "say good" is just a placeholder until i get the timer creation to work. Any help woudl be appreciated. Thanks in advance!
#1
To clarify, when the case is matched and the code executes, no timer is created. Nothing shows up in the timers list, and when i test with IsTimer, it returns the code for does not exist.
USA Global Moderator #2
Try deleting that space in the script name. You want "" not " ".

The current implementation of AddTimer returns an early error if you specify a non-zero-length function name that does not exist. It does not trim off extra whitespace.

https://github.com/nickgammon/mushclient/blob/f12ef5b21df751aabe15cbbdc01021b30e32bff8/scripting/methods/methods_timers.cpp#L180-L186

Checking the return value of AddTimer should show this.
Amended on Tue 12 Aug 2014 05:40 PM by Fiendish
Australia Forum Administrator #3
You may find using addxml easier to add timers:

http://www.gammon.com.au/forum/?id=7123

Also you may want to use the "active when closed" flag if you are expecting this timer to fire if the world is not connected.

Try "checking" the AddTimer result:


check (AddTimer("BeetleTimer", 0, 0, 1,"Say Good", 1 , ""))


That will raise an error if the sort of thing Fiendish mentioned happens.

See:

http://www.gammon.com.au/scripts/doc.php?general=lua
Amended on Tue 12 Aug 2014 07:51 PM by Nick Gammon
#4
Thanks a lot for your quick responses!!

Removing the space worked.