Register forum user name Search FAQ

Gammon Forum

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 ➜ Incrementing a variable using the GUI

Incrementing a variable using the GUI

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


Pages: 1 2  

Posted by BishopOsiris   USA  (55 posts)  Bio
Date Wed 01 Jul 2015 01:15 AM (UTC)
Message
I simply wish to increment a variable based on an output from my MUD. I did a forum search and everything I found involved complicated scripting solutions. I'm looking for a simple GUI solution. There has to be a way to set up a trigger to change the value of a variable. I've created the variable: helpNumber. I've created the trigger: Unable to find what you're looking for. Which sends to the MUD: help @helpNumber. Every time the trigger triggers I want to increment the variable by 1. How can I do this?

I have expand variables checked.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 01 Jul 2015 03:37 AM (UTC)
Message
There is no command-line interface for doing arithmetic (unlike some other clients). However it is really easy using scripting. For your case:


<triggers>
  <trigger
   enabled="y"
   match="blah blah"
   send_to="12"
   sequence="100"
  >
  <send>

-- if variable does not exist, create it
if not GetVariable ('helpNumber') then
   SetVariable ('helpNumber', 0)
end -- if

-- get help
Send ("help " .. GetVariable ('helpNumber'))

-- add one to help number
SetVariable ('helpNumber', tonumber (GetVariable ('helpNumber')) + 1)


</send>
  </trigger>
</triggers>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


The arithmetic is done in this line:


-- add one to help number
SetVariable ('helpNumber', tonumber (GetVariable ('helpNumber')) + 1)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by BishopOsiris   USA  (55 posts)  Bio
Date Reply #2 on Wed 01 Jul 2015 11:54 AM (UTC)
Message
So I have a few questions since I know nothing about scripting:

Do I just enter this in the command box where I enter regular commands for the MUD?

What if I need to edit the trigger/variable later? Can I do that from the GUI?

Is this LUA?

What do these two items do:
send_to="12"
sequence="100"
Top

Posted by Xavious   (41 posts)  Bio
Date Reply #3 on Wed 01 Jul 2015 05:06 PM (UTC)
Message
What Nick pasted is actually the XML output for a trigger configuration. It can be a little confusing if you don't have any experience with this sort of thing. This is the format that triggers are actually saved in. Let's ignore that for now.

Bishoposiris said:

Do I just enter this in the command box where I enter regular commands for the MUD?

The "send" portion of this trigger is what goes in the "send" box for your trigger, which either sends commands to the mud or processes scripts depending on the "send to" option you pick in the dropdown box.

Bishoposiris said:

What if I need to edit the trigger/variable later? Can I do that from the GUI?

Yes, absolutely. You can click the trigger icon or push "shift+ctrl+8" to bring up your trigger interface. You can either click already entered triggers, or click add to add a new one. Once you click add, you will see the "send" box and the "send to" dropdown I mentioned earlier.

Bishoposiris said:

Is this LUA?

Yes, Lua is the default scripting language for MUSHclient and has the most power and flexibility. Mostly what you see here are function calls to save, retrieve, and modify a variable. There is a comprehensive list of built in MUSHclient functions you can view on this website. Alternatively you can search for a function by name to find the documentation.

Bishoposiris said:

What do these two items do:
send_to="12"
sequence="100"

"Send to" is just a numbered reference for the "send to" dropdown box on the add trigger interface. In this case the 12 means "script." (script is the 12th option in the dropdown).

If you want to just add what Nick posted you can copy the tags from triggers to /trigger, go to MUSHclient and push "shift+ctrl+8", then click the "paste" button at the bottom. You should then change the trigger text from "blah blah" to whatever text you need this trigger to fire on.

Hope this helps!
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 01 Jul 2015 08:31 PM (UTC)
Message
Bishoposiris said:

Do I just enter this in the command box where I enter regular commands for the MUD?


I provided a link, please follow it.

Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

- 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 01 Jul 2015 08:32 PM (UTC)
Message

There's even a video on that page:


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by BishopOsiris   USA  (55 posts)  Bio
Date Reply #6 on Wed 01 Jul 2015 09:16 PM (UTC)
Message
Sorry Nick, I missed your link about pasting XML. That was an oversight on my part. I did exactly as you said but the trigger still isn't working. I've tried inputting:

help @helpNumber
help helpNumber

which should echo to the screen:

help 1

but is simply echoes exactly what I've typed. And even though I get the same response:

Unable to find what you were looking for

nothing is triggered. I've tried checking and unchecking Expand Variables but nothing changes.

What am I doing wrong?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 01 Jul 2015 09:25 PM (UTC)
Message
You've changed it, right? Because it worked for me. Please paste here your altered trigger. Read the link:

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by BishopOsiris   USA  (55 posts)  Bio
Date Reply #8 on Wed 01 Jul 2015 10:35 PM (UTC)

