Incrementing a variable using the GUI

Posted by BishopOsiris on Wed 01 Jul 2015 01:15 AM — 22 posts, 84,693 views.

USA #0
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.
Australia Forum Administrator #1
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)
USA #2
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"
#3
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!
Australia Forum Administrator #4
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.
Australia Forum Administrator #5

There's even a video on that page:

USA #6
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?
Australia Forum Administrator #7
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.
USA #8
<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.
Amended on Wed 01 Jul 2015 10:37 PM by BishopOsiris
Australia Forum Administrator #9
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?
USA #10
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?
Australia Forum Administrator #11
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.
USA #12
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.
Australia Forum Administrator #13
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.
USA #14
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!
Amended on Tue 07 Jul 2015 01:36 PM by BishopOsiris
USA #15
Ok, so I think I've been doing this the hard way. All I really need is a timer set to send 'help helpNumber' to the MUD like every 3 seconds. That way I don't have to worry with all the different responses needing triggers. I tried to set up the timer myself using the same code you gave but I kept getting compile errors. Can you tell me how to proceed?
Australia Forum Administrator #16
Post the timer.

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.


Post the errors.
USA #17
I set the timer to go off every 3 seconds. I send to script. In the Send: box I put:


<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>


When I hit ok it immediately starts popping up compile error boxes every 3 seconds and the only way to stop it is to close down MUSHClient via Task Manager. I'm guessing I need some command to stop/start the timer in the MUD but I still don't think the code above is correct.
Australia Forum Administrator #18
Paste the whole thing, not just part of it.

Please ...

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.
USA #19
Sorry, Nick. Here's the whole thing:


<timers>
  <timer second="3.00" offset_second="0.00"    send_to="12"
>
  <send>&lt;send&gt;

-- 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)


&lt;/send&gt;</send>

  </timer>
</timers>
#20
You seem to have double "send" tags in your post, which may have something to do with your problem. I tried copy/pasting your code and that was the issue I had.

Another thing you can do to help debug is when an error popup is displayed, click the checkbox to have errors sent to your world window instead of the popup box. That way you wont get stuck in an infinite loop again where boxes are popping up faster than you can click them.

Here's the version of your timer that I got to work (all I did was get rid of the double send tags):


<timers>
  <timer second="3.00" offset_second="0.00"    send_to="12"
>
  <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>
  </timer>
</timers>
Amended on Fri 10 Jul 2015 05:06 PM by Xavious
USA #21
So this did exactly what I wanted it to. Thank you both for your patience and help!

Bishop