Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Expanding Variables, Help?

Expanding Variables, Help?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by BlackGuard   USA  (12 posts)  Bio
Date Sat 27 Nov 2010 12:47 PM (UTC)
Message
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.
Top

Posted by BlackGuard   USA  (12 posts)  Bio
Date Reply #1 on Sat 27 Nov 2010 03:29 PM (UTC)
Message
I figured it out with some help.

It's:

Note ("This "..Target.." is too strong. Teleport to safety!")
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #2 on Sat 27 Nov 2010 07:50 PM (UTC)
Message
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.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,339 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.