Sharing Variables

Posted by Rhinoa on Mon 31 Dec 2001 03:44 AM — 3 posts, 14,364 views.

United Kingdom #0
Is there a way of sharing variables between 2 characters? (Both operated by the same player)
Australia Forum Administrator #1
You mean both on your copy of MUSHclient but in different worlds? Yes, that is easy. :)

You need to get an "object reference" to the other world, and then use it to get or set variables. Here is a code snippet to illustrate the idea ...


dim otherworld
dim hp

set otherworld = world.getworld ("world2")

if otherworld is nothing then
world.note "World world2 is not open"
exit sub
end if

hp = otherworld.getvariable ("hp")



In this example "world2" is the second character, the "getworld" line gets a reference to it into the "otherworld" variable. Then you can use "otherworld.getvariable" to get the variable contents.

Of course, you can then use anything else (eg. setvariable, note etc.) on the other world.


otherworld.note "Hi there"
Amended on Wed 02 Jan 2002 09:53 PM by Nick Gammon
United Kingdom #2
Thanx...

Worked perfectly...

~Rhinoa~