Triggers affecting Variables (Mushclient)

by Unknown

Back to Combat Guide.

Unknown2007-02-11 13:12:03




Now this is a pretty stupid question maybe, but I've been babied and spoiled with how dumbed down Zmud makes a lot of things for years, until recently I lost all access to my Zmud registration as my code was among the ones long before Zuggsoft switched to their new registration type and I have no way of recovering it or converting it to one of the new registrations as of result of being inable to recover it in the first place. (Thanks to my significant other for completely wiping my computer with all such information stored on it.)



So.. until a time that I can afford to buy Zmud once more, or should I find a liking to it decide to register Mushclient when I can afford too, I'm using the latter.


Basically, I'm attempting to create my own system that essentially uses the same logical steps that you'd use to make a basic zmud curing system. Through the use of variables to track and contain the different afflictions, balances, states etc, and allowing triggers to affect those states and then creating a queue of sorts to allow the actions to be given through aliases.

I'm sure that's likely completely the wrong way to go with doing it for Mushclient.. maybe..


But anyways I'm not very far into it and attempting to find the best way to affect my variables directly through triggers; e.g.'

Hmmmm. Why must everything be so difficult to figure out?
/world.SetVariable "affliction_stupidity" "1"


Anyone that's used mushclient extensively knows what I'm trying to do there. But that and various other attempts at doing that for the same result don't seem to be working. Like changing the trigger to be sent to variables and then the affliction_stupidity variable with the number 1 so that it'll simply react to the line and speak directly with variables to set it to 1.


Either way, I'm sure I can -figure- out a way to do it with some effort, though my minds a bit fried at the moment.

I'm just asking for what's essentially the best way to do so from someone that's more experienced.


And though I've pretty computer literate and inclined to learn more about these things with time and effort, I currently have little to know VBscript knowledge. Something made painfully obvious when I attempted to look at Ethelon's old curing system he offers for free in attempt to find a way to do what I'm attempting, only it appears he has all triggers for such things being sent to his subroutine script where it there handles the changing of variables and other things. tongue.gif
Ethelon2007-02-11 15:02:43
When making a trigger to alter a Variable you use SEND TO: SCRIPT

In your stupidity example, the send box will look like this:

setvariable "affliction_stupidity", "1"


For a Queued curing you really should use Sub Routines and have it accessed like it is in the free system.

The /world that you used earlier is mainly used when sending to script from the Command line, which you shouldn't be doing.

If you do not want to make Sub Routines, you can still set your triggers to alter variables like above, and then have your prompt call a queued trigger to cure based off variables. I think this would be an example, I'm at work, so sorry if I mess this up in my haste: (There are better ways to write this with arrays and such, but this seems easiest for what you are requesting)

CODE
If getvariable("herbbalance") = 0 Then
If getvariable("affliction_stupidity") = 1 Then
send "outr pennyroyal"
send "eat pennyroyal"
setvariable "herbbalance", "1"
Elseif getvariable("affliction_slickness") = 1 Then
send "outr calamus"
send "eat calamus"
setvariable "herbbalance", "1"
Elseif getvariable("affliction_reckless") = 1 Then
send "outr horehound"
send "eat horehound"
setvariable "herbbalance", "1"
end if
end if


That is the simple way of doing a que based off prompt trigger. Make sure to set the "You mayeat anotehr herb blah blahblah" line as a trigger to switch the herbbalance trigger to 0, this allows you not to waste herbs.

Hope that helps some. If you want something more detailed or written better, PM me with your questions.

Also, this should be in the Mechanics Corner
Unknown2007-02-11 15:24:01
QUOTE(Aedeche @ Feb 11 2007, 02:12 PM) 382269
Through the use of variables to track and contain the different afflictions, balances, states etc, and allowing triggers to affect those states and then creating a queue of sorts to allow the actions to be given through aliases.

I'm sure that's likely completely the wrong way to go with doing it for Mushclient.. maybe..

That's completely the wrong way to go with doing it for MUSHclient. whistling.gif Well, not quite, but you really don't need to muck around with executing aliases. You should rather have your queues as subs in your subroutine file, sending commands directly without using aliases. Your triggers should set variables and call subs from the subroutine. Ethelon's system is a very good example of this.

