Minetest  5.4.0
ScriptApiBase Class Reference

#include <s_base.h>

+ Inheritance diagram for ScriptApiBase:
+ Collaboration diagram for ScriptApiBase:

Public Member Functions

 ScriptApiBase (ScriptingType type)
 
 ScriptApiBase ()
 
virtual ~ScriptApiBase ()
 
 DISABLE_CLASS_COPY (ScriptApiBase)
 
void loadMod (const std::string &script_path, const std::string &mod_name)
 
void loadScript (const std::string &script_path)
 
void loadModFromMemory (const std::string &mod_name)
 
void runCallbacksRaw (int nargs, RunCallbacksMode mode, const char *fxn)
 
void addObjectReference (ServerActiveObject *cobj)
 
void removeObjectReference (ServerActiveObject *cobj)
 
IGameDefgetGameDef ()
 
ServergetServer ()
 
ScriptingType getType ()
 
ClientgetClient ()
 
std::string getOrigin ()
 
void setOriginDirect (const char *origin)
 
void setOriginFromTableRaw (int index, const char *fxn)
 
void clientOpenLibs (lua_State *L)
 

Protected Member Functions

lua_State * getStack ()
 
void realityCheck ()
 
void scriptError (int result, const char *fxn)
 
void stackDump (std::ostream &o)
 
void setGameDef (IGameDef *gamedef)
 
EnvironmentgetEnv ()
 
void setEnv (Environment *env)
 
GUIEnginegetGuiEngine ()
 
void setGuiEngine (GUIEngine *guiengine)
 
void objectrefGetOrCreate (lua_State *L, ServerActiveObject *cobj)
 
void pushPlayerHPChangeReason (lua_State *L, const PlayerHPChangeReason &reason)
 
- Protected Member Functions inherited from LuaHelper
template<>
bool readParam (lua_State *L, int index)
 

Protected Attributes

std::recursive_mutex m_luastackmutex
 
std::string m_last_run_mod
 
bool m_secure = false
 
int m_lock_recursion_count {}
 
std::thread::id m_owning_thread
 

Static Private Member Functions

static int luaPanic (lua_State *L)
 

Private Attributes

lua_State * m_luastack = nullptr
 
IGameDefm_gamedef = nullptr
 
Environmentm_environment = nullptr
 
GUIEnginem_guiengine = nullptr
 
ScriptingType m_type
 

Friends

class LuaABM
 
class LuaLBM
 
class InvRef
 
class ObjectRef
 
class NodeMetaRef
 
class ModApiBase
 
class ModApiEnvMod
 
class LuaVoxelManip
 

Additional Inherited Members

- Static Protected Member Functions inherited from LuaHelper
static bool isNaN (lua_State *L, int idx)
 
template<typename T >
static T readParam (lua_State *L, int index)
 Read a value using a template type T from Lua State L and index. More...
 
template<typename T >
static T readParam (lua_State *L, int index, const T &default_value)
 Read a value using a template type T from Lua State L and index. More...
 

Constructor & Destructor Documentation

◆ ScriptApiBase() [1/2]

ScriptApiBase::ScriptApiBase ( ScriptingType  type)

References Client, clientOpenLibs(), CUSTOM_RIDX_BACKTRACE, CUSTOM_RIDX_SCRIPTAPI, DIR_DELIM, FATAL_ERROR_IF, porting::getPlatformName(), luaPanic(), m_lock_recursion_count, m_luastack, m_type, and script_exception_wrapper().

+ Here is the call graph for this function:

◆ ScriptApiBase() [2/2]

ScriptApiBase::ScriptApiBase ( )
inline

References FATAL_ERROR.

◆ ~ScriptApiBase()

ScriptApiBase::~ScriptApiBase ( )
virtual

References m_luastack.

Member Function Documentation

◆ addObjectReference()

void ScriptApiBase::addObjectReference ( ServerActiveObject cobj)

References ObjectRef::create(), ActiveObject::getId(), and SCRIPTAPI_PRECHECKHEADER.

Referenced by ServerEnvironment::addActiveObjectRaw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clientOpenLibs()

void ScriptApiBase::clientOpenLibs ( lua_State *  L)

Referenced by ScriptApiBase().

+ Here is the caller graph for this function:

◆ DISABLE_CLASS_COPY()

ScriptApiBase::DISABLE_CLASS_COPY ( ScriptApiBase  )

◆ getClient()

Client * ScriptApiBase::getClient ( )

References m_gamedef.

Referenced by ScriptApiClient::environment_step(), ModApiBase::getClient(), loadModFromMemory(), ScriptApiClient::on_dignode(), ScriptApiClient::on_punchnode(), runCallbacksRaw(), and ScriptApiSecurity::sl_g_loadfile().

+ Here is the caller graph for this function:

◆ getEnv()

