[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]  Trigger Trouble
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Trigger Trouble

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


Posted by SteamKnight   USA  (17 posts)  [Biography] bio
Date Wed 18 Nov 2009 01:48 AM (UTC)
Message
Hey guys,
I've tried and tried to make this work, but it's not. This is supposed to be a remove/wear armour trigger set.

<triggers>
<trigger
enabled="y"
match="You are now wearing a suit of scale mail."
send_to="12"
sequence="99"
>
<send>SetVariable("armourbalance", "0")</send>
</trigger>
<trigger
enabled="y"
match="You gain equilibrium."
send_to="12"
sequence="99"
>
<send>if(GetVariable("armourbalance") == 1) then Send('wear '..GetVariable('armour')) end</send>
</trigger>
<trigger
enabled="y"
match="You have recovered balance on all limbs."
send_to="12"
sequence="99"
>
<send>if(GetVariable("armourbalance") == 1) then Send('wear '..GetVariable('armour')) end</send>
</trigger>
<trigger
enabled="y"
match="You remove a suit of scale mail."
send_to="12"
sequence="99"
>
<send>SetVariable("armourbalance", "1")</send>
</trigger>
</triggers>
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #1 on Wed 18 Nov 2009 01:51 AM (UTC)
Message
Template:codetag To make your code more readable please use [code] tags as described here.
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #2 on Wed 18 Nov 2009 01:55 AM (UTC)
Message
First thing I noticed was this.
GetVariable("armourbalance") == 1

MUSH variables return strings from GetVariable
GetVariable("armourbalance") == "1"

Now it is testing as a sting.

tostring() and tonumber() can be used to make stings into numbers or numbers into strings.
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 18 Nov 2009 01:58 AM (UTC)
Message
I was about to say that. :)

Anyway, it could be easier, for transient variables, to use Lua variables and not MUSHclient world variables.

eg. Instead of:


SetVariable("armourbalance", "0")


just do:


armourbalance = false


Then you can just test like this:


if armourbalance then 
  -- do something
end -- if


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Wed 18 Nov 2009 01:59 AM (UTC)
Message
But if you are going to stick to your current method, change:


if(GetVariable("armourbalance") == 1)


to:


if(GetVariable("armourbalance") == "1")


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Duraac   (3 posts)  [Biography] bio
Date Reply #5 on Sun 13 Dec 2009 07:16 AM (UTC)
Message
(If you're having trouble getting the variable back to 0 I have your solution)
Hey, I play the same game and I actually used your code as a stepping stone to help me learn how the LUA language works. I entered your code and added in their changes and still found a problem. The Variable would not set back to 0. Because I needed this exact same code, I worked on it, for hours.(eventually changing almost everything about the code -.-) Untill I eventually found the problem. The problem is not within the code, but rather within the way the line "You are now wearing scail mail." shows up on the screen. It shows up on the same line as the health and mana bar! Simply put an astrisk in fron of the trigger code. "match="You are now wearing a suit of scale mail.""
(sorry I'm new to the forums and don't yet understand how to make the quote boxes:)
[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,680 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]