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
➜ Trigger Trouble
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| SteamKnight
USA (17 posts) 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>
| Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #1 on Wed 18 Nov 2009 01:51 AM (UTC) |
Message
|
 |
To make your code more readable please use [code] tags as described here.
|
| Top |
|
Posted by
| Blainer
(191 posts) 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) 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:
Then you can just test like this:
if armourbalance then
-- do something
end -- if
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) 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 | Top |
|
Posted by
| Duraac
(3 posts) 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:) | 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.
20,667 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top