[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  How to call a variable from a different world
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

How to call a variable from a different world

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

Posted by ReallyCurious   USA  (50 posts)  [Biography] bio
Date Mon 23 Apr 2007 01:47 PM (UTC)
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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,669 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 23 Apr 2007 10:03 PM (UTC)
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
[Go to top] 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.


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

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]