[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Catching varibles within a trigger
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Catching varibles within a trigger

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


Posted by Stowslee   (7 posts)  [Biography] 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.
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] 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>

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.

Template:post=9626 Please see the forum thread: http://gammon.com.au/forum/?id=9626.

Template:post=9616 Please see the forum thread: http://gammon.com.au/forum/?id=9616.

[Go to top] top

Posted by Blainer   (191 posts)  [Biography] 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.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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. :)
[Go to top] 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.


4,375 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]