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
➜ General
➜ Persistent variable, two different triggers
Persistent variable, two different triggers
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Mavega
(4 posts) Bio
|
Date
| Tue 22 Jan 2013 07:32 AM (UTC) |
Message
| Hi Mr. Gammon, you seem like such an intelligent person and I would be forever grateful for your help with my latest problem.
Trigger #1 - "Text_AAAAAA"
(Set variable X to "1")
(Send variable like, "say Hello 'x'")
Trigger #2 - "Text_BBBBBB"
(Set variable X to 2X [so multiply it by 2 and store it]
(Send new X like, "say Hello 'x'")
So basically... if trigger "AAAAAA" occurs, we reset variable X and send it in a command to the server.
If trigger "BBBBBB" occurs, we multiply X by 2 and then send that to the server.
Can you please help me? I feel like I don't even know where to start because I don't need variable X to persist through each session - it only has to stay alive until Trigger "AAAAA" is called again. | Top |
|
Posted by
| Mavega
(4 posts) Bio
|
Date
| Reply #1 on Tue 22 Jan 2013 07:34 AM (UTC) |
Message
| Example test case:
Server says: "AAAAAA"
I say, "Hello 1"
Server says: "BBBBBB"
I say, "Hello 2"
Server says: "BBBBBB"
I say, "Hello 4"
Server says: "BBBBBB"
I say, "Hello 8"
Server says: "AAAAAA"
I say, "Hello 1"
Server says: "BBBBBB"
I say, "Hello 2"
etc etc etc | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #2 on Tue 22 Jan 2013 09:23 PM (UTC) |
Message
| Can you make a try, and show what you did?
|
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
|
Variables persist, this should be simple to do. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Mavega
(4 posts) Bio
|
Date
| Reply #3 on Wed 23 Jan 2013 07:06 AM (UTC) |
Message
| I have 2 different trigger codes...
<triggers>
<trigger
enabled="y"
match="AAAAAA"
send_to="12"
sequence="100"
>
<send>
x = tonumber (GetVariable ("x"))
x = x * 2
SetVariable ("x", x)
Send ("counter currently at ", x, " steps")</send>
</trigger>
</triggers>
<triggers>
<trigger
enabled="y"
match="BBBBBB"
send_to="12"
sequence="100"
>
<send>
SetVariable("x", "2")
Send ("counter reset to 2")</send>
</trigger>
</triggers>
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Wed 23 Jan 2013 08:16 PM (UTC) |
Message
| The examples you posted are the opposite of what you said (regarding AAAAAA and BBBBBB) but can be simplified:
<triggers>
<trigger
enabled="y"
match="AAAAAA"
send_to="12"
sequence="100"
>
<send>
x = (x or 1) * 2
Note ("counter currently at ", x, " steps")
</send>
</trigger>
<trigger
enabled="y"
match="BBBBBB"
send_to="12"
sequence="100"
>
<send>
x = 1
Note ("counter reset to 1")
</send>
</trigger>
</triggers>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Wed 23 Jan 2013 08:17 PM (UTC) |
Message
| The Lua variable "x" (you might want to give it a longer name) persists inside the script space for that session. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Mavega
(4 posts) Bio
|
Date
| Reply #6 on Fri 25 Jan 2013 01:23 PM (UTC) |
Message
| Yes you're right. I made a mistake and switched BBBBBB and AAAAAA in the code.
I'm going to try your fixes now, thanks. | 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.
16,999 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top