API-Namen, Parameter und Code stehen in ihrer englischen Originalform.

Einführung

Welcome to the reference documentation for Visionaire. This is a documentation for programmers discussing lua features and keeping track of advanced functions. If you're not to savy on programming you can still use the finished scripts.

Grundlagen

Lua Basics

If you're a beginner to programming lua might be one of the easier languages to start with, although most of the basics are the same as in other languages.

https://www.lua.org/start.html
https://www.tutorialspoint.com/lua/index.htm
http://www.phailed.me/2011/02/learn-lua-the-hard-way-1/
http://luatut.com/crash_course.html

If you know programming languages and just want some syntax, look here:

http://tylerneylon.com/a/learn-lua/

Point of Execution

Lua code can be executed in the action part call script / execute script or with a definition script. Scripts that are marked as definition script will run when the engine starts, others can be called with call script action part.

  • Action part
  • Event handler
  • Tween/SetDelay
  • Mainloop

Objektzugriff

game.CurrentCharacter -- gets a field of the game object
Fonts[1] -- gets the first object in the Fonts table
Fonts.__len -- gets the size of the table
Fonts.Name -- access by name, alpha numeric names and the letter _ are allowed, but the first letter must be a letter.
Fonts["0-name"] -- alternate access for complicated names

Fonts[1].Size -- access a field value
Fonts[1].Size = 10 -- write a field value

Visionaire saves all data in tables containing objects. These objects contain fields with different types. All fields can be read and written from lua, but not all fields have event handlers, that will update the value in the engine.

All tables and the game object are exported to lua and can accessed there. Tables can be iterated with numbers and names.

The table names are globals corresponding to their name.

Once you have an object you can read and write fields as members of that object.

Feldtypen

t_bool

local b = game.FullScreenIntro
game.FullScreenIntro = true

A simple boolean, true or false.

t_int

local b = game.ScrollSpeed
game.ScrollSpeed = 100

A simple 32bit integer.

t_string

local b = game.Description
game.Description = ""

A simple string.

t_path

local b = game.Intro
game.Intro = ""

Paths are essentially strings but are used to distinguish from strings.

t_float

local b = game.CurrentCharacter.Size
game.CurrentCharacter.Size = 0.0

A 32bit float.

t_point

local b = game.ScrollPosition
game.ScrollPosition = {x=0, y=0}

-- just to clarify that this won't work as the table you are given is not a reference
game.ScrollPosition.x=0 -- doesn't work

A point, handled as a table with x and y values as integers.

t_rect

local b = game.CurrentScene.ScrollableArea
game.CurrentScene.ScrollableArea = {x=0, y=0, width=100, height=100}

-- just to clarify that this won't work as the table you are given is not a reference
game.CurrentScene.ScrollableArea.x=0 -- doesn't work

A rect, handled as a table with x, y, width and height values as integers.

t_sprite

A sprite, will be a table with the properties:
path string
position point/table
transparency int
transpcolor int
pause int

game.CurrentCharacter.Size = 0.0 -- CurrentCharacter is a link
game.CurrentCharacter = emptyObject -- link is cleared
game.CurrentCharacter = Characters[1]

A link to an object, the object will be returned on access. The link can be set with an object.

game.CurrentCharacter.Items = {} -- clearing the list
local b = game.CurrentCharacter.Items.Name -- access by name
local b = game.CurrentCharacter.Items[1] -- access by number

A list of links, it can iterated with numbers and names of the objects.

t_text

A text object, which contains one language text. Has the properties:
text: string
sound: string
language: int, id of the language

t_vrect

A list of rects.

t_vsprite

A list of sprites.

t_vpoint

A list of points.

t_vstring

A list of strings.

t_vint

A list of ints.

t_vpath

A list of paths.

t_vfloat

A list of floats.

t_vtext

A list of texts.