◆ getGameDef()

IGameDef* ScriptApiBase::getGameDef ( )
inline

References m_gamedef.

Referenced by ScriptApiSecurity::checkPath(), and ModApiBase::getGameDef().

+ Here is the caller graph for this function:

◆ getGuiEngine()

GUIEngine* ScriptApiBase::getGuiEngine ( )
inlineprotected

References m_guiengine.

Referenced by ModApiBase::getGuiEngine().

+ Here is the caller graph for this function:

◆ getOrigin()

std::string ScriptApiBase::getOrigin ( )
inline

References m_last_run_mod.

Referenced by ModApiEnvMod::l_emerge_area().

+ Here is the caller graph for this function:

◆ getServer()

◆ getStack()

◆ getType()

ScriptingType ScriptApiBase::getType ( )
inline

References m_type.

Referenced by ScriptApiSecurity::sl_g_loadfile().

+ Here is the caller graph for this function:

◆ loadMod()

void ScriptApiBase::loadMod ( const std::string &  script_path,
const std::string &  mod_name 
)

References getStack(), and loadScript().

Referenced by Server::init(), and ServerModManager::loadMods().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadModFromMemory()

void ScriptApiBase::loadModFromMemory ( const std::string &  mod_name)

References Client, getClient(), Client::getModFile(), getStack(), m_type, PUSH_ERROR_HANDLER, ScriptApiSecurity::safeLoadString(), sanity_check, and verbosestream.

Referenced by Client::loadMods().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadScript()

void ScriptApiBase::loadScript ( const std::string &  script_path)

References getStack(), m_secure, PUSH_ERROR_HANDLER, ScriptApiSecurity::safeLoadFile(), and verbosestream.

Referenced by GUIEngine::loadMainMenuScript(), loadMod(), and AsyncWorkerThread::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ luaPanic()

int ScriptApiBase::luaPanic ( lua_State *  L)
staticprivate

References FATAL_ERROR.

Referenced by ScriptApiBase().

+ Here is the caller graph for this function:

◆ objectrefGetOrCreate()

void ScriptApiBase::objectrefGetOrCreate ( lua_State *  L,
ServerActiveObject cobj 
)
protected

References ObjectRef::create(), ActiveObject::getId(), ServerActiveObject::isGone(), push_objectRef(), and warningstream.

Referenced by ScriptApiDetached::detached_inventory_AllowMove(), ScriptApiDetached::detached_inventory_AllowPut(), ScriptApiDetached::detached_inventory_AllowTake(), ScriptApiDetached::detached_inventory_OnMove(), ScriptApiDetached::detached_inventory_OnPut(), ScriptApiDetached::detached_inventory_OnTake(), ScriptApiItem::item_CraftPredict(), ScriptApiItem::item_OnCraft(), ScriptApiItem::item_OnDrop(), ScriptApiItem::item_OnPlace(), ScriptApiItem::item_OnSecondaryUse(), ScriptApiItem::item_OnUse(), ModApiEnvMod::l_add_entity(), ObjectRef::l_get_attach(), ObjectRef::l_get_children(), ModApiEnvMod::l_get_connected_players(), ModApiEnvMod::l_get_objects_in_area(), ModApiEnvMod::l_get_objects_inside_radius(), ModApiEnvMod::l_get_player_by_name(), ScriptApiEntity::luaentity_Punch(), ScriptApiEntity::luaentity_run_simple_callback(), ScriptApiNode::node_on_dig(), ScriptApiNode::node_on_punch(), ScriptApiNode::node_on_receive_fields(), ScriptApiNodemeta::nodemeta_inventory_AllowMove(), ScriptApiNodemeta::nodemeta_inventory_AllowPut(), ScriptApiNodemeta::nodemeta_inventory_AllowTake(), ScriptApiNodemeta::nodemeta_inventory_OnMove(), ScriptApiNodemeta::nodemeta_inventory_OnPut(), ScriptApiNodemeta::nodemeta_inventory_OnTake(), ScriptApiPlayer::on_cheat(), ScriptApiPlayer::on_dieplayer(), ScriptApiPlayer::on_joinplayer(), ScriptApiPlayer::on_leaveplayer(), ScriptApiPlayer::on_newplayer(), ScriptApiPlayer::on_player_hpchange(), ScriptApiPlayer::on_playerReceiveFields(), ScriptApiPlayer::on_punchplayer(), ScriptApiPlayer::on_respawnplayer(), ScriptApiPlayer::on_rightclickplayer(), ScriptApiEnv::player_event(), ScriptApiPlayer::pushMoveArguments(), pushPlayerHPChangeReason(), and ScriptApiPlayer::pushPutTakeArguments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pushPlayerHPChangeReason()

void ScriptApiBase::pushPlayerHPChangeReason ( lua_State *  L,
const PlayerHPChangeReason reason 
)
protected

