Register forum user name Search FAQ

Gammon Forum

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 ➜ Keeping track of focus balance

Keeping track of focus balance

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


Posted by Rivius   (99 posts)  Bio
Date Sun 12 Sep 2010 03:03 AM (UTC)

Amended on Sun 12 Sep 2010 03:06 AM (UTC) by Rivius

Message
In one of the games I play there is a case where you might become paralyzed and need to send the command to the game

FOCUS BODY

Now when you're paralyzed, this is the trigger line.


^You are paralysed and


and I have it set to Send("FOCUS BODY") to the world.


For example lets say I get paralyzed mid-swing and then I attempt to swing again it would say

"You are paralysed and cannot do that".

and the trigger would fire and send "FOCUS BODY".
Focus body takes some time to eventually cure my paralysis.

Now if I inadvertently hit swing again while still focusing body, it will once again trigger off the command FOCUS BODY. This is undesirable because it uses up excess mana and takes longer.


Now, I don't know very much about variables and scripting, but I'm sure it isn't too difficult.

I want something like a variable called "paralyzed" to be initially set to 0 when I start the game. Then when a paralysis message comes up, I want it to set paralysis to 1 and prevent "focus body" from firing again.

this second trigger:

^Your muscles unlock\; you are no longer paralysed\.$

Should set paralyzed to 0, and allow for someone to once again fire off focus body.


In this way, I can be as efficient as possible with my mana. During combat with multiple people in a room, it gets too spammy and I can't always keep track of these things and before I notice I might do an extra swing or two.


Anyway, can you please instruct me on how to go about doing this? I figure this would assist in the coding of similar aspects.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 12 Sep 2010 03:23 AM (UTC)

Amended on Sun 12 Sep 2010 03:24 AM (UTC) by Nick Gammon

Message
Something like this would do it:


<triggers>
  <trigger
   enabled="y"
   match="You are paralysed and *"
   send_to="12"
   sequence="110"
  >
  <send>

if not paralyzed then
  Send ("FOCUS BODY") 
  paralyzed = true
end -- if

</send>
  </trigger>

  <trigger
   enabled="y"
   match="Your muscles unlock; you are no longer paralysed."
   send_to="12"
   sequence="110"
  >
  <send>

paralyzed = false

</send>
  </trigger>

</triggers>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


This sets a Lua variable 'paralyzed' (which is assumed to be false when you open the world).

Then when you get the message about being paralysed you only send the message if the variable isn't set already.

I didn't use regular expressions there, your triggers are so simple it is easier to read without using regexps.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rivius   (99 posts)  Bio
Date Reply #2 on Sun 12 Sep 2010 03:47 AM (UTC)
Message
Excellent! Now I don't seem to be wasting mana. I'll test this a little more to see if there's any hiccups, but it looks like that's it. Also, the script seems very simple. So thanks for that!
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.


14,113 views.

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

Go to topic:           Search the forum


[Go to top] top

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