CMUD -> MUSHclient: Multistate Triggers

Posted by Anna Henderson on Wed 02 Jun 2010 12:16 AM — 3 posts, 14,961 views.

#0
I've been playing Lusternia for the past three months, and have been using CMUD. I'm switching to MUSHclient because 1.) Lusternia's best curing system uses MUSHclient, and 2.) MUSHclient seems to be the better client overall, if less user-friendly at first.

I've begun to learn Lua and am making good progress, though I've never programmed before. I've also been reading up on MUSHclient itself, and have learned most of the basics and even some advanced concepts. Even so, this is all completely new to me.

However, I wish to make the transition from CMUD to MUSH as soon as possible, and only one major obstacle stands in my way: CMUD's multistate triggers. I depend heavily on them, and I don't know how to do the same thing in MUSHclient.

For example, in Lusterna, there's a type of attack that requires me to alternate between three different abilities for maximum effectiveness, like so:

You have recovered equilibrium.
>SEND INFLUENCE @TARGET WITH COMPLIMENTS

You have recovered equilibrium.
>SEND INFLUENCE @TARGET WITH PRAISE

You have recovered equilibrium.
>SEND INFLUENCE @TARGET WITH ADMIRATION

(start back at the beginning)


I use CMUD's class function to toggle the multistate trigger that does this on and off as I need it. Here is the actual XML from CMUD:

trigger priority="1450" id="145">
  <pattern>recovered equilibrium</pattern>
  <value>influence @inf with compliments</value>
  <trigger>
    <pattern>recovered equilibrium</pattern>
    <value>influence @inf with admiration</value>
  </trigger>
  <trigger>
    <pattern>recovered equilibrium</pattern>
    <value>influence @inf with praise</value>
  </trigger>
</trigger>


I plan to work hard learning Lua and mastering MUSHclient, and if I can get this one detail whipped into shape, I'll have a clean slate to start off on.

Thanks, and hope this post wasn't too long/I missed an obvious and easy solution/etc.
Australia Forum Administrator #1
There are a few ways you could do that. One is to have a trigger that switches what to send, like this:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="You have recovered equilibrium."
   send_to="12"
   sequence="100"
  >
  <send>

  equilibrium_state = equilibrium_state or 1  -- start at 1 initially

  what_to_send = {
    "influence @inf with compliments",
    "influence @inf with admiration",
    "influence @inf with praise",
    } -- end table
 
  -- pull out current message
  Send (what_to_send [equilibrium_state])

  -- move onto next one
  equilibrium_state = equilibrium_state + 1

  -- wrap if necessary
  if equilibrium_state &gt; #what_to_send then
    equilibrium_state = 1
  end -- if past end

</send>
  </trigger>
</triggers>




Another approach, which is less complex, but uses more triggers, is to have each one disable itself, and enable the next one in sequence.


<triggers>

  <trigger
   enabled="y"
   expand_variables="y"
   match="You have recovered equilibrium."
   name="eq_trigger_1"
   send_to="12"
   sequence="100"
  >
  <send>

Send "influence @inf with compliments"

EnableTrigger ("eq_trigger_1", false)  -- disable ourself
EnableTrigger ("eq_trigger_2", true)  -- enable next one

</send>
  </trigger>

  <trigger
   expand_variables="y"
   match="You have recovered equilibrium."
   name="eq_trigger_2"
   send_to="12"
   sequence="100"
  >
  <send>

Send "influence @inf with admiration"

EnableTrigger ("eq_trigger_2", false)  -- disable ourself
EnableTrigger ("eq_trigger_3", true)  -- enable next one

</send>
  </trigger>

  <trigger
   expand_variables="y"
   match="You have recovered equilibrium."
   name="eq_trigger_3"
   send_to="12"
   sequence="100"
  >
  <send>

Send "influence @inf with praise"

EnableTrigger ("eq_trigger_3", false)  -- disable ourself
EnableTrigger ("eq_trigger_1", true)  -- enable next one

</send>
  </trigger>

</triggers>


This method would get messy with lots of messages, but is a bit simpler to understand. (Notice only one of the three triggers is initially enabled).
#2
Wonderful! Those two techniques fit the bill nicely, and the second in particular is one any beginner should be able to understand. I have several other uses for "sequential loop triggers" (which seems like a good generic term for these), so I'll definitely learn to script them from scratch, rather than simply copy-pasting your work.

Thanks muchly, from the x="n";y="th";print(x..y) person to say: "Wow, Nick, you responded promptly and your solution worked perfectly!"