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
➜ General
➜ Trigger on expressions (when a variable changes)
Trigger on expressions (when a variable changes)
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Seriley
(42 posts) Bio
|
Date
| Sun 11 Jul 2010 11:02 PM (UTC) |
Message
| I've recently switched to MUSHClient from CMUD.
There was a useful trigger category in CMUD that would fire whenever a change was detected in one or more variables in an expression placed in the pattern field.
Is there a way to duplicate this feature in MUSHClient? What if the variable pointed to a table and a table entry changed?
Thanks | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 11 Jul 2010 11:47 PM (UTC) Amended on Sun 11 Jul 2010 11:50 PM (UTC) by Nick Gammon
|
Message
| There is no feature to track changes to MUSHclient variables (although you can track MXP variable changes).
Variables are set quite often, and to track every change might be expensive.
However in Lua it is possible to do that (track Lua variable changes) by using the __newindex metamethod, attached to a table. (Even global variables are in a table, however it is probably better to set up a particular table for this purpose).
This is described here:
http://www.lua.org/pil/13.4.4.html
Effectively you set up an empty "proxy" table, so that every attempt to write to it (change its contents) creates a new entry, which __newindex detects. The change is then written to a shadow table. You also use __index to retrieve existing values.
I'm assuming this answers your question, I wouldn't call this a trigger in the normal sense.
You can however use triggers (things that match incoming text from the MUD) and put variables in them, so you can match (for example) one of a long list of player names. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Seriley
(42 posts) Bio
|
Date
| Reply #2 on Mon 12 Jul 2010 12:43 AM (UTC) |
Message
| Thank you for your prompt response, Nick.
I will check into the lua proxy table approach. There is one table I'm using that I would like to shadow possibly. | 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.
11,092 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top