XMREngine Script Engine

From Dreamnation
Jump to: navigation, search

XMRE supports several extensions to the LSL to make it easier to write scripts.

   XMREngine.advflowctl - provide traditional break/continue/switch/case statements
   XMREngine.arrays - provide an associative mutable datatype
   XMREngine.chars - provide the character datatype
   XMREngine.include - read source from another location
   XMREngine.inline events - handle event processing inline instead of using event handlers
   XMREngine.norighttoleft - enables an optimization
   XMREngine.objects - provide mechanism to create script-definable class types, including generics and fixed-dimension arrays
   XMREngine.sorpra - mechanism to move scripted objects across sim border
   XMREngine.trycatch - provide mechanism to catch exceptions

   XMREngine.builtins - miscellaneous built-in functions not mentioned in the above sections
   XMREngine.scriptdb - persistent storage available to scripts

   XMREngine.sample - sample scripts using XMREngine features


1) The keywords that are part of the extensions will not be recognized until the corresponding xmroption statement has been given, so the new keywords don't interfere with existing scripts.

2) The parts of the xmroption statement are case-insensitive.

Test Program

There is a script test program available. It will compile your script then run it directly on your computer. For any ll...() functions, it prints out the function name and arguments passed to stdout. If the ll...() function returns a value, it reads the return value from stdin. When an event handler completes, it reads the next event name and its arguments from stdin. You can then examine the printed values to see if it is doing what you expect for the inputs given. You can put the inputs in a file and pass it to your script and make sure the output is correct, comparing it to known good data.

Download http://www.dreamnation.net/kunta/scripts/xmrengtest.zip to get it and unzip. Run it like this:

   mono xmrengtest.exe <scriptfile>

It will compile the script and call the default state_entry handler. It will exit when the default state_entry handler completes. To have it process more events after that, include the -eventio option:

   mono xmrengtest.exe -eventio <scriptfile>

...and it will read the name and arguments of subsequent events from stdin, one event per line in the format:

   event_name ( arguments ... )

such as

   http_response ("firstone", 3, [0,<1,2,3>,"456"], "body")

You must be sure to get the argument types correct or an error will result.

The -builtins option lists the functions and built-in constants that the compiler recognizes:

   mono xmrengtest.exe -builtins