aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_base.h
Commit message (Expand)AuthorAge
* Restructure devtest's unittests and run them in CI (#11859)sfan52021-12-18
* Clean up/improve some scriptapi error handling codesfan52021-09-10
* Async-related script cleanupssfan52021-08-28
* script: Put getGuiEngine() inside a client-only #ifdefsfan52020-04-27
* Modernize lua read (part 2 & 3): C++ templating assurance (#7410)Loïc Blot2018-06-30
* Fix a warning reported by clangLoic Blot2018-03-29
* Add reasons to on_dieplayer and on_hpchangeAndrew Ward2018-03-28
* Change include from "cmake_config.h" to "config.h"Wayward One2018-01-21
* [CSM] Don't load the IO library. (#6087)red-0012018-01-04
* Modernize source code: last part (#6285)Loïc Blot2017-08-20
* C++ modernize: Pragma once (#6264)Loïc Blot2017-08-17
* Cleanup various headers to reduce compilation times (#6255)Loïc Blot2017-08-16
* Create a filesystem abstraction layer for CSM and only allow accessing files ...red-0012017-06-30
* C++11 cleanup on constructors (#6000)Vincent Glize2017-06-19
* Remove threads.h and replace its definitions with their C++11 equivalents (#5...ShadowNinja2017-06-11
* C++11 patchset 6: forbid object copy using assigment/copy function deleters (...Loïc Blot2017-06-10
* Use C++11 mutexes only (remove compat code) (#5922)Loïc Blot2017-06-06
* [CSM] Add event on_place_node API lua (#5548)Vincent Glize2017-04-29
* [CSM] Client side moddingLoic Blot2017-03-13
* Make minetest abort on lua panicRogier2016-12-24
* Add minetest.register_lbm() to run code on block load onlyest312016-03-07
* Fix C++11 compilabilityest312016-01-23
* Fix Lua scripting synchronizationkwolekr2015-11-01
* Fix server crashing on Lua errorsShadowNinja2015-10-31
* Push error handler afresh each time lua_pcall is usedKahrl2015-08-27
* Use numeric indices and raw table access with LUA_REGISTRYINDEXKahrl2015-08-27
* Clean up threadingShadowNinja2015-08-23
* SAPI: Track last executed mod and include in error messageskwolekr2015-08-12
* Improve Script CPP API diagnosticskwolekr2015-08-05
* Fix code style from recent commits and add misc. optimizationskwolekr2015-07-02
* Add Lua errors to error dialogrubenwardy2015-06-29
* Add mod securityShadowNinja2015-05-16
* Fix object reference pushing functions when called from coroutinesShadowNinja2014-10-07
* Only push the Lua error handler onceShadowNinja2014-04-27
* Pass a errfunc to lua_pcall to get a tracebackShadowNinja2013-11-15
* Always use builtin JThread librarykwolekr2013-09-15
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
* Add LuaVoxelManipkwolekr2013-06-27
* Move scriptapi to separate folder (by sapier)sapier2013-05-25
span> ServerEnvironment *env = o->m_env; if(env == NULL) return 0; f32 t = luaL_checknumber(L,2); env->getMap().setNodeTimer(o->m_p,NodeTimer(t,0)); return 0; } int NodeTimerRef::l_stop(lua_State *L) { MAP_LOCK_REQUIRED; NodeTimerRef *o = checkobject(L, 1); ServerEnvironment *env = o->m_env; if(env == NULL) return 0; env->getMap().removeNodeTimer(o->m_p); return 0; } int NodeTimerRef::l_is_started(lua_State *L) { MAP_LOCK_REQUIRED; NodeTimerRef *o = checkobject(L, 1); ServerEnvironment *env = o->m_env; if(env == NULL) return 0; NodeTimer t = env->getMap().getNodeTimer(o->m_p); lua_pushboolean(L,(t.timeout != 0)); return 1; } int NodeTimerRef::l_get_timeout(lua_State *L) { MAP_LOCK_REQUIRED; NodeTimerRef *o = checkobject(L, 1); ServerEnvironment *env = o->m_env; if(env == NULL) return 0; NodeTimer t = env->getMap().getNodeTimer(o->m_p); lua_pushnumber(L,t.timeout); return 1; } int NodeTimerRef::l_get_elapsed(lua_State *L) { MAP_LOCK_REQUIRED; NodeTimerRef *o = checkobject(L, 1); ServerEnvironment *env = o->m_env; if(env == NULL) return 0; NodeTimer t = env->getMap().getNodeTimer(o->m_p); lua_pushnumber(L,t.elapsed); return 1; } NodeTimerRef::NodeTimerRef(v3s16 p, ServerEnvironment *env): m_p(p), m_env(env) { } NodeTimerRef::~NodeTimerRef() { } // Creates an NodeTimerRef and leaves it on top of stack // Not callable from Lua; all references are created on the C side. void NodeTimerRef::create(lua_State *L, v3s16 p, ServerEnvironment *env) { NodeTimerRef *o = new NodeTimerRef(p, env); *(void **)(lua_newuserdata(L, sizeof(void *))) = o; luaL_getmetatable(L, className); lua_setmetatable(L, -2); } void NodeTimerRef::set_null(lua_State *L) { NodeTimerRef *o = checkobject(L, -1); o->m_env = NULL; } void NodeTimerRef::Register(lua_State *L) { lua_newtable(L); int methodtable = lua_gettop(L); luaL_newmetatable(L, className); int metatable = lua_gettop(L); lua_pushliteral(L, "__metatable"); lua_pushvalue(L, methodtable); lua_settable(L, metatable); // hide metatable from Lua getmetatable() lua_pushliteral(L, "__index"); lua_pushvalue(L, methodtable); lua_settable(L, metatable); lua_pushliteral(L, "__gc"); lua_pushcfunction(L, gc_object); lua_settable(L, metatable); lua_pop(L, 1); // drop metatable luaL_openlib(L, 0, methods, 0); // fill methodtable lua_pop(L, 1); // drop methodtable // Cannot be created from Lua //lua_register(L, className, create_object); } const char NodeTimerRef::className[] = "NodeTimerRef"; const luaL_reg NodeTimerRef::methods[] = { luamethod(NodeTimerRef, start), luamethod(NodeTimerRef, set), luamethod(NodeTimerRef, stop), luamethod(NodeTimerRef, is_started), luamethod(NodeTimerRef, get_timeout), luamethod(NodeTimerRef, get_elapsed), {0,0} };