diff options
author | Brandon <brandon@bremaweb.com> | 2014-02-22 14:30:33 -0600 |
---|---|---|
committer | Brandon <brandon@bremaweb.com> | 2014-02-22 14:30:33 -0600 |
commit | 38f06a8df0a8accefedbd1b10e5a22f9ae2b13a2 (patch) | |
tree | f62b40efbbed2cb4b01d1edb59408c14268b3ac5 | |
parent | cd75c51451cc99cc969bb02159076dc3ab9ba69b (diff) |
add time options for who to ban and damage
-rw-r--r-- | config.lua | 9 | ||||
-rw-r--r-- | depends.txt | 2 | ||||
-rw-r--r-- | functions.lua | 9 | ||||
-rw-r--r-- | protection.lua | 8 |
4 files changed, 23 insertions, 5 deletions
@@ -15,7 +15,9 @@ local defaults = { offenseReset = "1440", adminUser = nil, chunkSize = "16", - enableHud = "true" + enableHud = "true", + noBanTime = 240, + noDamageTime = 600 } for k, v in pairs(defaults) do @@ -30,3 +32,8 @@ landrush.config:write() -- These are items that can be dug in unclaimed areas when landrush.config:get_bool("requireClaim") is true landrush.global_dig_list = {["default:ladder"]=true,["default:leaves"]=true,["default:tree"]=true,["default:grass"]=true,["default:grass_1"]=true,["default:grass_2"]=true,["default:grass_3"]=true,["default:grass_4"]=true} +if minetest.get_modpath("whoison") then + landrush.whoison=true +else + landrush.whoison=false +end diff --git a/depends.txt b/depends.txt index 4cfb8a9..1017fca 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,2 @@ -default +whoison? doors
\ No newline at end of file diff --git a/functions.lua b/functions.lua index 92cad80..839c814 100644 --- a/functions.lua +++ b/functions.lua @@ -44,11 +44,18 @@ function landrush.get_owner(pos) end function landrush.get_distance(pos1,pos2) - if ( pos1 ~= nil and pos2 ~= nil ) then return math.abs(math.floor(math.sqrt( (pos1.x - pos2.x)^2 + (pos1.z - pos2.z)^2 ))) else return 0 end +end +function landrush.get_timeonline(name) + -- a wrapper for whoison.getTimeOnline since whoison is an optional dependancy + if ( landrush.whoison == true ) then + return (whoison.getTimeOnline(name) / 60) + else + return -1 + end end diff --git a/protection.lua b/protection.lua index c5b8f9f..7fbb3bf 100644 --- a/protection.lua +++ b/protection.lua @@ -126,10 +126,14 @@ function landrush.protection_violation(pos,name) end minetest.chat_send_player(name, "Area owned by "..tostring(owner).." stop trying to dig here!") - player:set_hp( player:get_hp() - landrush.config:get("offenseDamage") ) + if ( tonumber(landrush.config:get("noDamageTime")) > landrush.get_timeonline(name) ) then + player:set_hp( player:get_hp() - landrush.config:get("offenseDamage") ) + end if ( landrush.config:get_bool("autoBan") == true ) then - landrush.do_autoban(pos,name) + if ( tonumber(landrush.config:get("noBanTime")) > landrush.get_timeonline(name) ) then + landrush.do_autoban(pos,name) + end end end |