Is there a similar function to AddTriggerEx, that allows me to specify where the output for my alias is sent to? AddAlias automatically sends to the world window, however I need to have it store to a variable, and then send a message to output. Something like this, although the syntax is horrible, I think it conveys my intent.
AddAlias("set_attack_alias", "^setattack (.*) , (.*)$", (attack_alias = %1)(attack_type = %2) "You have set your alias to" %1 , "And you have set your attack type to" %2, alias_flag.Enabled + alias_flag.RegularExpression + alias_flag.IgnoreAliasCase, "")
I could use SetAliasOption, however I would then have to write a function that checks for the alias, and then if it exists, modify it, which seems like entirely too much code, when the flag for triggers exists.
Your essentially right, I'll just throw them into a function.
My next question is how do I set the variables? Can I do a SetAliasOption() and change send to variable? Whats they syntax for that?
Remember that in the GUI, Send To and Variable are separate text boxes. As for the text to add to the variable, you put that in ResponseText for AddAlias, which is basically the same as the Send box.
If you are using Lua, you may find the addxml.lua module does exactly what you want. Effectively you can use ImportXML (as Twisol said) to add things, exactly the same way the client does when it reads in your world file, and thus all options are available. However the addxml module simplifies using that.
Okay, we are making progress, I used the addxml to create the triggers instead of AddTriggerEx(), I do prefer the method, its easier to read, as well as work with. The only problem I'm having now is of lexical scope. In the send line of the trigger, which is sending to a variable(MushClient var), and I'm trying to increment the variable by one, and store it into the variable.
This only sets the variable to one. It seems as if I'm storing the result into a diffrent variable than the variable I created with SetVariable.
SetVariable("beetle_in_room", 0)
addxml.trigger { match = "^(A carrion beetle enters, scavenging for flesh.|The faint clicking of insect legs on stone alerts you to the entrance of a carrion beetle.|A carrion beetle scuttles in, searching for food.)$",
name = "beetle_enter",
enabled = true,
regexp = true,
send_to = 9,
variable = "beetle_in_room",
send = (GetVariable("beetle_in_room") + 1),
sequence = 50,
}
I tried changing the send line to the following, but it actually returns zero...
SetVariable("beetle_in_room", 0)
addxml.trigger { match = "^(A carrion beetle enters, scavenging for flesh.|The faint clicking of insect legs on stone alerts you to the entrance of a carrion beetle.|A carrion beetle scuttles in, searching for food.)$",
name = "beetle_enter",
enabled = true,
regexp = true,
send_to = 12,
send = [[SetVariable(GetVariable("beetle_in_room") + 1)]],
sequence = 50,
}
The double-brackets around the send text is actually just another form of quoting, like "" and ''. The send text is supposed to be text, after all - it's evaluated and executed once the trigger is fired. And the send_to is 12, which means Script.