Thread: Scripting
View Single Post
  #1  
Old 2010-09-20, 11:42
Brafil Brafil is offline
Magic Level: Red Ball
 
Join Date: Jun 2010
Posts: 161
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

Last edited by Brafil; 2010-09-20 at 18:51.
Reply With Quote