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
➜ Catching varibles within a trigger
Catching varibles within a trigger
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Stowslee
(7 posts) Bio
|
Date
| Tue 27 Oct 2009 02:23 AM (UTC) |
Message
| I am having an issue catching this trigger and saving its values to a set of variables. I just switched to MUSH from ZMud and have no idea how to get started, hoping working with this trigger in particular will give me insight to some of the coding.
H:105% [4552/4309] M:102% [2388/2325] B:100% [26300/26300] Exp:36% [] [eb]H:105% [4552/4309] M:102% [2388/2325] B:100% [26300/26300] Exp:36% [] [eb]
It comes up as the prompt (not sure if that matters)
Thanks in advance for any assistance you can provide. | Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #1 on Tue 27 Oct 2009 02:55 AM (UTC) Amended on Tue 27 Oct 2009 02:58 AM (UTC) by Blainer
|
Message
| MUSHclient saves variables on the world file. This is handy as they are available from all other triggers, aliases and timers once you select Expand Variable when you make the trigger, alias or timer.
This trigger matches "Health: 50\100" 100 is the total health and 50 the current health. It then puts the second wildcard (total health) into the Variable "total_health". "Send To:" is set to "Send To Variable"
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="health: *\*"
send_to="9"
sequence="100"
variable="total_health"
>
<send>%2</send>
</trigger>
</triggers>
This alias uses the Variable set by the above trigger.
<aliases>
<alias
match="test"
enabled="y"
expand_variables="y"
send_to="2"
sequence="100"
>
<send>Total Health @total_health</send>
</alias>
</aliases>
This trigger runs some Lua code using the wildcards in the trigger to print out total and current health.
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="health: *\*"
send_to="12"
sequence="100"
variable="total_health"
>
<send>
total_health = "%2"
current_health = "%1"
Note("Current: "..current_health)
Note("Total: "..total_health)</send>
</trigger>
</triggers>
 |
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
|
| Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #2 on Tue 27 Oct 2009 03:08 AM (UTC) Amended on Tue 27 Oct 2009 03:11 AM (UTC) by Blainer
|
Message
| This trigger catches the line above (I made a few assumptions in the match) and calls the function "print_wildcards" in the script file passing the name, line and a table of wildcards.
<triggers>
<trigger
enabled="y"
match="H:*% [*/*] M:*% [*/*] B:*% [*/*] Exp:*% [] [eb]H:*% [*/*] M:*% [*/*] B:*% [*/*] Exp:*% [] [*]"
script="print_wildcards"
send_to="12"
sequence="100"
>
</trigger>
</triggers>
The function in the script file looks like this.
function print_wildcards (name, line, wildcards)
for i,v in ipairs(wildcards) do
Note(v)
end
end
I didn't test this but it should give you the idea. | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #3 on Tue 27 Oct 2009 03:49 AM (UTC) |
Message
| .. Oh, there's two topics. See my reply in the other topic, too. :) | 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.
18,539 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top