Difference between revisions of "Scripting"

From VisionaireWiki
Jump to navigation Jump to search
(New page: == General == Visionaire 3.0 comes with a Scripting language which is a combination of Lua (http://www.lua.org) and a Visionaire Object Model. The object model is used to access the Visio...)
 
Line 9: Line 9:
 
== Visionaire Object Model ==
 
== Visionaire Object Model ==
  
All objects can be accessed and manipulated through the scripting language. All objects of the same type (e.g. scene or button) are stored in one table. The properties of an object can be accessed by defined fields for the specific table. All objects and its fields are documented in [[Dokumentation_Datenstruktur_/_GameData_3.x|Visionaire Data Structure]].
+
All objects can be accessed and manipulated through the scripting language. All objects of the same type (e.g. scene or button) are stored in one table. The properties of an object can be accessed by defined fields for the specific table. All objects and its fields are documented in [[Data Structure 3.x|Visionaire Data Structure]].
  
 
The field types of the data structure are mapped to Lua types in the following way:
 
The field types of the data structure are mapped to Lua types in the following way:

Revision as of 10:31, 25 October 2008

General

Visionaire 3.0 comes with a Scripting language which is a combination of Lua (http://www.lua.org) and a Visionaire Object Model. The object model is used to access the Visionaire data structure in a convinient way. Almost every instance in Visionaire is represented as an object (e.g. scene, character, interface, ...) which can be manipulated through the scripting language.

Online documentation about scripting Language:

Visionaire Object Model

All objects can be accessed and manipulated through the scripting language. All objects of the same type (e.g. scene or button) are stored in one table. The properties of an object can be accessed by defined fields for the specific table. All objects and its fields are documented in Visionaire Data Structure.

The field types of the data structure are mapped to Lua types in the following way:

Field Type

Lua Type

t_link

userdata (VisionaireObject) or string which describes the object path. See object access for description of the object path.

t_links

table (array) with Visionaire Objects (userdata or string, see t_link above) elements, each entry referencing one Visionaire Object.

t_int

number (integer)

t_float

number

t_bool

number (boolean)

t_point

table (with elements "x" and "y")

t_rect

table (with elements "x", "y", "width" and "height")

t_string

string

t_path

string

t_sprite

table (with element "path" and optional elements "x", "y", "cutting" (t_rect) and "transparent" (t_point))

t_vint

table with number (integer) elements

t_vfloat

table with number (float) elements

t_vpoint

table with t_point elements

t_vrect

table with t_rect elements

t_vstring

table with string elements

t_vpath

table with t_path elements

t_vsprite

table with t_sprite elements


Now follows a list of all objects and its methods and all exported functions.

Objects

VisionaireObject

Functions

getObject

Returns a VisionaireObject (userdata) which matches the given path.

Parameter

Lua Type

Description

Parameter #1

string

Path which describes the object storage. See object access for description of the path.

Return value

userdata (VisionaireObject)

VisionaireObject or nil if object was not found.

Example:

daniel = getObject("Characters[Daniel]")

Accessing an object

Whenever an object path is needed you can specify it the following way:
1. start with a Table (as is shown in the table column of the Visionaire Data Structure).
2. if this table is not "Game" (this table has only one object) then you have to write the name of the object inside bracktes ('[' and ']').
3. either goto 7. or continue with 4.
4. write a dot '.' and then a fieldname of this object (the field type must either be t_link or t_links).
5. if the field type is t_links then goto 2., else goto 6.
6. either goto 7. or goto 4. (access another link)
7. done. A valid object is specified.

Examples:

Game.CharacterLinks[Tom]
Scene[Room].SceneObjects[start].SceneConditions[game started?]
Character[Tom].CharacterInterfaces[Tom-MI3]

Alternatively, you can also access an object by its table-id and object-id. It can be specified by a tuple:
(table-id,object-id)

Example:

(0,6)

Selects the object with id 6 from table 0 (characters).

Commands

Commands for Visionaire Player only

Commands for Visionaire Editor only