Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Creating a timer

Creating a timer

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nyell   (8 posts)  Bio
Date Tue 12 Aug 2014 05:18 PM (UTC)
Message
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!
Top

Posted by Nyell   (8 posts)  Bio
Date Reply #1 on Tue 12 Aug 2014 05:22 PM (UTC)
Message
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.
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #2 on Tue 12 Aug 2014 05:28 PM (UTC)

Amended on Tue 12 Aug 2014 05:40 PM (UTC) by Fiendish

Message
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.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 12 Aug 2014 07:50 PM (UTC)

Amended on Tue 12 Aug 2014 07:51 PM (UTC) by Nick Gammon

Message
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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nyell   (8 posts)  Bio
Date Reply #4 on Wed 13 Aug 2014 08:22 PM (UTC)
Message
Thanks a lot for your quick responses!!

Removing the space worked.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


21,418 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.