Trigger Trouble

Posted by SteamKnight on Wed 18 Nov 2009 01:48 AM — 6 posts, 27,441 views.

USA #0
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>
#1
Template:codetag
To make your code more readable please use [code] tags as described here.
#2
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.
Australia Forum Administrator #3
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

Australia Forum Administrator #4
But if you are going to stick to your current method, change:


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


to:


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

#5
(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:)