For instance, a trigger for an herb cured affliction will do something like "call herbcall ("reckless", "horehound")". In the subroutine, there's a sub herbcall which takes two arguments (herb, affliction). When called with two arguments, it sets the "affliction_reckless" variable to 1, checks if you have herb balance and aren't anorexic and stuff like that, then attempts to cure it. If you don't have herb balance, it only sets the variable to 1. The trigger for regaining herb balance does "call herbhealing (a, b, c)". (Ignore the a, b, c. They're just in there to avoid a syntax error, but they don't mean anything.) Sub herbhealing is your herb curing queue and will run through all the herb afflictions in priority order until it finds one to cure. You'll notice that it does everything with "send "outr horehound""-style statements, not by calling aliases.

Once you get used to this, it's a much cleaner, more logical way of scripting. The documentation's convoluted, so it's easiest to learn by dissecting scripts and asking others.

QUOTE(Aedeche @ Feb 11 2007, 02:12 PM) 382269
Hmmmm. Why must everything be so difficult to figure out?
/world.SetVariable "affliction_stupidity" "1"

The / only works from the command line. (It's a nice way of sending script commands on the fly.) For triggers, don't use a backslash, but make sure the trigger's set to Send To: Script. When the trigger Sends To: World, all the stuff in the trigger's edit box gets sent directly to Lusternia. When it Sends To: Execute, it checks for aliases first and interprets those, then sends everything directly to Lusternia. When it Sends To: Script, it treats everything in the edit box as a script command. (Don't bother with Send To: Variable. Just use script commands for that.) Some examples:

setvariable "affliction_stupidity", 1
if getvariable ("focusbalance") = 0 then
send "focus mind"
end if
note "*** YOU'RE STUPID, STUPID! ***"
colournote "limegreen", "cornflowerblue", "This is an echo in really mismatched colours"
world.execute "mystupidityalias"

Those are all the commands you'll need to start with. Eventually, you'll want to learn to use DoAfter and DoAfterSpecial (temporary timers), enabletrigger and enabletriggergroup (enable/disable triggers) and maybe to set timers, but that's it.

I'd also recommend getting used to writing all your triggers as regular expressions, particularly ones that start with a new line. That cuts down on the number of trigger evaluations, reduces your vulnerability to illusions somewhat, and will be really useful once you discover that debating and warrior afflictions generally require multiline triggers where the line break can show up anywhere. I wrote a comprehensive post about using regexes somewhere in the Mechanic's Corner.
Theomar2007-02-12 01:16:16
For a down and dirty method of affecting a variable through a trigger, put the line in the "Trigger" box, in the Send box put what the value of the variable shall be, and in the "Send to" drop-down box, select "variable." You'll have to go to the bottom of the trigger create menu and find the box labelled "Variable." It goes from being greyed out to white when you select "Send to Variable." Fill in the variable's name, and presto.

Basically, use this as an example:
CODE

     enabled="y"
   match="Hmmmm. Why must everything be so difficult to figure out?"
   send_to="9"
   sequence="100"
   variable="test"
  >
  yes
  

Copy that entire block of code, go to the Triggers menu (Shift+Ctrl+8) and select Paste. It'll paste the trigger in, and you'll be able to see what I mean.

That uses less processing power. The downside is you can only have the trigger change one variable, unless you have multiple triggers of the same line to change multiple variables in a recurring process (this eats a lot of processing though).

Also, I actually recommend using Lua as the programming language as it's integrated with MUSHclient. It makes it faster. I also find it easier to read than the other languages.

I can help if you do choose to go down Lua path. (Also, with Lua you don't have to supply the world. call to each function, but you need to use proper capitalization)

Everything else has been covered pretty well by the replies before mine.

Actually, I think I'll give you an example of Lua's differences (I'm using Vale Kant's* previous post example):
CODE
SetVariable ("affliction_stupidity", "1")
if (GetVariable("focusbalance") == "0") then
Send ("focus mind")
end
Note ("*** YOU'RE STUPID, STUPID! ***")
ColourNote ("limegreen", "cornflowerblue", "This is an echo in really mismatched colours")
Execute ("mystupidityalias")


Although, I use tables to track temporary things (such as afflictions on me, and balances) and MUSHclient variables for static things (pipe numbers, enchant numbers). I can explain those later in a PM if you so desire.

*Apparently I kant spell.
Unknown2007-02-12 20:21:13
Ditch VBS and use Lua! Lua is the new default scripting language in MUSHclient, and it's marginally faster and more powerful than VBS. It's also more cross-platform compatible (i.e., if you ever wanted to run MUSHclient under WINE on Linux).

Or...

Send an e-mail to support@zuggsoft.com with the details you used to purchase your license (name, address, etc), and they'll help you recover your license key.