Brunot
Loading...
Searching...
No Matches
Scripting

With scripting support, we can do a lot really simply. there will also be a few quirks, which I'm hopefully able to document here

Syntax quirks

Paths

To iterate over a path in lua, you'll need to use pairs(path:iterable())

local cards = Path("~/Entity/")
for num, ent in pairs(cards:iterable()) do
-- num is number of Entity in order, kinda like iterating with i.
-- num will have range [1, numOfEntities]
-- (notice brackets on either side of range,
-- b/c lua is 1 indexed, and include the 5, if
-- there are 5 entities, for example)
-- ent is a reference to the entity
hlg:Message("Card:" .. ent:getFormattedName())
end

this is roughly equivelent to the following cpp code

auto cards = gobj::Path("~/Entity/");
for( auto& ent : cards ) {
hlg::Message("Card: {}", ent.getFormattedName());
}
An object that represents where a GameObject or a range of GameObjects exists in the Engine.
Definition Path.h:326
auto Message(spdlog::format_string_t< Args... > message, Args &&... args) -> void
Definition Logging.h:85

QOL

Brunot.lua

Lua language server (the thing that gives syntax higlighting for lua) can recognize some classes and types in lua if we declare them, which makes warnings and errors go away. if theres a warning you want to disappear in lua, you can likely just add a field to Brunot.lua and it will stop warning you, and possibly even give you autocomplete. it is encouraged to add things to brunot.lua as you go along, and if you would like to add more things ahead of time, (like for an entire type) go ahead. I recommend looking at the bindLuaTypes functions to see what is actually bound

Lua Bindings

bindLuaTypes

to bind a type to lua, our engine convention is to put it in a static bindLuaTypes function in the class, then call it in the constructor of ScriptingManager. we also have a few macros to help you out ///

Todo
fill this and other sections out

component Bindings

lorem ipsum ill fill this out later

other bindings

lorem ipsum ill fill this out later