References PlayerHPChangeReason::from_mod, PlayerHPChangeReason::getTypeAsString(), PlayerHPChangeReason::hasLuaReference(), PlayerHPChangeReason::lua_reference, PlayerHPChangeReason::node, PlayerHPChangeReason::object, and objectrefGetOrCreate().

Referenced by ScriptApiPlayer::on_dieplayer(), and ScriptApiPlayer::on_player_hpchange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ realityCheck()

void ScriptApiBase::realityCheck ( )
protected

References dstream, m_luastack, script_get_backtrace(), and stackDump().

Referenced by LuaLBM::trigger(), and LuaABM::trigger().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeObjectReference()

void ScriptApiBase::removeObjectReference ( ServerActiveObject cobj)

References ActiveObject::getId(), SCRIPTAPI_PRECHECKHEADER, and ObjectRef::set_null().

Referenced by ServerEnvironment::clearObjects(), ServerEnvironment::deactivateFarObjects(), and ServerEnvironment::removeRemovedObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runCallbacksRaw()

void ScriptApiBase::runCallbacksRaw ( int  nargs,
RunCallbacksMode  mode,
const char *  fxn 
)

References Client, FATAL_ERROR_IF, getClient(), getStack(), m_lock_recursion_count, m_type, PUSH_ERROR_HANDLER, and scriptError().

+ Here is the call graph for this function:

◆ scriptError()

void ScriptApiBase::scriptError ( int  result,
const char *  fxn 
)
protected

References getStack(), m_last_run_mod, and script_error().

Referenced by runCallbacksRaw(), LuaLBM::trigger(), and LuaABM::trigger().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setEnv()

void ScriptApiBase::setEnv ( Environment env)
inlineprotected

References m_environment.

Referenced by ScriptApiEnv::initializeEnvironment(), Client::loadMods(), and ScriptApiClient::setEnv().

+ Here is the caller graph for this function:

◆ setGameDef()

void ScriptApiBase::setGameDef ( IGameDef gamedef)
inlineprotected

References m_gamedef.

Referenced by ClientScripting::ClientScripting(), and ServerScripting::ServerScripting().

+ Here is the caller graph for this function:

◆ setGuiEngine()

void ScriptApiBase::setGuiEngine ( GUIEngine guiengine)
inlineprotected

References m_guiengine.

Referenced by MainMenuScripting::MainMenuScripting().

+ Here is the caller graph for this function:

◆ setOriginDirect()

void ScriptApiBase::setOriginDirect ( const char *  origin)

References m_last_run_mod.

Referenced by ModApiClient::l_set_last_run_mod(), ModApiServer::l_set_last_run_mod(), and ScriptApiEnv::on_emerge_area_completion().

+ Here is the caller graph for this function:

◆ setOriginFromTableRaw()

void ScriptApiBase::setOriginFromTableRaw ( int  index,
const char *  fxn 
)

References getStack(), getstringfield_default(), and m_last_run_mod.

+ Here is the call graph for this function:

◆ stackDump()

void ScriptApiBase::stackDump ( std::ostream &  o)
protected

References m_luastack, and porting::mt_snprintf().

Referenced by realityCheck().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ InvRef

friend class InvRef
friend

◆ LuaABM

friend class LuaABM
friend

◆ LuaLBM

friend class LuaLBM
friend

◆ LuaVoxelManip

friend class LuaVoxelManip
friend

◆ ModApiBase

friend class ModApiBase
friend

◆ ModApiEnvMod

friend class ModApiEnvMod
friend

◆ NodeMetaRef

friend class NodeMetaRef
friend

◆ ObjectRef

friend class ObjectRef
friend

Member Data Documentation

◆ m_environment

Environment* ScriptApiBase::m_environment = nullptr
private

Referenced by getEnv(), and setEnv().

◆ m_gamedef

IGameDef* ScriptApiBase::m_gamedef = nullptr
private

◆ m_guiengine

GUIEngine* ScriptApiBase::m_guiengine = nullptr
private

Referenced by getGuiEngine(), and setGuiEngine().

◆ m_last_run_mod

std::string ScriptApiBase::m_last_run_mod
protected

◆ m_lock_recursion_count

int ScriptApiBase::m_lock_recursion_count {}
protected

Referenced by ScriptApiBase(), and runCallbacksRaw().

◆ m_luastack

lua_State* ScriptApiBase::m_luastack = nullptr
private

◆ m_luastackmutex

std::recursive_mutex ScriptApiBase::m_luastackmutex
protected

◆ m_owning_thread

std::thread::id ScriptApiBase::m_owning_thread
protected

◆ m_secure

bool ScriptApiBase::m_secure = false
protected

◆ m_type

ScriptingType ScriptApiBase::m_type
private

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