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
➜ How would I match these things to set variables?
How would I match these things to set variables?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Rivius
(99 posts) Bio
|
Date
| Wed 29 Sep 2010 11:39 PM (UTC) Amended on Wed 29 Sep 2010 11:54 PM (UTC) by Rivius
|
Message
| My prompt looks like this (the whole line):
3670h, 2460m, 2820e, 10p, 15882en, 10600w elrx-
But I'm most concerned with the final part of it that says
elrx-
Now this part shows me various balances and stats. For example e tells me about me equilibrium, l tells me if my left arm is on balance and r tells me if my right arm is on balance.
Also, that last part can have more things at the end of it, depending on things I do, like eating a "kafe bean" might turn this into
elrxk-
Now to the question. I want to keep track of when the e,l,r and x parts are gone. Any of them can be gone individually at any time. When it does I want to set a variable to 0. And then I want to set it to 1 when it comes back.
[to illustrate what I mean, let's say I equilibrium is gone, it would be lrx- until it comes back and then it is elrx again.]
How would I go about doing this? | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #1 on Wed 29 Sep 2010 11:43 PM (UTC) |
Message
| I am a bit short on time, and rather not spend the time chewing your entire problem out when a few weeks ago, I tackled the same problem for someone with a similar issue.
Have a look at this thread: http://www.gammon.com.au/forum/?id=10619&page=999
Alternatively, look around for the word 'prompt' on these forums. This issue comes past so often that it really is only a matter of applying the answers to fit your specific situation. | Top |
|
Posted by
| Rivius
(99 posts) Bio
|
Date
| Reply #2 on Thu 30 Sep 2010 01:44 AM (UTC) Amended on Thu 30 Sep 2010 04:03 AM (UTC) by Rivius
|
Message
| Alright! Thanks for that. I used that knowledge and then found out I actually had a nice trigger already set up in my system that allows me to take advantage of that.
EDIT (with the below post's suggestions)
http://pastebin.com/PbwNZZNu
You can consider this problem solved, but do you think this can be simplified any? | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #3 on Thu 30 Sep 2010 03:07 AM (UTC) |
Message
| Not really without knowing the bigger context and such.
The only 'simplification' I can offer is to use booleans rather than integers for your flags. E.g. offbalance = true or nsent = false, and likewise checking for those values.
Truth and false (on/off, yes/no, etc) are ment for this kind of thing, and it makes your code easier to read. Likewise, because an if-statement is basically checking for the 'truth' in an expression, you can simply say if nsent then. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #4 on Thu 30 Sep 2010 04:23 AM (UTC) |
Message
|
Rivius said:
You can consider this problem solved, but do you think this can be simplified any?
Well here:
if (string.find("%7", "e")) and
(string.find("%7", "l")) and
(string.find("%7", "x")) and
(string.find("%7", "r"))
then
offbalanc = false -- If all these match, you're not off balance.
Does the server randomize the order of the letters? If not, why not just test:
if "%7" == "elxr" then
offbalanc = false
And Worstje is right:
... is just wordy.
Make it:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
18,930 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top