Amended on Wed 01 Jul 2015 10:37 PM (UTC) by BishopOsiris

Message
<triggers>
<trigger
enabled="y"
match="Unable to find what you were looking for"
send_to="12"
sequence="100"
>
<send>-- if variable does not exist, create it
if not GetVariable ('helpNumber') then
SetVariable ('helpNumber', 0)
end -- if

-- get help
Send ("help " .. GetVariable ('helpNumber'))

-- add one to help number
SetVariable ('helpNumber', tonumber (GetVariable ('helpNumber')) + 1)


</send>
</trigger>
</triggers>

The only thing I changed was the "match=" statement.

Here is the output from my MUD:

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 10 PM>
help @helpNumber
Unable to find what you were looking for. Make sure to check your spelling.

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 11 PM>
help helpNumber
Unable to find what you were looking for. Make sure to check your spelling.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #9 on Thu 02 Jul 2015 04:05 AM (UTC)
Message
You have told the trigger to look for:


Unable to find what you were looking for


But you are actually receiving:


Unable to find what you were looking for. Make sure to check your spelling.


The trigger "match" text has to be exactly what you receive. Or make it a regexp (check the regular expression box) and then it can be somewhere on that line.

And where does "help @helpNumber" come from?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by BishopOsiris   USA  (55 posts)  Bio
Date Reply #10 on Thu 02 Jul 2015 11:38 AM (UTC)
Message
Ah, ok. That makes more sense. You'll have to forgive me. I'm coming from the CMUD environment so I'm carrying some bad habits from there. That, and it's been 5 years since I've done anything MUD related so I'm still a bit rusty.

So I should just type:

help 1

to get the trigger started? How would I enter the command using the actual variable?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #11 on Thu 02 Jul 2015 08:34 PM (UTC)
Message
We have a terminology problem here. You don't type anything to start a trigger. A trigger matches incoming data from the MUD.

You type something to start an alias. That matches what you type.

Although your first post said:

Quote:

I simply wish to increment a variable based on an output from my MUD.


So why do you ask:

Quote:

So I should just type:


help 1


to get the trigger started?


Unless you mean, you type "help 1" to get the first help page, and then the trigger matches on the second one? If you made the sequence a bit clearer I might be able to help you more.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by BishopOsiris   USA  (55 posts)  Bio
Date Reply #12 on Mon 06 Jul 2015 12:25 AM (UTC)
Message
Ok, so what I'm trying to do is make a log of every help file on my MUD. But I don't want to sit there and type 'help 1', 'help 2', 'help 3', etc. manually because there's almost 3000 help files. I don't think there are help files for 1 - 19 so I think the first help file is 'help 20'. So right now if I type 'help 1' this is the output I get:


civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 7 PM> 
help 1
Unable to find what you were looking for.  Make sure to check your spelling.

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 7 PM> 


So I need a variable that represents the help file number (in this case '1') and a trigger that will trigger on the output


Unable to find what you were looking for.  Make sure to check your spelling.


increment my variable by one, and send to the MUD 'help 2'. This will continue to trigger until it gets to the first help file


civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 9 AM> 
help 20
EMPIRE IMPERIALS 'IMPERIAL LAW' ECHELONS EMPEROR RECRUITER 'ARCANE SECT'
In ages past, a mighty Empire existed, bent on civilizing all of Thera by
force.  Consisting of four sects, the Blades, the Divine, the Black, and
the Shadow, its citizens spread across the lands like locusts, attempting
to bring all under their dominion.  Betrayed by the Arcane Sect, and the
dread Lich Valguarnera, the Empire fell into ruins, until all that was left
was an empty palace, and the decaying Imperial lands, a distant memory of a
dream unrealized.

Time passed, and a rumbling was heard throughout Thera.  Once again, the
call went out for new citizens to create an Empire.  Their goals remain the
same... all of Thera will be brought under Imperial control, to promote
order and civilization.  Wary of past alliances that brought about its
previous ruination, the Empire has banished the Arcane Sect forever.  Four
sects remain the heart of the Empire, however.

The Blade Sect consists of warriors and bards.
The Black Sect consists of anti-paladins and necromancers.
The Divine Sect consists of shamans and healers.
The Shadow Sect consists of assassins and thieves.

Admittance to the Empire is available only to those with dark hearts,
orderly ethos and begins with the bloodoath, which can be administered by
any citizen.  Druids and rangers cannot join the Empire due to their
affinity with nature.

There are seven echelons of status in the Empire, from the lowliest,
bloodoath, to the highest, Emperor.  Those of a higher echelon have the
power to promote, or demote those below them, based on their worth as
citizens.  Every citizen within the Empire has pledged their heart, their
soul and their life to the Empire and are bound to follow Imperial Law.

