Script Format

There are only three commands for the scripting "language", I use quotes because this is not exactly a scripting language, for there are no conditionals or such.

** Comments **

Any line starting with a # is ignored from any further parsing, allowing you to add comments or explanation as to what or why or how the script works.

** The DO command **

This executes the text following via bukkit's internal console command sending. This means that the commands have the same permissions and power as the console.

do say hello, world!

** The DOASYNC command **

This executes the text following via bukkit's internal console command sending. This means that the commands have the same permissions and power as the console. However the script carries on without waiting for the command to complete. This is usefull if you want to do a pile of worldedit commands or some such automatically but not caring about how long they took so long as they complete.

doAsync say hello, world!

** The Exec command **

This executes an external program using java's runtime.getruntime().exec() meaning that **programs executed from SCC have the same level of control over the computer as the user running the craftbukkit server! ** With that out of the way, this command is useful to fire off programs that can run in the background. common uses can be map renders (eg using Minecraft Overviewer), or anything else that can run without further interference from the server.

Note that the Current Working Directory is where the server's base directory is (normally where the craftbukkit.jar is), if this does not make sense, using the full path to the program works as well.

exec /path/to/Minecraft-overviewer.py --config=render.config

or on windows:

exec C:\path\to\Minecraft-overviewer.exe --config=render.config

Note that we don't support environment variables inside the cronScript, this is due to multi-platform headaches (windows env != linux env != mac osx env...), if a better method of subprocess management is known drop a comment or submit a ticket on github so that we can take a look!

** The Sleep command**

This command allows your scripts to delay a small amount before continuing execution. The argument is a number of milliseconds to sleep for. Example sleeping for 1.5 seconds:

do say hello
sleep 1500
do say world

** The ExecWait command**

This executes an external program in the same way that the exec command does, except it waits for it to finish, buffering the program output to be used later in the SCC script via the symbols $?. for example:

execwait uname -a
do say this server is running on $?

This is perhaps the most useful part of SimpleCronClone because this makes running anything synchronous with the server easy, for example backups:

do say backup in progress...
do save-all
do save-off
execwait /path/to/backup_program.sh
do save-on
do save-all
do say backup complete

** The WAITFORASYNC command **

The script parser when it hits exec or doAsync puts those tasks into some lists, and with this command you are able to say "I don't care what order those commands were done in, so long as they get done after this line, so wait for them here".

do say running long async tasks...
doAsync really_slow_command
doAsync eg_worlediting_large_areas_or_some_such
exec sh/background_processing.sh
waitForAsync
do say long async tasks complete.

** Arguments **

With the addition of the EventEngine, now scripts called from the EventEngine get some special arguments. For what those arguments are for what event, see here. An example to help explain:

In plugins/SimpleCronClone/tab.sce:

playerJoin    events/playerJoin.sce

and in plugins/SimpleCronClone/events/playerJoin.sce:

do say event $0 with the player argument of: $1

$0 is always the event name itself (for event scripts, scripts called from the CronEngine do not use arguments), the other arguments are based on what the event itself was (see that link above for list of events, and their arguments)

Edit for v1.1: now it is also possible to pass arguments to .scc files, these are in the order received starting with $0 as the first argument.


A collection of examples can be found in the github repo