Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
ScriptApiPlayer Class Reference

#include <s_player.h>

+ Inheritance diagram for ScriptApiPlayer:
+ Collaboration diagram for ScriptApiPlayer:

Public Member Functions

virtual ~ScriptApiPlayer ()=default
 
void on_newplayer (ServerActiveObject *player)
 
void on_dieplayer (ServerActiveObject *player, const PlayerHPChangeReason &reason)
 
bool on_respawnplayer (ServerActiveObject *player)
 
bool on_prejoinplayer (const std::string &name, const std::string &ip, std::string *reason)
 
bool can_bypass_userlimit (const std::string &name, const std::string &ip)
 
void on_joinplayer (ServerActiveObject *player, s64 last_login)
 
void on_leaveplayer (ServerActiveObject *player, bool timeout)
 
void on_cheat (ServerActiveObject *player, const std::string &cheat_type)
 
bool on_punchplayer (ServerActiveObject *player, ServerActiveObject *hitter, float time_from_last_punch, const ToolCapabilities *toolcap, v3f dir, s32 damage)
 
void on_rightclickplayer (ServerActiveObject *player, ServerActiveObject *clicker)
 
s32 on_player_hpchange (ServerActiveObject *player, s32 hp_change, const PlayerHPChangeReason &reason)
 
void on_playerReceiveFields (ServerActiveObject *player, const std::string &formname, const StringMap &fields)
 
void on_authplayer (const std::string &name, const std::string &ip, bool is_success)
 
int player_inventory_AllowMove (const MoveAction &ma, int count, ServerActiveObject *player)
 
