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 ➜ How to call a variable from a different world

How to call a variable from a different world

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


Posted by ReallyCurious   USA  (50 posts)  Bio
Date Mon 23 Apr 2007 01:47 PM (UTC)
Message
I set an alias to do the following:
holdoff *

%1 = assert (GetWorld ("%1"), "%1 not open")


assert (%1:IsConnected(), "%1 is not connected")


%1:Send("hold ", GetVariable("offhand"))

It's getting the variable from the world that I use to do the alias rather than, what I want, call the variable from the world I specify(%1 in this case).

I tried searching the forum for 'getvariable' and 'worlds' but most of the subjects found are pretty vague with what the poster's problem is: ('I need help', 'help with trigger', etc.)

Regardless, I'm going to sift through these threads now and look for an answer.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 23 Apr 2007 10:03 PM (UTC)
Message
You need to specify the other world for all function calls that refer to it, not just the Send. For example:


%1:Send("hold ", %1:GetVariable("offhand"))


Also I wouldn't personally use %1 as a variable name. Remember it substitutes the matching text for %1, so say the MUD name was "Ancient Anguish" then the line would read:


Ancient Anguish = assert (GetWorld ("Ancient Anguish"), "Ancient Anguish not open")


Now "Ancient Anguish" (on the left of the '=') is not a valid variable name, as it has a space in it.

So, I would code it like this:


otherworld = assert (GetWorld ("%1"), "%1 not open")

assert (otherworld:IsConnected(), "%1 is not connected")

otherworld:Send("hold ", otherworld:GetVariable("offhand"))


In this example "otherworld" is just a variable name, it doesn't matter what it is, the player won't see it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


12,183 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.