Expanding Variables, Help?

Posted by BlackGuard on Sat 27 Nov 2010 12:47 PM — 3 posts, 17,789 views.

USA #0
I'm new to using Lua and was hoping for some help. I've read through various help files and I cannot seem to find anything that actually addressed what I need help with.

My question is, how do I expand variables inside of a note?

An example of what I mean is:

Quote:

------------------------------------------------
if (HP < 25) then
Note ("This @Target is too strong. Teleport to safety!")
end
------------------------------------------------
What currently appears with this code:

This @Target is too strong. Teleport to safety!

I want it to appear as:

This GOLEM is too strong. Teleport to safety!

Or whatever my current target is via the target variable.
USA #1
I figured it out with some help.

It's:

Note ("This "..Target.." is too strong. Teleport to safety!")
USA #2
When using Lua variables, keep in mind that they don't "expand" like MUSHclient wildcards and variables do. They're actual items/entities in the script that you operate on. That's why, if you have a Target variable, you don't just drop it into the string and hope it gets interpolated. :) You actually have to use the language's concatenation operator, which takes two strings and sticks them together.