int player_inventory_AllowPut (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
int player_inventory_AllowTake (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
void player_inventory_OnMove (const MoveAction &ma, int count, ServerActiveObject *player)
 
void player_inventory_OnPut (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
void player_inventory_OnTake (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
- Public Member Functions inherited from ScriptApiBase
 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 runCallbacksRaw (int nargs, RunCallbacksMode mode, const char *fxn)
 
void addObjectReference (ServerActiveObject *cobj)
 
void removeObjectReference (ServerActiveObject *cobj)
 
ScriptingType getType ()
 
IGameDefgetGameDef ()
 
ServergetServer ()
 
const std::string & getOrigin ()
 
void setOriginDirect (const char *origin)
 
void setOriginFromTableRaw (int index, const char *fxn)
 
void clientOpenLibs (lua_State *L)
 
void checkSetByBuiltin ()
 

Private Member Functions

void pushPutTakeArguments (const char *method, const InventoryLocation &loc, const std::string &listname, int index, const ItemStack &stack, ServerActiveObject *player)
 
void pushMoveArguments (const MoveAction &ma, int count, ServerActiveObject *player)
 

Additional Inherited Members

- Static Public Member Functions inherited from ScriptApiBase
static std::string getCurrentModNameInsecure (lua_State *L)
 Returns the currently running mod, only during init time.
 
- Protected Member Functions inherited from ScriptApiBase
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)
 
EmergeThreadgetEmergeThread ()
 
void setEmergeThread (EmergeThread *emerge)
 
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)
 
template<>
s16 readParam (lua_State *L, int index)
 
template<>
int readParam (lua_State *L, int index)
 
template<>
float readParam (lua_State *L, int index)
 
template<>
v2s16 readParam (lua_State *L, int index)
 
template<>
v2f readParam (lua_State *L, int index)
 
template<>
v3f readParam (lua_State *L, int index)
 
template<>
std::string_view readParam (lua_State *L, int index)
 
template<>
std::string readParam (lua_State *L, int index)
 
template<>
std::string_view readParam (lua_State *L, int index)
 Read a string from Lua state L at index without copying it.
 
- Static Protected Member Functions inherited from LuaHelper
template<typename T >
static T readParam (lua_State *L, int index)
 Read a value using a template type T from Lua state L at index.
 
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 at index.
 
- Protected Attributes inherited from ScriptApiBase
std::recursive_mutex m_luastackmutex
 
std::string m_last_run_mod
 
int m_lock_recursion_count {}
 
std::thread::id m_owning_thread
 

Constructor & Destructor Documentation

◆ ~ScriptApiPlayer()

virtual ScriptApiPlayer::~ScriptApiPlayer ( )
virtualdefault

Member Function Documentation

◆ can_bypass_userlimit()

bool ScriptApiPlayer::can_bypass_userlimit ( const std::string & name,
const std::string & ip )

References RUN_CALLBACKS_MODE_OR, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::handleCommand_Init().

+ Here is the caller graph for this function:

◆ on_authplayer()

void ScriptApiPlayer::on_authplayer ( const std::string & name,
const std::string & ip,
bool is_success )

References RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::handleCommand_FirstSrp(), and Server::handleCommand_SrpBytesM().

+ Here is the caller graph for this function:

◆ on_cheat()

void ScriptApiPlayer::on_cheat ( ServerActiveObject * player,
const std::string & cheat_type )

References ScriptApiBase::objectrefGetOrCreate(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::checkInteractDistance(), Server::handleCommand_Interact(), and Server::process_PlayerPos().

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

◆ on_dieplayer()

void ScriptApiPlayer::on_dieplayer ( ServerActiveObject * player,
const PlayerHPChangeReason & reason )

References ScriptApiBase::objectrefGetOrCreate(), ScriptApiBase::pushPlayerHPChangeReason(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::HandlePlayerDeath().

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

◆ on_joinplayer()

void ScriptApiPlayer::on_joinplayer ( ServerActiveObject * player,
s64 last_login )

References ScriptApiBase::objectrefGetOrCreate(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::handleCommand_ClientReady().

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

◆ on_leaveplayer()

void ScriptApiPlayer::on_leaveplayer ( ServerActiveObject * player,
bool timeout )

References ScriptApiBase::objectrefGetOrCreate(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::DeleteClient().

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

◆ on_newplayer()

void ScriptApiPlayer::on_newplayer ( ServerActiveObject * player)

References ScriptApiBase::objectrefGetOrCreate(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::emergePlayer().

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

◆ on_player_hpchange()

s32 ScriptApiPlayer::on_player_hpchange ( ServerActiveObject * player,
s32 hp_change,
const PlayerHPChangeReason & reason )

References ScriptApiBase::objectrefGetOrCreate(), PCALL_RES, PUSH_ERROR_HANDLER, ScriptApiBase::pushPlayerHPChangeReason(), and SCRIPTAPI_PRECHECKHEADER.

Referenced by PlayerSAO::setHP().

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

◆ on_playerReceiveFields()

void ScriptApiPlayer::on_playerReceiveFields ( ServerActiveObject * player,
const std::string & formname,
const StringMap & fields )

References ScriptApiBase::objectrefGetOrCreate(), RUN_CALLBACKS_MODE_OR_SC, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::handleCommand_InventoryFields().

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

◆ on_prejoinplayer()

bool ScriptApiPlayer::on_prejoinplayer ( const std::string & name,
const std::string & ip,
std::string * reason )

References LuaHelper::readParam(), RUN_CALLBACKS_MODE_OR, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::handleCommand_Init().

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

◆ on_punchplayer()

bool ScriptApiPlayer::on_punchplayer ( ServerActiveObject * player,
ServerActiveObject * hitter,
float time_from_last_punch,
const ToolCapabilities * toolcap,
v3f dir,
s32 damage )

References dir(), ScriptApiBase::objectrefGetOrCreate(), push_tool_capabilities(), push_v3f(), LuaHelper::readParam(), RUN_CALLBACKS_MODE_OR, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by PlayerSAO::punch().

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

◆ on_respawnplayer()

bool ScriptApiPlayer::on_respawnplayer ( ServerActiveObject * player)

References ScriptApiBase::objectrefGetOrCreate(), LuaHelper::readParam(), RUN_CALLBACKS_MODE_OR, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by PlayerSAO::respawn().

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

◆ on_rightclickplayer()

void ScriptApiPlayer::on_rightclickplayer ( ServerActiveObject * player,
ServerActiveObject * clicker )

References ScriptApiBase::objectrefGetOrCreate(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by PlayerSAO::rightClick().

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

◆ player_inventory_AllowMove()

int ScriptApiPlayer::player_inventory_AllowMove ( const MoveAction & ma,
int count,
ServerActiveObject * player )

References pushMoveArguments(), RUN_CALLBACKS_MODE_OR_SC, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by IMoveAction::allowMove().

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

◆ player_inventory_AllowPut()

int ScriptApiPlayer::player_inventory_AllowPut ( const MoveAction & ma,
const ItemStack & stack,
ServerActiveObject * player )

References ItemStack::count, pushPutTakeArguments(), RUN_CALLBACKS_MODE_OR_SC, runCallbacks, SCRIPTAPI_PRECHECKHEADER, MoveAction::to_i, MoveAction::to_inv, and MoveAction::to_list.

Referenced by IMoveAction::allowPut().

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

◆ player_inventory_AllowTake()

int ScriptApiPlayer::player_inventory_AllowTake ( const MoveAction & ma,
const ItemStack & stack,
ServerActiveObject * player )

References ItemStack::count, MoveAction::from_i, MoveAction::from_inv, MoveAction::from_list, pushPutTakeArguments(), RUN_CALLBACKS_MODE_OR_SC, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by IMoveAction::allowTake().

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

◆ player_inventory_OnMove()

void ScriptApiPlayer::player_inventory_OnMove ( const MoveAction & ma,
int count,
ServerActiveObject * player )

References pushMoveArguments(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by IMoveAction::onMove().

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

◆ player_inventory_OnPut()

void ScriptApiPlayer::player_inventory_OnPut ( const MoveAction & ma,
const ItemStack & stack,
ServerActiveObject * player )

References pushPutTakeArguments(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, SCRIPTAPI_PRECHECKHEADER, MoveAction::to_i, MoveAction::to_inv, and MoveAction::to_list.

Referenced by IMoveAction::onPut().

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

◆ player_inventory_OnTake()

void ScriptApiPlayer::player_inventory_OnTake ( const MoveAction & ma,
const ItemStack & stack,
ServerActiveObject * player )

References MoveAction::from_i, MoveAction::from_inv, MoveAction::from_list, pushPutTakeArguments(), RUN_CALLBACKS_MODE_FIRST, runCallbacks, and SCRIPTAPI_PRECHECKHEADER.

Referenced by IMoveAction::onTake().

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

◆ pushMoveArguments()

void ScriptApiPlayer::pushMoveArguments ( const MoveAction & ma,
int count,
ServerActiveObject * player )
private

References InvRef::create(), MoveAction::from_i, MoveAction::from_inv, MoveAction::from_list, ScriptApiBase::getStack(), ScriptApiBase::objectrefGetOrCreate(), MoveAction::to_i, and MoveAction::to_list.

Referenced by player_inventory_AllowMove(), and player_inventory_OnMove().

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

◆ pushPutTakeArguments()

void ScriptApiPlayer::pushPutTakeArguments ( const char * method,
const InventoryLocation & loc,
const std::string & listname,
int index,
const ItemStack & stack,
ServerActiveObject * player )
private

References InvRef::create(), LuaItemStack::create(), ScriptApiBase::getStack(), and ScriptApiBase::objectrefGetOrCreate().

Referenced by player_inventory_AllowPut(), player_inventory_AllowTake(), player_inventory_OnPut(), and player_inventory_OnTake().

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

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