mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-05 19:31:04 +00:00
tmp
This commit is contained in:
parent
7935a63ed4
commit
0fb8e1b398
19 changed files with 284 additions and 17 deletions
|
@ -22,5 +22,6 @@ set(client_SCRIPT_CPP_API_SRCS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/s_client_common.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/s_mainmenu.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/s_pause_menu.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/s_sscsm.cpp
|
||||
PARENT_SCOPE)
|
||||
|
||||
|
|
|
@ -43,11 +43,12 @@ extern "C" {
|
|||
|
||||
enum class ScriptingType: u8 {
|
||||
Async, // either mainmenu (client) or ingame (server)
|
||||
Client,
|
||||
Client, // CPCSM
|
||||
MainMenu,
|
||||
Server,
|
||||
Emerge,
|
||||
PauseMenu,
|
||||
SSCSM,
|
||||
};
|
||||
|
||||
class Server;
|
||||
|
@ -58,6 +59,7 @@ class EmergeThread;
|
|||
class IGameDef;
|
||||
class Environment;
|
||||
class GUIEngine;
|
||||
class SSCSMEnvironment;
|
||||
class ServerActiveObject;
|
||||
struct PlayerHPChangeReason;
|
||||
|
||||
|
@ -90,9 +92,9 @@ public:
|
|||
ScriptingType getType() { return m_type; }
|
||||
|
||||
IGameDef *getGameDef() { return m_gamedef; }
|
||||
Server* getServer();
|
||||
Server *getServer();
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
Client* getClient();
|
||||
Client *getClient();
|
||||
#endif
|
||||
|
||||
// IMPORTANT: These cannot be used for any security-related uses, they exist
|
||||
|
@ -158,6 +160,9 @@ protected:
|
|||
#if CHECK_CLIENT_BUILD()
|
||||
GUIEngine* getGuiEngine() { return m_guiengine; }
|
||||
void setGuiEngine(GUIEngine* guiengine) { m_guiengine = guiengine; }
|
||||
|
||||
SSCSMEnvironment *getSSCSMEnv() { return m_sscsm_environment; }
|
||||
void setSSCSMEnv(SSCSMEnvironment *env) { m_sscsm_environment = env; }
|
||||
#endif
|
||||
|
||||
EmergeThread* getEmergeThread() { return m_emerge; }
|
||||
|
@ -178,14 +183,15 @@ protected:
|
|||
private:
|
||||
static int luaPanic(lua_State *L);
|
||||
|
||||
lua_State *m_luastack = nullptr;
|
||||
lua_State *m_luastack = nullptr;
|
||||
|
||||
IGameDef *m_gamedef = nullptr;
|
||||
Environment *m_environment = nullptr;
|
||||
IGameDef *m_gamedef = nullptr;
|
||||
Environment *m_environment = nullptr;
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
GUIEngine *m_guiengine = nullptr;
|
||||
GUIEngine *m_guiengine = nullptr;
|
||||
SSCSMEnvironment *m_sscsm_environment = nullptr;
|
||||
#endif
|
||||
EmergeThread *m_emerge = nullptr;
|
||||
EmergeThread *m_emerge = nullptr;
|
||||
|
||||
ScriptingType m_type;
|
||||
ScriptingType m_type;
|
||||
};
|
||||
|
|
29
src/script/cpp_api/s_sscsm.cpp
Normal file
29
src/script/cpp_api/s_sscsm.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
// SPDX-FileCopyrightText: 2025 Luanti authors
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include "s_sscsm.h"
|
||||
|
||||
#include "s_internal.h"
|
||||
#include "script/sscsm/sscsm_environment.h"
|
||||
|
||||
void ScriptApiSSCSM::load_mods(const std::vector<std::string> &init_paths)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void ScriptApiSSCSM::environment_step(float dtime)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
||||
// Get core.registered_globalsteps
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "registered_globalsteps");
|
||||
// Call callbacks
|
||||
lua_pushnumber(L, dtime);
|
||||
try {
|
||||
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
|
||||
} catch (LuaError &e) {
|
||||
getSSCSMEnv()->setFatalError(e);
|
||||
}
|
||||
}
|
15
src/script/cpp_api/s_sscsm.h
Normal file
15
src/script/cpp_api/s_sscsm.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
// SPDX-FileCopyrightText: 2025 Luanti authors
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpp_api/s_base.h"
|
||||
|
||||
class ScriptApiSSCSM : virtual public ScriptApiBase
|
||||
{
|
||||
public:
|
||||
void load_mods(const std::vector<std::string> &init_paths);
|
||||
|
||||
void environment_step(float dtime);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue