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
➜ Jscript
➜ Trigger on Colour
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Drakonuz
(2 posts) Bio
|
| Date
| Mon 08 May 2006 06:25 PM (UTC) |
| Message
| I've been searching this forum for a few days & cannot find where it says how to set up a trigger (in script) that will match colour.
I can make the trigger from the 'triggers' menu, but I want to set the trigger using AddTrigger and the help files don't show the options I need.
Input is something like the following:
!# cR Mana:Icy Move:Tired>
Harlond's Stable ##(coloured green)
An elven youth is busy attending to the animals.
Exits: east.
... and I want to be able to store the room name. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,169 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Mon 08 May 2006 10:43 PM (UTC) |
| Message
| You will need to use ImportXML to get at these options. See:
http://www.gammon.com.au/scripts/doc.php?function=ImportXML
Make an example trigger in the GUI editor, to see the option names, and then use that as a template for the one you create in your scripting. If you were using Lua you could use the multi-line strings like this:
ImportXML [[
<triggers>
<trigger
back_colour="10"
enabled="y"
expand_variables="y"
match="foo"
match_back_colour="y"
match_text_colour="y"
send_to="1"
sequence="100"
text_colour="9"
>
<send>blah</send>
</trigger>
</triggers>
]]
In JScript, just build up your XML text in whatever way you feel comfortable, and then call ImportXML to get MUSHclient to create the trigger. This particular example matches "foo" in red text (9) on a green background (10). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Drakonuz
(2 posts) Bio
|
| Date
| Reply #2 on Thu 11 May 2006 10:11 PM (UTC) |
| Message
| I'm not very knowledgable in XML (and barely more at scripting). How would I embed this in my script file? For instance, if I have something like:
onPluginLoad
world.AddTrigger(doorOpened, * is opened *. | * opens the *., openReplace(%1,%2),eEnabled eIgnoreAliasCase eOmitFromLogFile eReplace eKeepEvaluating,"")
world.AddTrigger(doorClosed, * is closed *. | * opens the *., closeReplace(%1,%2), eEnabled eIgnoreAliasCase eOmitFromLogFile eReplace eKeepEvaluating,"")
world.AddTrigger(doorLocked, * locks the *. | * is locked *., lockedReplace(%1,%2), eEnabled eIgnoreAliasCase eOmitFromLogFile eReplace eKeepEvaluating,"")
world.AddTrigger(doorUnlocked, * unlocks the *. | * is unlocked *., unlockedReplace(%1,%2), eEnabled eIgnoreAliasCase eOmitFromLogFile eReplace eKeepEvaluating,"")
world.AddTrigger(doorPicked, You hear some clicking noises., pickedReplace(), eEnabled eIgnoreAliasCase eOmitFromLogFile eReplace eKeepEvaluating,"")
Would the XML just get pasted in here like:
ImportXML (
"<triggers>" +
"<trigger name="roomName" back_colour="10" text_colour="0" enabled="y" expand_variables="y" match="*" match_back_colour="y" match_text_colour="y" send_to="9" sequence="100" variable="rName">" +
"</trigger>" +
"</triggers>"
);
Or should I call it from somewhere?
Also, does the XML trigger language look correct? I assumed that using send_to=9 and varuable-rName would send the trigger value (the room name) to world variable "rName". Correct? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,169 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Thu 11 May 2006 10:32 PM (UTC) |
| Message
| Well, not quite because you have quotes within quotes, syntactically it is not correct JScript. This works:
ImportXML (
"<triggers>" +
" <trigger" +
" back_colour=\"10\"" +
" enabled=\"y\"" +
" expand_variables=\"y\"" +
" match=\"*\"" +
" match_back_colour=\"y\"" +
" match_text_colour=\"y\"" +
" name=\"roomName\"" +
" send_to=\"9\"" +
" sequence=\"100\"" +
" text_colour=\"8\"" +
" variable=\"rName\"" +
" >" +
" <send>%0</send>" +
" </trigger>" +
"</triggers>"
);
It looks more readable too because I have kept the line breaks.
Quote:
Also, does the XML trigger language look correct? I assumed that using send_to=9 and varuable-rName would send the trigger value (the room name) to world variable "rName". Correct?
For send to variable you need to specify *what* to send to the variable, so I have added %0 which is the entire matching text.
Anyway, I don't quite understand why you are doing this in onPluginLoad. You always want these triggers in a plugin, right? Why not just put the triggers in the plugin? Loading them each time from a script seems a roundabout way of doing it.
See the various plugins in the plugins section for examples. When you make a plugin with the plugin wizard any selected triggers (in your world file) are copied into the plugin, you don't need to add them with scripting. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | 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.
17,575 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top