Skip to content

Commit 008d7e0

Browse files
committedMar 22, 2015
Revert "Add a Lua call to do damages / heals" ok @ShadowNinja
This reverts commit 467fc0d.
1 parent 61f2d0c commit 008d7e0

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed
 

Diff for: ‎doc/lua_api.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,6 @@ This is basically a reference to a C++ `ServerActiveObject`
23362336
* `right_click(clicker)`; `clicker` is another `ObjectRef`
23372337
* `get_hp()`: returns number of hitpoints (2 * number of hearts)
23382338
* `set_hp(hp)`: set number of hitpoints (2 * number of hearts)
2339-
* `apply_damage(damage)`: set amount of damage to object. If damage < 0, heal the target
23402339
* `get_inventory()`: returns an `InvRef`
23412340
* `get_wield_list()`: returns the name of the inventory list the wielded item is in
23422341
* `get_wield_index()`: returns the index of the wielded item

Diff for: ‎src/script/lua_api/l_object.cpp

+3-38
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2929
#include "content_sao.h"
3030
#include "server.h"
3131
#include "hud.h"
32-
#include "settings.h"
33-
#include "main.h"
3432

3533

3634
struct EnumString es_HudElementType[] =
@@ -257,10 +255,10 @@ int ObjectRef::l_set_hp(lua_State *L)
257255
ObjectRef *ref = checkobject(L, 1);
258256
luaL_checknumber(L, 2);
259257
ServerActiveObject *co = getobject(ref);
260-
if(co == NULL)
261-
return 0;
258+
if(co == NULL) return 0;
262259
int hp = lua_tonumber(L, 2);
263-
260+
/*infostream<<"ObjectRef::l_set_hp(): id="<<co->getId()
261+
<<" hp="<<hp<<std::endl;*/
264262
// Do it
265263
co->setHP(hp);
266264
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
@@ -291,38 +289,6 @@ int ObjectRef::l_get_hp(lua_State *L)
291289
return 1;
292290
}
293291

294-
// apply_damage(self, damage)
295-
// damage = amount of damage to apply
296-
// if damage is negative, heal the player
297-
// returns: nil
298-
int ObjectRef::l_apply_damage(lua_State *L)
299-
{
300-
NO_MAP_LOCK_REQUIRED;
301-
ObjectRef *ref = checkobject(L, 1);
302-
luaL_checknumber(L, 2);
303-
ServerActiveObject *co = getobject(ref);
304-
if(co == NULL)
305-
return 0;
306-
307-
int damage = lua_tonumber(L, 2);
308-
309-
// No damage, no heal => do nothing
310-
if (damage == 0)
311-
return 0;
312-
313-
// If damage is positive (not healing) and damage is disabled, ignore
314-
if (damage > 0 && g_settings->getBool("enable_damage") == false)
315-
return 0;
316-
317-
// Do damage/heal
318-
co->setHP(co->getHP() - damage);
319-
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
320-
getServer(L)->SendPlayerHPOrDie(((PlayerSAO*)co)->getPeerID(), co->getHP() == 0);
321-
}
322-
323-
return 0;
324-
}
325-
326292
// get_inventory(self)
327293
int ObjectRef::l_get_inventory(lua_State *L)
328294
{
@@ -1379,7 +1345,6 @@ const luaL_reg ObjectRef::methods[] = {
13791345
luamethod(ObjectRef, right_click),
13801346
luamethod(ObjectRef, set_hp),
13811347
luamethod(ObjectRef, get_hp),
1382-
luamethod(ObjectRef, apply_damage),
13831348
luamethod(ObjectRef, get_inventory),
13841349
luamethod(ObjectRef, get_wield_list),
13851350
luamethod(ObjectRef, get_wield_index),

Diff for: ‎src/script/lua_api/l_object.h

-6
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ class ObjectRef : public ModApiBase {
8383
// 0 if not applicable to this type of object
8484
static int l_get_hp(lua_State *L);
8585

86-
// apply_damage(self, damage)
87-
// damage = amount of damage to apply
88-
// if damage is negative, heal the player
89-
// returns: nil
90-
static int l_apply_damage(lua_State *L);
91-
9286
// get_inventory(self)
9387
static int l_get_inventory(lua_State *L);
9488

0 commit comments

Comments
 (0)
Please sign in to comment.