the Magicball Network Forums

the Magicball Network Forums (https://forum.magicball.net/index.php)
-   Little Script Adventure (https://forum.magicball.net/forumdisplay.php?f=60)
-   -   Scripting (https://forum.magicball.net/showthread.php?t=15571)

Brafil 2010-09-20 11:42

Scripting
 
Alright guys, we should maybe discuss scripting in this thread. So far the language is lua 5.x, embedded in the source.

IMPORTANT: Scripting may do nasty things. File I/O and module loading HAS to be disabled. This is actually easy to do, we won't supply those modules.

Data structures:
For safety, the script doesn't have access to the data structures used by the game. Instead, it knows the objects' IDs, which are fully opaque but enable the scripter to manipulate everything they need.

There are currently four manipulatable data structures:
- Conditions: Delay the execution of actions to a certain point in time
- Objects: Basic, script-driven models
- Characters: Standard characters

High-level data structures:
pos(x, y[, z]): Position at tile x, y, z. Equivalent to [ x = x, y = y, z = z ].
pos(object): Current position of object. *
area(x1, y1, x2, y2): All positions from x1, y1 to x2, y2. Equivalent to [ [ x1, y1 ], [ x2, y2 ] ].

* pos returns the position of the object at the time it's executed. All functions accepting pos also accept object IDs, which calculates the object's position every frame.

High-level functions:
char(filename, pos, rot): Load character with mesh filename at position. Returns a new ID.
object(filename, pos, rot): Loads a basic object, similar to char.
trigger(condition, function[, times])
: function to be called when condition is true (at most times times)

TBC


All times are GMT +2. The time now is 20:16.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright ©2000 - 2019, the Magicball Network