diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | LICENSE.txt | 0 | ||||
-rw-r--r-- | README.md | 33 | ||||
-rw-r--r-- | depends.txt | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | init.lua | 61 | ||||
-rwxr-xr-x[-rw-r--r--] | mod.conf | 0 |
6 files changed, 76 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/LICENSE.txt b/LICENSE.txt index 4362b49..4362b49 100644..100755 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,28 @@ -/pvp_areas without arguments lists areas, if any. -/pvp_areas pos1 selects the players current position as the area minimum. -/pvp_areas pos2 selects the players current position as the area maximum. -/pvp_areas set adds an entry using pos1 and pos2 values. -/pvp_areas remove n removes an area entry. +# PvP Areas + +Sets an area for PvP control. + +Use safemode to make areas be safe zones; otherwise they are killzones by default. + +## Config + +* `pvp_areas.safemode` + * safemode = true --> PvP Control areas are safe zones + * default is `false`, making PvP Control areas kill zones + +* `pvp_areas.label` + * if ShadowNinja's `areas` mod is also present with HUD registration feature, this label will be displayed anywhere + a PvP Control area has been set. + +## Commands + +* `/pvp_areas` + * without arguments lists areas, if any. +* `/pvp_areas pos1` + * selects the players current position as the area minimum. +* `/pvp_areas pos2` + * selects the players current position as the area maximum. +* `/pvp_areas set` + * adds an entry using pos1 and pos2 values. +* `/pvp_areas remove n` + * removes an area entry. diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..923677c --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +areas? @@ -1,10 +1,16 @@ -- pvp_areas --- Copyright 2016 James Stevenson (everamzah) +-- Original : Copyright 2016 James Stevenson (everamzah) +-- Additional : Copyright Tai Kedzierski (DuCake) -- LGPL v2.1+ local pvp_areas_worlddir = minetest.get_worldpath() local pvp_areas_modname = minetest.get_current_modname() +local hasareasmod = minetest.get_modpath("areas") + +local safemode = minetest.setting_getbool("pvp_areas.safemode") or false +local area_label = minetest.setting_get("pvp_areas.label") or "Defined area." + local pvp_areas_store = AreaStore() pvp_areas_store:from_file(pvp_areas_worlddir .. "/pvp_areas_store.dat") @@ -28,6 +34,13 @@ local function save_pvp_areas() pvp_areas_store:to_file(pvp_areas_worlddir .. "/pvp_areas_store.dat") end +local function areas_entity(pos,num) + if hasareasmod then + local obj = minetest.add_entity(pos, "areas:pos"..tostring(num)) + local ent = obj:get_luaentity() + ent.active = true + end +end -- Register privilege and chat command. minetest.register_privilege("pvp_areas_admin", "Can set and remove PvP areas.") @@ -93,26 +106,44 @@ minetest.register_chatcommand("pvp_areas", { end }) +local KILL_NO = true +local KILL_OK = false + +local AREA_ACTIVATE = KILL_OK +local AREA_NOACTIVATE = KILL_NO + +if safemode then + AREA_ACTIVATE = KILL_NO + AREA_NOACTIVATE = KILL_OK +end + -- Register punchplayer callback. minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) - if damage < 1 then - return false - end - for k, v in pairs(pvp_areas_store:get_areas_for_pos(player:getpos())) do if k then - if pvp_default then - return true - else - return false - end + return KILL_NO end end + return KILL_OK +end) + +if hasareasmod then + if areas.registerHudHandler then + + local function advertise_nokillzone(pos, list) + for k, v in pairs(pvp_areas_store:get_areas_for_pos(pos)) do + if k then + table.insert(list, { + id = "PvP Control Area "..tostring(k), + name = area_label, + } ) + return + end + end + end - -- player is not in a pvp_areas_store area. - if pvp_default then - return false + areas:registerHudHandler(advertise_nokillzone) else - return true + minetest.log("info","Your version of `areas` does not support registering hud handlers.") end -end) +end |