Table of Contents
VidentiUI's Lua Functionality
There are two main ways that Lua code is able to affect UI in VidentiUI:
While UI Data is only ever modified by Lua scripts, Shared Globals are, as the name suggests, shared between Lua and C++. UI Data is retrieved to draw UI Elements to the screen, while Shared Globals share input events, signals and the deltaTime and nextScript variables between Lua and C++.
UI Data
UI Data consists of categories and elements. In Lua, all UI Categories are tables, and fields of the global ui element, and all UI Elements are tables, and fields of UI Categories.
Categories
Categories are used to make managing similar or grouped parts of UI easier. For example, take the code below:
ui.btn = {} -- create the buttons category
ui.btn.b1 = {--[[button data]]}
ui.btn.b2 = {--[[button data]]}
ui.btn.b3 = {--[[button data]]}
ui.bg = {} -- create the background category
ui.bg.bg = {--[[background data]]}
In this case, both the group of buttons and the background are in two seperate categories. To remove the buttons but keep the background intact, we only need to call:
ui.btn = nil
Removing all the UI elements in that category. Note that ui.bg.bg is just as capable of being a button as ui.btn.b1, it only depends on how the UI element is defined.
Elements
UI Elements are the basic building blocks of UI. Graphically, they consist of either:
- Text
- A rectangular texture or solid color
- Both
In Lua, UI Elements have a number of fields, each with their own behaviour and parameters. These can be found in the List of UI Properties on this wiki.
Shared Globals
Shared Globals are values that are updated typically every frame with information to pass between UI scripts and your C++ app, handling input and functionality that depends on Lua and C++ interoperability.
They can be seen in Lua as global variables that begin with VUI_. For a full list of them and their functionality, see the List of Shared Globals on this wiki.