Quote:
... do GetWorldIdList() and GetWorldList() always return a list of world in the same order (assuming that there are no changed to the worlds list between the execution of the 2 functions)?
Yes, the return the worlds found in the internal world list, the same list that is used to general world numbers (world 1, world 2 etc.).
Quote:
And are world IDs static such that I can hardcode World IDs into my scripts?
Just to clarify, GetWorldIdList was added because there is no restriction on world names, you can have 10 worlds all called "untitled". However MUSHclient refuses to open two (or more) worlds which have the same ID string.
So, using GetWorldIdList is safer than GetWorldList.
Inside the world file, if you open it with a text editor, you will see something like this:
<muclient>
<world
muclient_version="3.85"
world_file_version="15"
date_saved="2007-04-11 16:48:24"
auto_say_override_prefix="-"
auto_say_string="say "
chat_name="Name-not-set"
command_stack_character=";"
id="f0b5158d0dc7909191f86c7e"
input_font_name="FixedSys"
The bold line is the world ID. If you simply copy and paste a world file you will get two with the same ID. You need to Edit menu -> Generate Unique ID to get a new one.
Once a world has a fixed ID you don't need to use GetWorldIdList at all, simply specify the unique ID in GetWorldById.
Quote:
What if I want to run a script (in W2) instead of "rescue sev" (e.g., a script that can also be called by an alias in W2: rescue_sev(name, line, wildcards))?
I'm not sure I understand the question here. If you are "in" W2, then you don't need to get its own world ID.
Quote:
I'm wondering if there is a less-dodgy way to do this.
Your approach seems OK, apart from maybe the test for "r" in the middle - is that necessary?
To make it safer, get the world ID instead of the name:
set w2 = GetWorldById ("8524c85ef23a9c1bc5e53924")
Your ID will be different of course. To find it you can type:
/Note GetWorldID
I have been experimenting with being able to call the function directly (and not use world.Execute) but it seems that this won't work because world 1 doesn't know about extra scripts recently added to world 2.
A slightly safer method would be to use an alias in world 2, not a script call. You would still use Execute, but make up an alias which does what you want. The technique of using a script call (like: /rescue_sev nil, nil, nil) relies upon the correct script prefix ("/") being set up, and the function call arguments begin setup correctly.
In other words, something like this:
w2.Execute "My_Rescue_Alias"
If you need to pass down something (like who to rescue) it could be an argument the alias, eg.
w2.Execute "My_Rescue_Alias " & line
|