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
➜ General
➜ Shared variable values between different worlds
Shared variable values between different worlds
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Rdiniz
Brazil (21 posts) Bio
|
Date
| Thu 07 Jul 2016 03:13 AM (UTC) |
Message
| When I want to play multiple sessions on the same mud, I just copy the .MCL into another new one and open 2 different sessions. That is working great.
I want some variables to be world(file) specific, which isn't happening like now. Lets say I have a (global?) variable named currentGainedXp, which incresas on each kill. I want somehow that session1 have its specific currentGainedXp value and session2 also have its specific currentGainedXp value. When I run with only one opened world, everything works great.
What is happening is that GetVariable("currentGainedXp") is returning a valid value from a random opened world.
How can I achieve that?
Thank you. | Top |
|
Posted by
| Wuggly
USA (112 posts) Bio
|
Date
| Reply #1 on Fri 08 Jul 2016 08:11 PM (UTC) Amended on Fri 08 Jul 2016 08:12 PM (UTC) by Wuggly
|
Message
| Do the values of the variables need to be saved? Like if you close and re-open a world?
If not, then just don't use globals then they won't interfere with each other.
Otherwise, the quick solution would be to simply rename the global in the second world file. | Top |
|
Posted by
| Rdiniz
Brazil (21 posts) Bio
|
Date
| Reply #2 on Fri 08 Jul 2016 08:26 PM (UTC) |
Message
| The vars don't need to be saved. I'll try to delete them under the Scripting -> Variables section and declare local to give it a try. I thought local vars would work only inside a function... | Top |
|
Posted by
| Wuggly
USA (112 posts) Bio
|
Date
| Reply #3 on Fri 08 Jul 2016 08:53 PM (UTC) Amended on Fri 08 Jul 2016 09:05 PM (UTC) by Wuggly
|
Message
| Ah, I meant just don't use SetVariable and GetVariable.
They would still be globals, just within that world file unless you put local in front of it.
ie:
a = b is global
local a = b is local
Using SetVariable let's you use a variable between/across sessions from any plugin or world file using GetVariable to call it. So like the problem you're having is it's setting/updating the same variable from two sessions. So it's being added to twice. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Sat 09 Jul 2016 06:25 AM (UTC) |
Message
|
Quote:
What is happening is that GetVariable("currentGainedXp") is returning a valid value from a random opened world.
You can send data from one world to another by using the "world" functions. See: http://www.gammon.com.au/scripts/doc.php?general=world
However I'm not sure what you are trying to do. If you have multiple worlds open which is the "master" world? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rdiniz
Brazil (21 posts) Bio
|
Date
| Reply #5 on Sat 09 Jul 2016 12:48 PM (UTC) |
Message
| I want to have multiple alts playing in the same mud, at the same time. I'll be in one windows, which could me the 'main', and the others are playing by triggers. At some point, I want to check some variables from each alt, which in the case is each opened world, for example, how much xp each alt got.
I have all this info when playing one world only, but looks like I'm using global variables. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #6 on Sun 10 Jul 2016 06:27 AM (UTC) |
Message
| |
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.
20,995 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top