How to call a variable from a different world

Posted by ReallyCurious on Mon 23 Apr 2007 01:47 PM — 2 posts, 12,748 views.

USA #0
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.
Australia Forum Administrator #1
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.