Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
ServerScripting Class Reference

#include <scripting_server.h>

+ Inheritance diagram for ServerScripting:
+ Collaboration diagram for ServerScripting:

Public Member Functions

 ServerScripting (Server *server)
 
void loadBuiltin ()
 
void saveGlobals ()
 
void initAsync ()
 
void stepAsync ()
 
u32 queueAsync (std::string &&serialized_func, PackedValue *param, const std::string &mod_origin)
 
- 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 ()
 
- Public Member Functions inherited from ScriptApiDetached
int detached_inventory_AllowMove (const MoveAction &ma, int count, ServerActiveObject *player)
 
int detached_inventory_AllowPut (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
int detached_inventory_AllowTake (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
void detached_inventory_OnMove (const MoveAction &ma, int count, ServerActiveObject *player)
 
void detached_inventory_OnPut (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
void detached_inventory_OnTake (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
- Public Member Functions inherited from ScriptApiEntity
bool luaentity_Add (u16 id, const char *name)
 
void luaentity_Activate (u16 id, const std::string &staticdata, u32 dtime_s)
 
void luaentity_Deactivate (u16 id, bool removal)
 
void luaentity_Remove (u16 id)
 
std::string luaentity_GetStaticdata (u16 id)
 
void luaentity_GetProperties (u16 id, ServerActiveObject *self, ObjectProperties *prop, const std::string &entity_name)
 
void luaentity_Step (u16 id, float dtime, const collisionMoveResult *moveresult)
 
bool luaentity_Punch (u16 id, ServerActiveObject *puncher, float time_from_last_punch, const ToolCapabilities *toolcap, v3f dir, s32 damage)
 
bool luaentity_on_death (u16 id, ServerActiveObject *killer)
 
void luaentity_Rightclick (u16 id, ServerActiveObject *clicker)
 
void luaentity_on_attach_child (u16 id, ServerActiveObject *child)
 
void luaentity_on_detach_child (u16 id, ServerActiveObject *child)
 
void luaentity_on_detach (u16 id, ServerActiveObject *parent)
 
- Public Member Functions inherited from ScriptApiEnv
void environment_Step (float dtime)
 
void environment_OnGenerated (v3s16 minp, v3s16 maxp, u32 blockseed)
 
void player_event (ServerActiveObject *player, const std::string &type)
 
void on_emerge_area_completion (v3s16 blockpos, int action, ScriptCallbackState *state)
 
void check_for_falling (v3s16 p)
 
void on_liquid_transformed (const std::vector< std::pair< v3s16, MapNode > > &list)
 
void on_mapblocks_changed (const std::unordered_set< v3s16 > &set)
 
bool has_on_mapblocks_changed ()
 
void initializeEnvironment (ServerEnvironment *env)
 
void triggerABM (int id, v3s16 p, MapNode n, u32 active_object_count, u32 active_object_count_wider)
 
void triggerLBM (int id, MapBlock *block, const std::unordered_set< v3s16 > &positions, float dtime_s)
 
- Public Member Functions inherited from ScriptApiModChannels
void on_modchannel_message (const std::string &channel, const std::string &sender, const std::string &message)
 
void on_modchannel_signal (const std::string &channel, ModChannelSignal signal)
 
- Public Member Functions inherited from ScriptApiNode
 ScriptApiNode ()=default
 
virtual ~ScriptApiNode ()=default
 
bool node_on_punch (v3s16 p, MapNode node, ServerActiveObject *puncher, const PointedThing &pointed)
 
bool node_on_dig (v3s16 p, MapNode node, ServerActiveObject *digger)
 
void node_on_construct (v3s16 p, MapNode node)
 
void node_on_destruct (v3s16 p, MapNode node)
 
bool node_on_flood (v3s16 p, MapNode node, MapNode newnode)
 
void node_after_destruct (v3s16 p, MapNode node)
 
bool node_on_timer (v3s16 p, MapNode node, f32 dtime)
 
void node_on_receive_fields (v3s16 p, const std::string &formname, const StringMap &fields, ServerActiveObject *sender)
 
- Public Member Functions inherited from ScriptApiNodemeta
 ScriptApiNodemeta ()=default
 
virtual ~ScriptApiNodemeta ()=default
 
int nodemeta_inventory_AllowMove (const MoveAction &ma, int count, ServerActiveObject *player)
 
int nodemeta_inventory_AllowPut (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
int nodemeta_inventory_AllowTake (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
void nodemeta_inventory_OnMove (const MoveAction &ma, int count, ServerActiveObject *player)
 
void nodemeta_inventory_OnPut (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
void nodemeta_inventory_OnTake (const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
 
- Public Member Functions inherited from ScriptApiItem
bool item_OnDrop (ItemStack &item, ServerActiveObject *dropper, v3f pos)
 
bool item_OnPlace (std::optional< ItemStack > &item, ServerActiveObject *placer, const PointedThing &pointed)
 
bool item_OnUse (std::optional< ItemStack > &item, ServerActiveObject *user, const PointedThing &pointed)
 
bool item_OnSecondaryUse (std::optional< ItemStack > &item, ServerActiveObject *user, const PointedThing &pointed)
 
bool item_OnCraft (ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
 
bool item_CraftPredict (ItemStack &item, ServerActiveObject *user, const InventoryList *old_craft_grid, const InventoryLocation &craft_inv)
 
- Public Member Functions inherited from ScriptApiPlayer
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 ScriptApiServer
bool on_chat_message (const std::string &name, const std::string &message)
 
void on_mods_loaded ()
 
void on_shutdown ()
 
std::string formatChatMessage (const std::string &name, const std::string &message)
 
bool getAuth (const std::string &playername, std::string *dst_password, std::set< std::string > *dst_privs, s64 *dst_last_login=nullptr)
 
void createAuth (const std::string &playername, const std::string &password)
 
bool setPassword (const std::string &playername, const std::string &password)
 
void freeDynamicMediaCallback (u32 token)
 
void on_dynamic_media_added (u32 token, const std::string &playername)
 
- Public Member Functions inherited from ScriptApiSecurity
void initializeSecurity ()
 
void initializeSecurityClient ()
 

Private Member Functions

void InitializeModApi (lua_State *L, int top)
 

Static Private Member Functions

static void InitializeAsync (lua_State *L, int top)
 

Private Attributes

AsyncEngine asyncEngine
 

Additional Inherited Members

- Static Public Member Functions inherited from ScriptApiBase
static std::string getCurrentModNameInsecure (lua_State *L)
 
static std::string getCurrentModName (lua_State *L)
 
- Static Public Member Functions inherited from ScriptApiServer
static u32 allocateDynamicMediaCallback (lua_State *L, int f_idx)
 
- Static Public Member Functions inherited from ScriptApiSecurity
static bool isSecure (lua_State *L)
 
static bool safeLoadString (lua_State *L, const std::string &code, const char *chunk_name)
 
static bool safeLoadFile (lua_State *L, const char *path, const char *display_name=NULL)
 
static bool checkWhitelisted (lua_State *L, const std::string &setting)
 
static bool checkPath (lua_State *L, const char *path, bool write_required, bool *write_allowed=NULL)
 
- Static Public Attributes inherited from ScriptApiNode
static struct EnumString es_DrawType []
 
static struct EnumString es_ContentParamType []
 
static struct EnumString es_ContentParamType2 []
 
static struct EnumString es_LiquidType []
 
static struct EnumString es_LiquidMoveType []
 
static struct EnumString es_NodeBoxType []
 
static struct EnumString es_TextureAlphaMode []
 
- 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.
 
- Protected Member Functions inherited from ScriptApiItem
bool getItemCallback (const char *name, const char *callbackname, const v3s16 *p=nullptr)
 
void pushPointedThing (const PointedThing &pointed, bool hitpoint=false)
 
- 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
 
bool m_secure = false
 
int m_lock_recursion_count {}
 
std::thread::id m_owning_thread
 

Constructor & Destructor Documentation

◆ ServerScripting()

ServerScripting::ServerScripting ( Server * server)

References g_settings, Settings::getBool(), infostream, InitializeModApi(), ScriptApiSecurity::initializeSecurity(), SCRIPTAPI_PRECHECKHEADER, ScriptApiBase::setGameDef(), and warningstream.

+ Here is the call graph for this function:

Member Function Documentation

◆ initAsync()

void ServerScripting::initAsync ( )

References asyncEngine, infostream, ModApiIPC::Initialize(), AsyncEngine::initialize(), ModApiCraft::InitializeAsync(), ModApiItem::InitializeAsync(), ModApiServer::InitializeAsync(), ModApiUtil::InitializeAsync(), InitializeAsync(), and AsyncEngine::registerStateInitializer().

Referenced by Server::init().

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

◆ InitializeAsync()

void ServerScripting::InitializeAsync ( lua_State * L,
int top )
staticprivate

References ModApiBase::getServer(), Server::m_lua_globals_data, ItemStackMetaRef::Register(), LuaAreaStore::Register(), LuaItemStack::Register(), LuaPcgRandom::Register(), LuaPerlinNoise::Register(), LuaPerlinNoiseMap::Register(), LuaPseudoRandom::Register(), LuaSecureRandom::Register(), LuaSettings::Register(), LuaVoxelManip::Register(), and script_unpack().

Referenced by initAsync().

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

◆ InitializeModApi()

◆ loadBuiltin()

void ServerScripting::loadBuiltin ( )

References BUILTIN_MOD_NAME, ScriptApiBase::checkSetByBuiltin(), DIR_DELIM, Server::getBuiltinLuaPath(), and ScriptApiBase::loadMod().

Referenced by Server::init().

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

◆ queueAsync()

u32 ServerScripting::queueAsync ( std::string && serialized_func,
PackedValue * param,
const std::string & mod_origin )

References asyncEngine, and AsyncEngine::queueAsyncJob().

Referenced by ModApiServer::l_do_async_callback().

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

◆ saveGlobals()

void ServerScripting::saveGlobals ( )

References ScriptApiBase::getServer(), Server::m_lua_globals_data, script_pack(), and SCRIPTAPI_PRECHECKHEADER.

Referenced by Server::init().

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

◆ stepAsync()

void ServerScripting::stepAsync ( )

References asyncEngine, ScriptApiBase::getStack(), and AsyncEngine::step().

Referenced by ServerEnvironment::step().

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

Member Data Documentation

◆ asyncEngine

AsyncEngine ServerScripting::asyncEngine
private

Referenced by initAsync(), queueAsync(), and stepAsync().


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