Scarab
A thin, game-agnostic 2D engine host built on the sunlight tile-map engine
Loading...
Searching...
No Matches
Scarab::Engine::Lua::LuaEngineUtil Class Reference

Shared helpers used by every Lua primitive API module - and, for s_LuaMutex specifically, by LuaEngine itself too (the orchestrator, not one of the primitive API modules - see s_LuaMutex's own comment for why it lives here rather than on LuaEngine). More...

#include <luaengineutil.h>

Static Public Member Functions

static Engine::IRendererProvider * GetRendererProvider (lua_State *pLuaState)
 Fetch the renderer provider stashed as a Lua light userdata global - the one object every renderer-needing primitive reaches the renderer through, since the renderer does not exist yet when the Lua engine is built (see IRendererProvider).
 
static void EnsureRenderer (lua_State *pLuaState)
 Make sure a renderer exists, creating the default one (and opening its window) if the script hasn't - for primitives that need a live window/GL context but don't go through GetTileMap()/GetDrawSurface() (eg. sprite_configure_texture, which loads a GPU texture).
 
static SunLight::TileMap::ITileMap * GetTileMap (lua_State *pLuaState)
 The engine's ITileMap - creating the default renderer first if the script has not created one yet (see IRendererProvider::GetTileMap).
 
static SunLight::DrawSurface::IDrawSurface * GetDrawSurface (lua_State *pLuaState)
 The engine's IDrawSurface - screen-space text/rectangle drawing and window-state primitives (see sunlight's own IDrawSurface header comment), a separate interface from GetTileMap()'s since sunlight v0.12.0 split those off ITileMap. Both address the same underlying TileMapRenderer object today (it implements both), but callers should reach for whichever interface actually matches what they're doing, not assume that always holds. Creates the default renderer first if the script has not created one yet.
 
static SunLight::Sound::SoundManager * GetSoundManager (lua_State *pLuaState)
 Fetch the engine's SoundManager instance stashed as a Lua light userdata global.
 
static Engine::SpritePool * GetSpritePool (lua_State *pLuaState)
 Fetch the engine's SpritePool instance stashed as a Lua light userdata global.
 
static SunLight::Scripting::ScriptProcessor * GetScriptProcessor (lua_State *pLuaState)
 Fetch the engine's ScriptProcessor instance stashed as a Lua light userdata global.
 
static void AddOneParmCommandScript (lua_State *pLuaState, SunLight ::Scripting ::Commands cmd)
 Add an one parameter command to the ScriptProcessor's queue; shared by every Lua primitive that queues a command rather than acting immediately (sp_wait, sp_move_sprites_to_screen, sp_play_song, ...).
 
static void RegisterConstants (lua_State *pLuaState, const stNamedConstant *pTable, size_t nCount)
 Register a table of named integer constants as Lua globals.
 
static void RegisterRealConstants (lua_State *pLuaState, const stNamedRealConstant *pTable, size_t nCount)
 Register a table of named real-valued constants as Lua globals (see stNamedRealConstant).
 

Static Public Attributes

static std::mutex s_LuaMutex
 

Detailed Description