See also: 'DIVINE SECT', 'BLACK SECT', 'SHADOW SECT', 'BLADE SECT',
'PROMOTION', 'DEMOTION'

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 10 AM> 


Note that this help file just returns me to my prompt so there's no specified output to trigger. For this I would need some kind of timer to increment my variable by one and send to the MUD 'help 21'. Some help files are larger than one page


civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 3 PM> 
help 2345
ARCHERY BOW BOWS
Syntax: automatic skill

The vast majority of adventurers and heroes find archery much too 
impractical
for a life of head-to-head combat, and leave bows and arrows in the hands
of archers that can shoot their weapons from the safety of battlements.

Two exceptions to this rule, however, are the hunter and the raider.

The hunter is a specialized ranger who has adapted the skill of archery to 
be
suitable for a life of adventure. Perpetually trying to keep distance in
confrontation requires a hunter's endurance and cunning, and typically with 
the
time required to load and aim, only a single shot can be fired in a round of
combat. 

As Goblins are socialized into a world in which speed and keeping enemies at 
a
distance are essential to survival, their raiders likewise train to keep
confrontation on their own terms--and archery provides them the distance
necessary to avoid enemies that would otherwise crush them.

Ranged attacks do, however, afford opportunities unique in the art
of war, but only a true hunter or skilled raider possesses an arsenal of 
skills
capable of making the bow viable enough to withstand the chaos of a direct 
fray.
Arrows fired from bows are impossible to parry.  The training of a hunter 
allows
them to use their bow even in the water.

The archery skill allows the hunter and raider to wield their bows, which
requires two hands.
[Hit Return to continue]


See also: HUNTER, RAIDER.
civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 4 PM> 


See near the bottom where it says


[Hit Return to continue]


I need a trigger to send return to the MUD which should be easy enough to do via the GUI. And then the timer will kick in and continue the process.

I hope this makes clearer what I'm trying to do.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #13 on Mon 06 Jul 2015 08:46 PM (UTC)
Message
I don't quite know where the confusion is. Make a trigger to match that line, like this (slightly modified from my earlier example):


<triggers>
  <trigger
   enabled="y"
   match="Unable to find what you were looking for.  Make sure to check your spelling."
   send_to="12"
   sequence="100"
  >
  <send>

-- if variable does not exist, create it
if not GetVariable ('helpNumber') then
   SetVariable ('helpNumber', 0)
end -- if

-- get help
Send ("help " .. GetVariable ('helpNumber'))

-- add one to help number
SetVariable ('helpNumber', tonumber (GetVariable ('helpNumber')) + 1)


</send>
  </trigger>
</triggers>



Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Use the GUI to set the variable helpNumber to the starting number (eg. 1) and then type "help 1". That would trigger the message, the trigger sends "help 2" and so on.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by BishopOsiris   USA  (55 posts)  Bio
Date Reply #14 on Tue 07 Jul 2015 01:05 PM (UTC)

Amended on Tue 07 Jul 2015 01:36 PM (UTC) by BishopOsiris

Message
Looks like we're getting closer. I put in your script and this is now my output:


civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 11 PM> 
help 1
Unable to find what you were looking for.  Make sure to check your spelling.
help 1

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 8 AM> Unable to find what you were looking for.  Make sure to check your spelling.

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 8 AM> 

Autosaving.

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 9 AM> 
help 1
Unable to find what you were looking for.  Make sure to check your spelling.
help 2

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 9 AM> Unable to find what you were looking for.  Make sure to check your spelling.

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 9 AM> 
help 1
Unable to find what you were looking for.  Make sure to check your spelling.
help 3

civilized <100%hp 100%m 100%mv 1900tnl (50.00%) 11 AM> BALATOR
The Village of Balator

Balator is located to the north of the city of Hamsah Mu'tazz.  A small 
village, at least compared to the great cities of Thera, it is still a center 
of commerce and home to many retired adventurers.  You might even recognize 
some famous people from Thera's past.  While Balator is suggested for levels 
10-40, some of the legends may require more training than this to defeat, 
and all characters will want to exercise caution and common sense.

See also "Help BALATOR2".


I put in 'help 1' at each prompt and the script is incrementing 1 each time but it isn't triggering on the output on the second time. Is it because the second output is showing up on the same line as my prompt?

Edit: Ok, I just looked back over this thread because I remembered you saying something about exact matches and regexp. I went back into my trigger and checked regular expression and it seems to working as intented now! Now I just need to make a timer to trigger the 'help helpNumber' when I actually get a help file returned instead of the 'Unable to find what you were looking for. Make sure to check your spelling.' output. I'll do some research on timers. If I need some help I'll let you know. Thanks for getting me this far!
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.


58,536 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

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

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.