78 lines
3.0 KiB
Diff
78 lines
3.0 KiB
Diff
diff --git a/hud.lua b/hud.lua
|
|
index bff0dd4..4ed006a 100644
|
|
--- a/hud.lua
|
|
+++ b/hud.lua
|
|
@@ -78,4 +78,11 @@ minetest.register_on_joinplayer(function(player)
|
|
|
|
end)
|
|
|
|
+minetest.register_on_dieplayer(function(player)
|
|
+ if not player then return end
|
|
+ if water_life.poison_after_death then return end
|
|
|
|
+ local meta=player:get_meta()
|
|
+ meta:set_int("snakepoison",0)
|
|
+ water_life.change_hud(player,"poison",0)
|
|
+end)
|
|
diff --git a/init.lua b/init.lua
|
|
index f92c3c3..97833b3 100644
|
|
--- a/init.lua
|
|
+++ b/init.lua
|
|
@@ -31,6 +31,7 @@ water_life.moskitolifetime = tonumber(minetest.settings:get("water_life_moskitol
|
|
water_life.radar_debug = minetest.settings:get_bool("water_life_radar_debug") or false
|
|
water_life.muddy_water = minetest.settings:get_bool("water_life_muddy_water") or false
|
|
water_life.repeltime = math.floor (720 / (tonumber(minetest.settings:get("time_speed")) or 72)*60) -- the repellent lasts half a minetest day
|
|
+water_life.poison_after_death = minetest.settings:get_bool("water_life_poison_after_death") or false
|
|
|
|
local path = minetest.get_modpath(minetest.get_current_modname())
|
|
|
|
diff --git a/settingtypes.txt b/settingtypes.txt
|
|
index 24bb049..4eb03f3 100644
|
|
--- a/settingtypes.txt
|
|
+++ b/settingtypes.txt
|
|
@@ -62,3 +62,7 @@ water_life_muddy_water (muddy water in rainforest and savanna biome) bool false
|
|
#-
|
|
# turn this value to true to see api function debug
|
|
water_life_radar_debug (api function debug shown in chat) bool false
|
|
+
|
|
+#
|
|
+# Turn this Value to true, if you want poison to persist after death
|
|
+water_life_poison_after_death (Poison stays after death) bool false
|
|
diff --git a/spawn.lua b/spawn.lua
|
|
index e6cef07..d2653f9 100644
|
|
--- a/spawn.lua
|
|
+++ b/spawn.lua
|
|
@@ -35,8 +35,25 @@ local function spawnstep(dtime)
|
|
|
|
|
|
if meta:get_int("snakepoison") > 0 then
|
|
- local score = plyr:get_hp()
|
|
- plyr:set_hp(score-1)
|
|
+ --local score = plyr:get_hp()
|
|
+ --plyr:set_hp(score-1)
|
|
+ poison_value = 1 --defautl poison value
|
|
+ local pl_name=plyr:get_player_name() -- player name
|
|
+ local hunger_ng_infos = hunger_ng.get_hunger_information(pl_name) -- information from hunger_ng
|
|
+ --minetest.log(dump(hunger_ng_infos))
|
|
+ local hunger_ng_interoper = hunger_ng.interoperability
|
|
+ --minetest.log(dump(hunger_ng_interoper))
|
|
+ -- if healing is enabled, then add healing to poison value
|
|
+ -- if the same you have the chance to survive if you stay satiated
|
|
+ if hunger_ng_infos.effects.healing then
|
|
+ poison_value = ((waterinterval/hunger_ng_interoper.settings.timers.heal)*hunger_ng_interoper.effects.heal.amount) + 0.1 --+ poison_value -- if you want decrease healt even with healing
|
|
+ end
|
|
+ --minetest.log("Poison: "..dump(poison_value))
|
|
+
|
|
+ local score = plyr:get_hp()-poison_value
|
|
+ --if score < 0 then score = 0 end
|
|
+ --minetest.log("Health: "..dump(score))
|
|
+ plyr:set_hp(score)
|
|
end
|
|
|
|
if meta:get_int("repellant") > 0 then
|
|
@@ -378,4 +395,3 @@ end
|
|
|
|
|
|
minetest.register_globalstep(spawnstep)
|
|
-
|