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

Classes

struct  Shared

Public Member Functions

 operator bool () const noexcept
auto alive () const noexcept -> bool
 False once the runtime that created the function is gone.
auto invoke () const noexcept -> bool
 Calls the function with no arguments and ignores the result.
auto invokeBool () const noexcept -> std::optional< bool >
 Calls the function and expects a boolean back.
auto invokeWithArgument (const std::function< void(lua_State *)> &push_argument) const noexcept -> std::optional< bool >
 Calls the function with one argument.

Static Public Member Functions

static auto capture (const luabridge::LuaRef &fn, std::string name={}) -> LuaCallback
 Keeps function alive on its interpreter.

Member Function Documentation

◆ invoke()

auto scripting::LuaCallback::invoke ( ) const -> bool
nodiscardnoexcept

Calls the function with no arguments and ignores the result.

When the interpreter is busy on another thread while this one owns a different one

◆ invokeWithArgument()

auto scripting::LuaCallback::invokeWithArgument ( const std::function< void(lua_State *)> & push_argument) const -> std::optional< bool >
nodiscardnoexcept

Calls the function with one argument.

Returns
the boolean the function returned

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