Skip to content

Commit

Permalink
Update settingtypes.txt & Use 0.4.16 API on Newer Servers (#3)
Browse files Browse the repository at this point in the history
* Change setting key "pvp_areas_enable_pvp" to "pvp_areas.enable_pvp"...

...to match other settings format.

* Use Minetest 0.4.16 settings API if available

* Update settingtypes.txt & README.md
  • Loading branch information
AntumDeluge authored and taikedz committed Jul 26, 2018
1 parent 0188945 commit 6e4d66d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Use safemode to make areas be safe zones; otherwise they are killzones by defaul
## Config
in minetest.conf

* `pvp_areas.enable_pvp`
* Allow PvP by default.
* default is `false`, PvP is disabled

* `pvp_areas.safemode`
* safemode = true --> PvP Control areas are safe zones
* default is `false`, making PvP Control areas kill zones
Expand Down
30 changes: 27 additions & 3 deletions init.lua
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,39 @@ 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."
-- The settings object
local settings = {}
if minetest.settings then
settings = minetest.settings
else
--- Function to retrieve a setting value.
--
-- @function settings:get
-- @param setting **string** setting name
-- @return String value of setting
function settings:get(setting)
return minetest.setting_get(setting)
end

--- Function to retrieve a boolean setting value.
--
-- @function settings:get_bool
-- @param setting **string** setting name
-- @return **bool**: True if setting is enabled
function settings:get_bool(setting)
return minetest.setting_getbool(setting)
end
end

local safemode = settings:get_bool("pvp_areas.safemode") or false
local area_label = settings: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")

local pvp_default = minetest.is_yes(minetest.setting_getbool("pvp_areas_enable_pvp"))
local pvp_default = minetest.is_yes(settings:get_bool("pvp_areas.enable_pvp"))
minetest.log("action", "[" .. pvp_areas_modname .. "] PvP by Default: " .. tostring(pvp_default))

local pvp_areas_players = {}
Expand Down
9 changes: 8 additions & 1 deletion settingtypes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Allow PvP by default.
pvp_areas_enable_pvp (PvP by Default) bool false
pvp_areas.enable_pvp (PvP by default) bool false

# When not enabled PvP Control areas are kill zones.
pvp_areas.safemode (PvP Control areas are safe zones) bool false

# 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.
pvp_areas.label (Show PvP area labels) string Defined area.

0 comments on commit 6e4d66d

Please sign in to comment.