Toast Engine
Loading...
Searching...
No Matches
scripting::ScriptInstance Class Reference

Public Member Functions

 ScriptInstance (size_t vm_index, lua_State *l, const assets::Handle< assets::Script > &script, NodeProxy proxy, std::shared_ptr< RuntimeToken > token)
 ~ScriptInstance ()
 The owner of the interpreter has to run this, it releases registry references.
 ScriptInstance (ScriptInstance &&)=delete
auto operator= (ScriptInstance &&) -> ScriptInstance &=delete
 ScriptInstance (const ScriptInstance &)=delete
auto operator= (const ScriptInstance &) -> ScriptInstance &=delete
void call (std::string_view fn_name) noexcept
 Calls the named lifecycle function.
void callWithLuaStack (std::string_view name, lua_State *l, int args_base, int n_args) noexcept
 rawget self[name]; if a function, pcall(self, forwarded_args...)
auto callEventMethod (std::string_view name, lua_State *l, int event_index) noexcept -> bool
 Calls a lua method on the self table.
void callWithAnyArgs (std::string_view name, std::span< const std::any > args) noexcept
 Fan-out call with args provided as std::any values.
auto setVar (std::string_view name, const std::any &value) noexcept -> bool
auto getVar (std::string_view name) const noexcept -> std::any
 Reads the instance variable named name.
auto getVarByPath (std::string_view path) const noexcept -> std::any
 Reads a variable through its schema path.
auto setVarByPath (std::string_view path, const std::any &value) noexcept -> bool
auto hasFunction (std::string_view fn_name) const noexcept -> bool
 Returns true if the self table has a callable field with this name. Needs the interpreter.
auto knowsFunction (std::string_view fn_name) const noexcept -> bool
 True when the script defined a function with this name when it was loaded; touches no interpreter.
auto luaSignals () const noexcept -> const std::unordered_map< std::string, LuaSignal > &
auto luaSignals () noexcept -> std::unordered_map< std::string, LuaSignal > &
auto schema () const noexcept -> const ScriptSchema &
auto isValid () const noexcept -> bool
 Cached at load, never touches the interpreter.
auto tickMask () const noexcept -> toast::TickFunctionList
 Tick phases this script defines.
auto name () const noexcept -> const std::string &
 Asset path of the script.

Member Function Documentation

◆ setVar()

auto scripting::ScriptInstance::setVar ( std::string_view name,
const std::any & value ) -> bool
noexcept

Writes value to the instance variable named name

Returns
true if the variable exists
Here is the caller graph for this function:

◆ setVarByPath()

auto scripting::ScriptInstance::setVarByPath ( std::string_view path,
const std::any & value ) -> bool
noexcept

Writes a variable through its schema path

Returns
true if the variable exists
Here is the caller graph for this function:

The documentation for this class was generated from the following files:
  • engine/src/toast/scripting/script_runtime.hpp
  • engine/src/toast/scripting/script_runtime.cpp