Proper format when sending a variable

Posted by EMP Fingers on Wed 13 May 2015 02:43 AM — 5 posts, 19,610 views.

#0
I've been setting up several triggers to practice engraving items with a tool but am unsure of how to call out the variable for them.

Upon matching it sends this to script:

Send ("engrave "..GetVariable("EngraveItem").." with tool")
Send ("test")

So if I'm engraving a hat all I need to do is set my EngraveItem variable to hat.

engrave hat with tool
(the game prompts me for what I wish to engrave)
test

What I don't understand is why I need the two periods before and after the GetVariable function. I don't see where in the function descriptions it calls out needing to use them in order for the function to work while I've been browsing. If someone could explain or point me in the right direction I'd appreciate it.
Australia Forum Administrator #1
Please post your exact trigger.

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.


You probably don't need scripting at all here.
Australia Forum Administrator #2
Quote:

What I don't understand is why I need the two periods before and after the GetVariable function.


The quick answer, though, is that the two dots is the Lua way of concatenating strings. So for example:


x = "foo" .. "bar"


Would put "foobar" into x.
#3
<triggers>
<trigger
enabled="y"
match="Oxytocin starts grinding an inscription into his * with an engraving tool."
send_to="12"
sequence="100"
>
<send>Send ("engrave "..GetVariable("EngraveItem").." with tool")
Send ("asfs")</send>
</trigger>
</triggers>

The only reason I use scripting is because this is one in a set of a couple triggers and timers I use to improve my crafting skill. This ques up another engrave command after the first one.

For this trigger specifically I could just call %1 with the same result but it's not always applicable for everything else, so rather than needing to change every instance of "hat" to "pants" when I finish my hats, I can just use the variable in everything and change the variable when I finish.

Thank you, Nick. I had been trying to figure that out for a while. Do you have any idea which forum page it's explained on off the top of your head? Just for later reference would be appreciated. If not thanks for explaining it to me!
Australia Forum Administrator #4
I don't think I document all the operators in the language (like + * / -). The .. operator is one such. However the online book Programming in Lua is very good.

Concatenation is mentioned here: 3.4 – Concatenation

The rest is worth reading (particularly the earlier parts) because he also describes how string constants work, comparisons, etc.