tomaka / hlua

Rust library to interface with Lua
MIT License
507 stars 48 forks source link

Storing references to loaded Lua table for callback logic. #182

Open dkushner opened 6 years ago

dkushner commented 6 years ago

Hey all! Currently trying to integrate Lua into my application as a scripting extension for rapid development. I wish to allow the user to implement custom components with something like the following structure:

local Test = { }

function Test:Init() end

function Test:Update(delta) end

function Test:Destroy() end

return Test

If I have a Lua instance stored in a struct, how might I also store within this struct, references to the callbacks defined in that loaded script? For instance, I want to load this table on initialization to get references to each of the callbacks and then be able to call the user-defined Test:Update(delta) function each frame.