News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

MOSE - MakeObj Script Environment

Started by Michael 'Cruzer', June 06, 2009, 03:16:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Michael 'Cruzer'

What is MOSE?
MOSE is a Scripting Language for Pak-Set Administrator, which have to build very much PAK files with one click. Mostly for this you also could use a batch file (or under linux an sh file), but the problem of batch or sh files is, that they aren't platform intependent. If you work with someone in a team, but he uses another platform (like Linux) you have to created 2 scripts files and if you want to change something you always have to do this twice! Here you could MOSE, because it's platform independent and dynamic.

What do I need for MOSE?
You only need Python 2.6 or newer (recommended: Python 3.0). So you can run MOSE on nearly every platform!

How to install?
LINUX/UNIX: Extract this zip (http://moscript.sf.net/) to "/usr/bin/" and put makeobj in the same directory.
It also would in every other directory, but I would recomend to extract it to "/usr/bin" for using SheBang in the scripts.

WINDOWS: Extract this zip (http://moscript.sf.net/) to any directory and put makeobj in the same directory.
Since version 0.4.0 there also exist an Installer for Windows! It's recomended to use this installer instead of this manual methode!

How to use?
If you use Linux type /usr/bin/mose.py into the shell. Then the interactive MOSE Shell starts. If you want to run a script you can type /usr/bin/mose.py example.mos into the shell and the script 'example.mos' will start.
If you use Windows klick on the file "mose.py" in the Windows Explorer for starting the interactive MOSE Shell. For running a script, you have to type mose.py example.mos in the cmd for running the script 'example.mos'

If you are in the interactive MOSE Shell you also could run a script by using the run command like this run example.mos

In the interactive MOSE Shell you can use every command which you can use in the script file!

How to write a MOS-Script:
MOScripts has the extension ".mos" (MakeObj Script). MOScript are like a Batch file. Every line is one command. The first word of every line is the command and all other words are the arguments. For example: build ./ ./ 'build' is the command and './ ./' are the arguments. For getting help to a command type '?' and the command. For example: ?build
For getting a list of all commands type help

Here is a small example for a moscript:
#!/usr/bin/mose.py
!size=128
build ./ ./


Description of what the script do:
Line 1: #/usr/bin/mose.py is a SheBang. This is some Linux special and it's only optional. Everybody who writes shell script will know what it means and for every other it isn't important.
Line 2: !size=128 defines that every thing should be build for the pak-size 128. Writting config paksize=128 would be the same effect. Choose this way to write which you like more.
Line 3: build ./ ./ This command pak all *.dat files in the directory to *.pak files. It has the same effect as you will write 'makeobj PAK ./ ./' in the windows-console/linux-shell.

List of most important commands:
[argument] means that this argument is optional.

build [output input1 [input2 [input3]]]
This command pak all *.dat files in the directory input1, input2, ... into *.pak files in the directory output.

config paksize=64 or !size=64
Defines for which pak-sizes they have to packed.

copy source destination
Copy one file (=source) to the destination directory (=destination)

xcopy source destination
Copy a directory or a file with using patterns.
Ex.: xcopy ./config/*.tab ./build/config/

chdir directory
Change the working directoy in a new working directory. (Like the shell command: cd / chdir)

echo text
Writes the text onto the screen.


There are many other commands, for getting a full list of them type 'help' in the interactive MOSE Shell.

Are there any example scripts?
Here is a script for building pak64:#!/usr/bin/mose.py

mkdir ./build/
mkdir ./build/config/
xcopy ./config/*.tab ./build/config
mkdir ./build/sound/
xcopy ./sound/*.wav ./build/sound
mkdir ./build/text/
xcopy ./text/*.tab ./build/text

!size=64
build ./build/ ./city_extra/
build ./build/ ./com/
build ./build/ ./cur/
build ./build/ ./factory/
#build ./build/ ./factory_alcohol/
#build ./build/ ./factory_computer/
#build ./build/ ./factory_food/
#build ./build/ ./factory_waste/
build ./build/ ./ground/
#build ./build/ ./ground/oldgrounds/
build ./build/ ./ind/
build ./build/ ./monument/
build ./build/ ./other/
build ./build/ ./player/
build ./build/ ./res/
build ./build/ ./trees/
build ./build/ ./vehicle/road/
build ./build/ ./vehicle/track/
build ./build/ ./vehicle/water/
build ./build/ ./vehicle/air/
build ./build/ ./vehicle/monorail/
build ./build/ ./vehicle/trams/
build ./build/ ./way/

!size=128
build ./build/ ./big-logo/
Founder and Ex-Maintainer of pak192.comic. Provider of Simutrans Hosting rental service.

Ashley

Very useful looking toolkit, and always nice to see things written in Python :)
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

Michael 'Cruzer'

A new versionis aviable (0.4.0): http://sourceforge.net/projects/moscript

Now there is also an Installer (Windows only) which helps you to install MOSE and also register the file extension *.mos to Explorer!


The most important new commands and sys-variables:

  • New command if: Example:
if a==a then echo True


  • New sys-varriable errors: Shows the number of errors. At end of script this value will be return to host if there isn't any other value called by exit command!


  • New sys-variable any_errors: When an error occured this variable will be set to '1'


  • New sys-variable mose_dir: This variable shows the absolute path to directory of the mose.py file.


  • New sys-variable zip: If zip is not '1' all following zip commands will be ignored. This variable could be also changed with commandline parametet -z or --zip!

Founder and Ex-Maintainer of pak192.comic. Provider of Simutrans Hosting rental service.

The Hood

I have a question.  Pak128.Britain now has some objects (ships, and in the future planes) which are larger than 128x128 size and included in the graphics with an offset to make them fit the centre of a 128x128 tile.  Is there any way MOSE can handle switching between different pak sizes in a script, to enable me to create a single script to build all objects?

jonasbb

Yes there is a way. You can switch the paksize in the script with !size=192.

The Hood

I couldn't get that to work, but then I realised my mistake - I'd typed the folder path to the dat files in wrong in the script.  Oops!

Michael 'Cruzer'

!size=192
# This objects will use 192*192px
build ./output/ ./obj192/
!size=128
# This objects will use 128*128px again
build ./output/ ./obj128/

Founder and Ex-Maintainer of pak192.comic. Provider of Simutrans Hosting rental service.