Is there any way I can make a new, blank world and then mess with it via scripting, i.e. send commands, etc?
Making new worlds via scripting
Posted by Poromenos on Wed 24 Sep 2003 02:44 PM — 11 posts, 23,704 views.
In a way other than using DoCommand, I mean... I find it a bit sloppy and I'd like to refrain from using it as much as possible...
Nick? Any ideas? :P
One way would be to have a "blank" world file, and in a script open it, and then find its world name, and use it to modify most (if not all) of its configuration parameters.
Alternatively, make a script that writes out a world file (as text) using the appropriate XML format. The XML format is pretty standard, and you can find the various configuration parameters easily enough.
Alternatively, make a script that writes out a world file (as text) using the appropriate XML format. The XML format is pretty standard, and you can find the various configuration parameters easily enough.
How about a "OpenNewWorld" command or something in the next version? Storing all the xml or distributing the world with the plugin is pretty tedious, and not easily customisable, while i think that function would be easy to write...
Doing a CreateObject of the MUSHclient world type might work. :)
Oh, it works! Oh but it asks the user for defaults etc... Could I just make a "quick connect" world, specifying IP, port and name? Even if not, a CreateWorld function would be nice for completeness, and I don't think it would be very hard to implement?
I think a minimal world file, written out as text in XML might be pretty small, as most of it could just take the defaults, which is what you would get anyway if you did a "createworld".
For example, use a handful of lines of scripting to create a file with this in it:
Then use Open to open that file, that gives you a COM object which is the new world, then use normal script routines to make adjustments to it.
For example, use a handful of lines of scripting to create a file with this in it:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<muclient>
<world defaults="y"
name="My New World Name"
site="my.world.address"
port="4000"
/>
</muclient>
Then use Open to open that file, that gives you a COM object which is the new world, then use normal script routines to make adjustments to it.
Still, it would have to be saved, maybe deleted afterwards, and that could be a problem... Is there a way to import it, or to somehow do an import without saving the file?
And why is a CreateWorld function so much trouble? :P
And why is a CreateWorld function so much trouble? :P
I am trying to find a method that will work for you today.
If you are planning to save the world, just call it the file name of the eventual world file. If not, use GetUniqueID to generate a unique file name, write that, and then delete it afterwards. You could delete it immediately after opening it.
If you are planning to save the world, just call it the file name of the eventual world file. If not, use GetUniqueID to generate a unique file name, write that, and then delete it afterwards. You could delete it immediately after opening it.
Ah hmm, ok, that works for me as long as i can delete it immediately... I can work with that temporarily until a better solution is available, the XML should do the trick.