[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]  General
. . -> [Subject]  How would I match these things to set variables?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

How would I match these things to set variables?

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


Posted by Rivius   (95 posts)  [Biography] 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?
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] top

Posted by Rivius   (95 posts)  [Biography] 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?
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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:


if nsent==true then


... is just wordy.

Make it:


if nsent then


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


3,887 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]