3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "irrlichttypes.h"
31 #include "jthread/jmutex.h"
32 #include "jthread/jmutexautolock.h"
33 #include "common/c_types.h"
34 #include "common/c_internal.h"
36 #define SCRIPTAPI_LOCK_DEBUG
38 #define SCRIPT_MOD_NAME_FIELD "current_mod_name"
39 // MUST be an invalid mod name so that mods can't
40 // use that name to bypass security!
41 #define BUILTIN_MOD_NAME "*builtin*"
47 class ServerActiveObject;
52 virtual ~ScriptApiBase();
54 bool loadMod(const std::string &script_path, const std::string &mod_name);
55 bool loadScript(const std::string &script_path);
58 void addObjectReference(ServerActiveObject *cobj);
59 void removeObjectReference(ServerActiveObject *cobj);
61 Server* getServer() { return m_server; }
66 friend class ObjectRef;
67 friend class NodeMetaRef;
68 friend class ModApiBase;
69 friend class ModApiEnvMod;
70 friend class LuaVoxelManip;
73 { return m_luastack; }
77 void stackDump(std::ostream &o);
79 void setServer(Server* server) { m_server = server; }
81 Environment* getEnv() { return m_environment; }
82 void setEnv(Environment* env) { m_environment = env; }
84 GUIEngine* getGuiEngine() { return m_guiengine; }
85 void setGuiEngine(GUIEngine* guiengine) { m_guiengine = guiengine; }
87 void objectrefGetOrCreate(lua_State *L, ServerActiveObject *cobj);
88 void objectrefGet(lua_State *L, u16 id);
90 JMutex m_luastackmutex;
91 // Stack index of Lua error handler
94 #ifdef SCRIPTAPI_LOCK_DEBUG
99 lua_State* m_luastack;
102 Environment* m_environment;
103 GUIEngine* m_guiengine;
106 #endif /* S_BASE_H_ */