Changes between Initial Version and Version 1 of ExportingFromCommandLine


Ignore:
Timestamp:
Apr 15, 2018, 7:13:16 PM (7 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ExportingFromCommandLine

    v1 v1  
     1It is possible to export from the command line using !WorldPainter's scripting support.
     2
     3= Step 1 =
     4
     5Write the script which will export the world. !WorldPainter uses Java's built-in scripting support called JSR223. By default it supports !JavaScript, but you can install support for many other scripting languages. To find out if your favourite scripting language is supported, google "''language'' jsr223". You're on your own with getting it to work though! Google is your friend.
     6
     7This instruction will assume you'll be using !JavaScript. A script to load a .world file and export it to a Minecraft map might look something like:
     8
     9{{{
     10#!js
     11var filename = 'test.world';
     12var exportDir = '.';
     13
     14print('Loading world ' + filename);
     15var world = wp.loadWorld(filename);
     16
     17print('Exporting world');
     18wp.exportWorld(world, exportDir);
     19}}}
     20
     21Name it `exportworld.js` and place it in the directory where your .world files are. The extension is important, as it is how Java detects the scripting language used.
     22
     23This script will load a .world file named `test.world` from the current directory, and export it to a directory called `test` in the current directory.
     24
     25= Step 2 =
     26
     27Run the script from the directory where the .world file is:
     28
     29{{{
     30cd /dir/to/world/files
     31wpscript exportworld.js
     32}}}
     33
     34Of course you can adapt the script to include the full path to the .world file and/or specify a different export directory.
     35
     36= Notes =
     37
     38 * There is no way to change the export settings from the script yet, so you must store those in the .world file beforehand. You can do that by starting an export (with your desired settings) in !WorldPainter, cancelling the export and then saving the .world file.
     39 * To get !WorldPainter on the server, if you can't run an installer (because there is no graphical environment, for instance), you can use one of the installerless archives. The download links are in the text underneath the download links for the installers. Just extract it to a directory of your choice.