Disallow object:remove() if the object is a player
authorKahrl <kahrl@gmx.net>
Mon, 23 Feb 2015 06:48:51 +0000 (16:48 +1000)
committerCraig Robbins <kde.psych@gmail.com>
Mon, 23 Feb 2015 06:49:48 +0000 (16:49 +1000)
Rebased by Zeno- (conflict in lua_api.txt)

doc/lua_api.txt
src/script/lua_api/l_object.cpp

index 1e25fb812dfb4867db3af6e4a7e7e1abda257271..69a3a6828056c35a6919b00445f842d482324b05 100644 (file)
@@ -2294,6 +2294,7 @@ This is basically a reference to a C++ `ServerActiveObject`
 
 #### Methods
 * `remove()`: remove object (after returning from Lua)
+    * Note: Doesn't work on players, use minetest.kick_player instead
 * `getpos()`: returns `{x=num, y=num, z=num}`
 * `setpos(pos)`; `pos`=`{x=num, y=num, z=num}`
 * `moveto(pos, continuous=false)`: interpolated move
index e048d072f8a6d3d203257915a8afa83826369dd0..73f6e93b3ee20ebe2c1d1db9ab56d0b05958ca39 100644 (file)
@@ -131,6 +131,7 @@ int ObjectRef::l_remove(lua_State *L)
        ObjectRef *ref = checkobject(L, 1);
        ServerActiveObject *co = getobject(ref);
        if(co == NULL) return 0;
+       if(co->getType() == ACTIVEOBJECT_TYPE_PLAYER) return 0;
        verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
        co->m_removed = true;
        return 0;