Shared helpers used by every Lua primitive API module - and, for s_LuaMutex specifically, by LuaEngine itself too (the orchestrator, not one of the primitive API modules - see s_LuaMutex's own comment for why it lives here rather than on LuaEngine).

Member Function Documentation

◆ AddOneParmCommandScript()

void Scarab::Engine::Lua::LuaEngineUtil::AddOneParmCommandScript ( lua_State *  pLuaState,
SunLight ::Scripting ::Commands  cmd 
)
static

Add an one parameter command to the ScriptProcessor's queue; shared by every Lua primitive that queues a command rather than acting immediately (sp_wait, sp_move_sprites_to_screen, sp_play_song, ...).

Parameters
pLuaStateLua state to be used by engine call.
cmdThe command to add to queue;

◆ EnsureRenderer()

void Scarab::Engine::Lua::LuaEngineUtil::EnsureRenderer ( lua_State *  pLuaState)
static

Make sure a renderer exists, creating the default one (and opening its window) if the script hasn't - for primitives that need a live window/GL context but don't go through GetTileMap()/GetDrawSurface() (eg. sprite_configure_texture, which loads a GPU texture).

Parameters
pLuaStateLua state to be used by engine call.

◆ GetDrawSurface()

SunLight::DrawSurface::IDrawSurface * Scarab::Engine::Lua::LuaEngineUtil::GetDrawSurface ( lua_State *  pLuaState)
static

The engine's IDrawSurface - screen-space text/rectangle drawing and window-state primitives (see sunlight's own IDrawSurface header comment), a separate interface from GetTileMap()'s since sunlight v0.12.0 split those off ITileMap. Both address the same underlying TileMapRenderer object today (it implements both), but callers should reach for whichever interface actually matches what they're doing, not assume that always holds. Creates the default renderer first if the script has not created one yet.

Parameters
pLuaStateLua state to be used by engine call.

◆ GetRendererProvider()

Engine::IRendererProvider * Scarab::Engine::Lua::LuaEngineUtil::GetRendererProvider ( lua_State *  pLuaState)
static

Fetch the renderer provider stashed as a Lua light userdata global - the one object every renderer-needing primitive reaches the renderer through, since the renderer does not exist yet when the Lua engine is built (see IRendererProvider).

Parameters
pLuaStateLua state to be used by engine call.

◆ GetScriptProcessor()

SunLight::Scripting::ScriptProcessor * Scarab::Engine::Lua::LuaEngineUtil::GetScriptProcessor ( lua_State *  pLuaState)
static

Fetch the engine's ScriptProcessor instance stashed as a Lua light userdata global.

Parameters
pLuaStateLua state to be used by engine call.

◆ GetSoundManager()

SunLight::Sound::SoundManager * Scarab::Engine::Lua::LuaEngineUtil::GetSoundManager ( lua_State *  pLuaState)
static

Fetch the engine's SoundManager instance stashed as a Lua light userdata global.

Parameters
pLuaStateLua state to be used by engine call.

◆ GetSpritePool()

Engine::SpritePool * Scarab::Engine::Lua::LuaEngineUtil::GetSpritePool ( lua_State *  pLuaState)
static

Fetch the engine's SpritePool instance stashed as a Lua light userdata global.

Parameters
pLuaStateLua state to be used by engine call.

◆ GetTileMap()

SunLight::TileMap::ITileMap * Scarab::Engine::Lua::LuaEngineUtil::GetTileMap ( lua_State *  pLuaState)
static

The engine's ITileMap - creating the default renderer first if the script has not created one yet (see IRendererProvider::GetTileMap).

Parameters
pLuaStateLua state to be used by engine call.

◆ RegisterConstants()

void Scarab::Engine::Lua::LuaEngineUtil::RegisterConstants ( lua_State *  pLuaState,
const stNamedConstant *  pTable,
size_t  nCount 
)
static

Register a table of named integer constants as Lua globals.

Parameters
pLuaStateLua state to be used by engine call.
pTableThe constants table to register;
nCountNumber of entries in the table;

◆ RegisterRealConstants()

void Scarab::Engine::Lua::LuaEngineUtil::RegisterRealConstants ( lua_State *  pLuaState,
const stNamedRealConstant *  pTable,
size_t  nCount 
)
static

Register a table of named real-valued constants as Lua globals (see stNamedRealConstant).

Parameters
pLuaStateLua state to be used by engine call.
pTableThe constants table to register;
nCountNumber of entries in the table;

Member Data Documentation

◆ s_LuaMutex

std::mutex Scarab::Engine::Lua::LuaEngineUtil::s_LuaMutex
static

The documentation for this class was generated from the following files: