aboutsummaryrefslogtreecommitdiff
path: root/src/activeobject.h
Commit message (Collapse)AuthorAge
* Ignore old entities from 0.3.Novatux2015-02-17
|
* SAO: re-add old ActiveObjectTypes for a future migration layerLoic Blot2015-02-17
|
* SAO work: ActiveObject types & SAO cleanup * Replace u8 types with ↵Loic Blot2015-02-17
| | | | ActiveObjectType. * Merge content_object.h into activeobject.h * Remove DummyLoadSAO, it's now unused. * Remove ItemSAO, it's also unused
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
|
* Add an option to disable object <-> object collision for Lua entitiesPilzAdam2013-07-20
|
* Closed add object <-> object collision handlingsapier2013-03-28
|
* Update Copyright YearsSfan52013-02-24
|
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
|
* Optimize headersPerttu Ahola2012-06-17
|
* Switch the license to be LGPLv2/later, with small parts still remaining as ↵Perttu Ahola2012-06-05
| | | | GPLv2/later, by agreement of major contributors
* Scripting WIPPerttu Ahola2011-11-29
|
* reorganized a lot of stuff and modified mapgen and objects slightly while ↵Perttu Ahola2011-06-26
| | | | doing it
* Some work-in-progress in hp and mobs and a frightening amount of random fixes.Perttu Ahola2011-04-21
|
* items now fall by gravity... also some other random updatingPerttu Ahola2011-04-10
|
* Some progress on transitioning from MapBlockObject to ActiveObject.Perttu Ahola2011-04-08
|
* Removed lua stuffPerttu Ahola2011-04-03
|
* Temporary commit; lots of test code and stuffPerttu Ahola2011-02-21
">*ud = luaL_checkudata(L, narg, className); if(!ud) luaL_typerror(L, narg, className); return *(NodeTimerRef**)ud; // unbox pointer } int NodeTimerRef::l_set(lua_State *L) { NodeTimerRef *o = checkobject(L, 1); ServerEnvironment *env = o->m_env; if(env == NULL) return 0; f32 t = luaL_checknumber(L,2); f32 e = luaL_checknumber(L,3); env->getMap().setNodeTimer(o->m_p,NodeTimer(t,e)); return 0; } int NodeTimerRef::l_start(lua_State *L) { NodeTimerRef *o = checkobject(L, 1); 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) { 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) { 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) { 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) { 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} };