summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rwxr-xr-xinit.lua28
2 files changed, 26 insertions, 3 deletions
diff --git a/README.md b/README.md
index fc6ffc3..c61faf5 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,7 @@ Sets an area for PvP control.
Use safemode to make areas be safe zones; otherwise they are killzones by default.
## Config
+in minetest.conf
* `pvp_areas.safemode`
* safemode = true --> PvP Control areas are safe zones
diff --git a/init.lua b/init.lua
index c89a905..9e833f7 100755
--- a/init.lua
+++ b/init.lua
@@ -8,8 +8,10 @@ local pvp_areas_modname = minetest.get_current_modname()
local hasareasmod = minetest.get_modpath("areas")
-local safemode = minetest.setting_getbool("pvp_areas.safemode")
+local safemode = minetest.setting_getbool("pvp_areas.safemode") or false
local area_label = minetest.setting_get("pvp_areas.label") or "Defined area."
+-- if false Mob does Damage
+local mobsDoNoDamage = false
local pvp_areas_store = AreaStore()
pvp_areas_store:from_file(pvp_areas_worlddir .. "/pvp_areas_store.dat")
@@ -112,19 +114,39 @@ local KILL_OK = false
local AREA_ACTIVATE = KILL_OK
local AREA_NOACTIVATE = KILL_NO
+local savemodeToString = "FALSCH" -- only for debugging
if safemode then
AREA_ACTIVATE = KILL_NO
AREA_NOACTIVATE = KILL_OK
+ savemodeToString = "WAHR"
end
-- Register punchplayer callback.
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
+ local isPlayer = hitter:is_player()
+
+ if hitter:is_player() == false then
+ return mobsDoNoDamage -- if this is a MOB then give Damage
+ end
+ --[[
+ local IsPlayerToString = "PLAYER" -- only for debugging
+ if isplayer then
+ IsPlayerToString = "PLAYER" -- only for debugging
+ else
+ IsPlayerToString = "MOB" -- only for debugging
+ return mobsDoNoDamage -- if this is a MOB then give Damage
+ end
+ ]]--
+
+ local playername = player:get_player_name()
for k, v in pairs(pvp_areas_store:get_areas_for_pos(player:getpos())) do
if k then
- return KILL_NO
+ --minetest.chat_send_player(playername, "in loop - safemode"..savemodeToString.." isPlayer "..IsPlayerToString)
+ return AREA_ACTIVATE --KILL_NO
end
end
- return KILL_OK
+ --minetest.chat_send_player(playername, "after - safemode"..savemodeToString.." isPlayer "..IsPlayerToString)
+ return AREA_NOACTIVATE --KILL_OK
end)
if hasareasmod then