Skip to content

Commit 38cf080

Browse files
kahrlZeno-
authored andcommittedFeb 23, 2015
Disallow object:remove() if the object is a player
Rebased by Zeno- (conflict in lua_api.txt)
1 parent cd4324e commit 38cf080

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed
 

‎doc/lua_api.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,7 @@ This is basically a reference to a C++ `ServerActiveObject`
22942294

22952295
#### Methods
22962296
* `remove()`: remove object (after returning from Lua)
2297+
* Note: Doesn't work on players, use minetest.kick_player instead
22972298
* `getpos()`: returns `{x=num, y=num, z=num}`
22982299
* `setpos(pos)`; `pos`=`{x=num, y=num, z=num}`
22992300
* `moveto(pos, continuous=false)`: interpolated move

‎src/script/lua_api/l_object.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ int ObjectRef::l_remove(lua_State *L)
131131
ObjectRef *ref = checkobject(L, 1);
132132
ServerActiveObject *co = getobject(ref);
133133
if(co == NULL) return 0;
134+
if(co->getType() == ACTIVEOBJECT_TYPE_PLAYER) return 0;
134135
verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
135136
co->m_removed = true;
136137
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.