Update simple_protection mod to Git commit f1f85aa...

https://github.com/SmallJoker/simple_protection/tree/f1f85aa
master
Jordan Irwin 2021-07-20 18:05:00 -07:00
parent 7b180f0c97
commit f8a653eefe
15 changed files with 331 additions and 366 deletions

View File

@ -123,7 +123,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* [wardrobe][] ([MIT][lic.wardrobe]) -- version: [0500a78 Git][ver.wardrobe] *2021-06-08*
* protection/
* [pvp_areas][] ([LGPL][lic.lgpl2.1]) -- version: [6e4d66d Git][ver.pvp_areas] *2018-07-26*
* [simple_protection][] ([CC0][lic.cc0]) -- version: [3630fe9 Git][ver.simple_protection] *2021-04-07* ([patched][patch.simple_protection])
* [simple_protection][] ([CC0][lic.cc0]) -- version: [f1f85aa Git][ver.simple_protection] *2021-07-18* ([patched][patch.simple_protection])
* storage/
* [drawers][] ([MIT / CC0 / CC BY][lic.drawers]) -- version: [0.6.2][ver.drawers] *2021-03-27*
* [more_chests][] ([GPL][lic.gpl2.0]) -- version: [6be8145 Git][ver.more_chests] *2021-04-05*
@ -666,7 +666,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.sfinv]: https://github.com/rubenwardy/sfinv/tree/556f70e
[ver.sfinv_buttons]: http://repo.or.cz/minetest_sfinv_buttons.git/tree/ebb1f7c
[ver.signs_lib]: https://gitlab.com/VanessaE/signs_lib/tree/2021-03-04-2
[ver.simple_protection]: https://github.com/SmallJoker/simple_protection/tree/3630fe9
[ver.simple_protection]: https://github.com/SmallJoker/simple_protection/tree/f1f85aa
[ver.slingshot]: https://github.com/AntumMT/mod-slingshot/releases/tag/v0.3
[ver.sneeker]: https://github.com/AntumMT/mod-sneeker/releases/tag/v1.1
[ver.snowdrift]: https://github.com/paramat/snowdrift/tree/3342939

View File

@ -1,4 +1,5 @@
local S = s_protect.translator
local sp = simple_protection
local S = sp.translator
-- A shared chest for simple_protection but works with other protection mods too

View File

@ -1,8 +1,9 @@
local S = s_protect.translator
local sp = simple_protection
local S = sp.translator
local commands = {}
function s_protect.register_subcommand(name, func)
function sp.register_subcommand(name, func)
if commands[name] then
minetest.log("info", "[simple_protection] Overwriting chat command " .. name)
end
@ -19,23 +20,23 @@ minetest.register_chatcommand("area", {
func = function(name, param)
if param == "" or param == "help" then
local function chat_send(desc, cmd)
minetest.chat_send_player(name, S(desc) .. ": "
minetest.chat_send_player(name, desc .. ": "
.. minetest.colorize("#0FF", cmd))
end
local privs = minetest.get_player_privs(name)
minetest.chat_send_player(name, minetest.colorize("#0F0",
"=> " .. S("Available area commands")))
chat_send("Information about this area", "/area show")
chat_send("View of surrounding areas", "/area radar")
chat_send("(Un)share one area", "/area (un)share <name>")
chat_send("(Un)share all areas", "/area (un)shareall <name>")
if s_protect.area_list or privs.simple_protection then
chat_send("List claimed areas", "/area list [<name>]")
chat_send(S("Information about this area"), "/area show")
chat_send(S("View of surrounding areas"), "/area radar")
chat_send(S("(Un)share one area"), "/area (un)share <name>")
chat_send(S("(Un)share all areas"), "/area (un)shareall <name>")
if sp.area_list or privs.simple_protection then
chat_send(S("List claimed areas"), "/area list [<name>]")
end
chat_send("Unclaim this area", "/area unclaim")
chat_send(S("Unclaim this area"), "/area unclaim")
if privs.server then
chat_send("Delete all areas of a player", "/area delete <name>")
chat_send(S("Delete all areas of a player"), "/area delete <name>")
end
return
end
@ -50,18 +51,18 @@ minetest.register_chatcommand("area", {
end,
})
s_protect.register_subcommand("show", function(name, param)
sp.register_subcommand("show", function(name, param)
local player = minetest.get_player_by_name(name)
local player_pos = player:get_pos()
local data = s_protect.get_claim(player_pos)
local data = sp.get_claim(player_pos)
minetest.add_entity(s_protect.get_center(player_pos), "simple_protection:marker")
local minp, maxp = s_protect.get_area_bounds(player_pos)
minetest.add_entity(sp.get_center(player_pos), "simple_protection:marker")
local minp, maxp = sp.get_area_bounds(player_pos)
minetest.chat_send_player(name, S("Vertical from Y @1 to @2",
tostring(minp.y), tostring(maxp.y)))
if not data then
if s_protect.underground_limit and minp.y < s_protect.underground_limit then
if sp.underground_limit and minp.y < sp.underground_limit then
return true, S("Area status: @1", S("Not claimable"))
end
return true, S("Area status: @1", S("Unowned (!)"))
@ -72,7 +73,7 @@ s_protect.register_subcommand("show", function(name, param)
for i, player in ipairs(data.shared) do
text = text..player..", "
end
local shared = s_protect.share[data.owner]
local shared = sp.share[data.owner]
if shared then
for i, player in ipairs(shared) do
text = text..player.."*, "
@ -86,7 +87,7 @@ end)
local function check_ownership(name)
local player = minetest.get_player_by_name(name)
local data, index = s_protect.get_claim(player:get_pos())
local data, index = sp.get_claim(player:get_pos())
if not data then
return false, S("This area is not claimed yet.")
end
@ -111,7 +112,7 @@ local function table_erase(t, e)
return removed
end
s_protect.register_subcommand("share", function(name, param)
sp.register_subcommand("share", function(name, param)
if not param or name == param then
return false, S("No player name given.")
end
@ -123,15 +124,15 @@ s_protect.register_subcommand("share", function(name, param)
return success, data
end
if s_protect.is_shared(name, param) then
if sp.is_shared(name, param) then
return true, S("@1 already has access to all your areas.", param)
end
if s_protect.is_shared(data, param) then
if sp.is_shared(data, param) then
return true, S("@1 already has access to this area.", param)
end
table.insert(data.shared, param)
s_protect.set_claim(data, index)
sp.set_claim(data, index)
if minetest.get_player_by_name(param) then
minetest.chat_send_player(param, S("@1 shared an area with you.", name))
@ -139,7 +140,7 @@ s_protect.register_subcommand("share", function(name, param)
return true, S("@1 has now access to this area.", param)
end)
s_protect.register_subcommand("unshare", function(name, param)
sp.register_subcommand("unshare", function(name, param)
if not param or name == param or param == "" then
return false, S("No player name given.")
end
@ -147,11 +148,11 @@ s_protect.register_subcommand("unshare", function(name, param)
if not success then
return success, data
end
if not s_protect.is_shared(data, param) then
if not sp.is_shared(data, param) then
return true, S("That player has no access to this area.")
end
table_erase(data.shared, param)
s_protect.set_claim(data, index)
sp.set_claim(data, index)
if minetest.get_player_by_name(param) then
minetest.chat_send_player(param, S("@1 unshared an area with you.", name))
@ -159,7 +160,7 @@ s_protect.register_subcommand("unshare", function(name, param)
return true, S("@1 has no longer access to this area.", param)
end)
s_protect.register_subcommand("shareall", function(name, param)
sp.register_subcommand("shareall", function(name, param)
if not param or name == param or param == "" then
return false, S("No player name given.")
end
@ -170,14 +171,14 @@ s_protect.register_subcommand("shareall", function(name, param)
return false, S("Unknown player.")
end
if s_protect.is_shared(name, param) then
if sp.is_shared(name, param) then
return true, S("@1 already has now access to all your areas.", param)
end
if not shared then
s_protect.share[name] = {}
sp.share[name] = {}
end
table.insert(s_protect.share[name], param)
s_protect.save_share_db()
table.insert(sp.share[name], param)
sp.save_share_db()
if minetest.get_player_by_name(param) then
minetest.chat_send_player(param, S("@1 shared all areas with you.", name))
@ -185,19 +186,19 @@ s_protect.register_subcommand("shareall", function(name, param)
return true, S("@1 has now access to all your areas.", param)
end)
s_protect.register_subcommand("unshareall", function(name, param)
sp.register_subcommand("unshareall", function(name, param)
if not param or name == param or param == "" then
return false, S("No player name given.")
end
local removed = false
local shared = s_protect.share[name]
local shared = sp.share[name]
if table_erase(shared, param) then
removed = true
s_protect.save_share_db()
sp.save_share_db()
end
-- Unshare each single claim
local claims = s_protect.get_player_claims(name)
local claims = sp.get_player_claims(name)
for index, data in pairs(claims) do
if table_erase(data.shared, param) then
removed = true
@ -206,30 +207,30 @@ s_protect.register_subcommand("unshareall", function(name, param)
if not removed then
return false, S("@1 does not have access to any of your areas.", param)
end
s_protect.update_claims(claims)
sp.update_claims(claims)
if minetest.get_player_by_name(param) then
minetest.chat_send_player(param, S("@1 unshared all areas with you.", name))
end
return true, S("@1 has no longer access to your areas.", param)
end)
s_protect.register_subcommand("unclaim", function(name)
sp.register_subcommand("unclaim", function(name)
local success, data, index = check_ownership(name)
if not success then
return success, data
end
if s_protect.claim_return and name == data.owner then
if sp.claim_return and name == data.owner then
local player = minetest.get_player_by_name(name)
local inv = player:get_inventory()
if inv:room_for_item("main", "simple_protection:claim") then
inv:add_item("main", "simple_protection:claim")
end
end
s_protect.set_claim(nil, index)
sp.set_claim(nil, index)
return true, S("This area is unowned now.")
end)
s_protect.register_subcommand("delete", function(name, param)
sp.register_subcommand("delete", function(name, param)
if not param or name == param or param == "" then
return false, S("No player name given.")
end
@ -238,18 +239,18 @@ s_protect.register_subcommand("delete", function(name, param)
end
local removed = {}
if s_protect.share[param] then
s_protect.share[param] = nil
if sp.share[param] then
sp.share[param] = nil
table.insert(removed, S("Globally shared areas"))
s_protect.save_share_db()
sp.save_share_db()
end
-- Delete all claims
local claims, count = s_protect.get_player_claims(param)
local claims, count = sp.get_player_claims(param)
for index in pairs(claims) do
claims[index] = false
end
s_protect.update_claims(claims)
sp.update_claims(claims)
if count > 0 then
table.insert(removed, S("@1 claimed area(s)", tostring(count)))
@ -261,9 +262,9 @@ s_protect.register_subcommand("delete", function(name, param)
return true, S("Removed")..": "..table.concat(removed, ", ")
end)
s_protect.register_subcommand("list", function(name, param)
sp.register_subcommand("list", function(name, param)
local has_sp_priv = minetest.check_player_privs(name, {simple_protection=true})
if not s_protect.area_list and not has_sp_priv then
if not sp.area_list and not has_sp_priv then
return false, S("This command is not available.")
end
if not param or param == "" then
@ -274,16 +275,16 @@ s_protect.register_subcommand("list", function(name, param)
end
local list = {}
local width = s_protect.claim_size
local height = s_protect.claim_height
local width = sp.claim_size
local height = sp.claim_height
local claims = s_protect.get_player_claims(param)
local claims = sp.get_player_claims(param)
for index in pairs(claims) do
-- TODO: Add database-specific function to convert the index to a position
local abs_pos = minetest.string_to_pos(index)
table.insert(list, string.format("%5i,%5i,%5i",
abs_pos.x * width + (width / 2),
abs_pos.y * height - s_protect.start_underground + (height / 2),
abs_pos.y * height - sp.start_underground + (height / 2),
abs_pos.z * width + (width / 2)
))
end

View File

@ -10,6 +10,8 @@ lSQLite database functions:
update_claims(claims table)
]]
error("lSqlite backend is incomplete")
local worldpath = minetest.get_worldpath()
local ie = minetest.request_insecure_environment()

View File

@ -11,14 +11,13 @@ Raw text format database functions:
]]
local claim_data = {}
local claim_db = { time = os.time(), dirty = false }
local share_db = { time = os.time(), dirty = false }
local sp = simple_protection
function s_protect.load_db()
function sp.load_db()
-- Don't forget the "parties"
s_protect.load_shareall()
sp.load_shareall()
local file = io.open(s_protect.file, "r")
local file = io.open(sp.file, "r")
if not file then
return
end
@ -39,8 +38,8 @@ function s_protect.load_db()
minetest.log("action", "[simple_protection] Loaded claim data")
end
function s_protect.load_shareall()
local file = io.open(s_protect.sharefile, "r")
function sp.load_shareall()
local file = io.open(sp.sharefile, "r")
if not file then
return
end
@ -55,7 +54,7 @@ function s_protect.load_shareall()
table.insert(_shared, data[index])
end
end
s_protect.share[data[1]] = _shared
sp.share[data[1]] = _shared
end
end
end
@ -63,6 +62,9 @@ function s_protect.load_shareall()
minetest.log("action", "[simple_protection] Loaded shared claims")
end
local claim_db = { time = os.time(), dirty = false }
local share_db = { time = os.time(), dirty = false }
local function delay(db_info, func)
local dtime = os.time() - db_info.time
if dtime < 6 then
@ -90,28 +92,28 @@ local function save_claims()
table.concat(data.shared, " ")
end
end
minetest.safe_file_write(s_protect.file, table.concat(contents, "\n"))
minetest.safe_file_write(sp.file, table.concat(contents, "\n"))
end
function s_protect.save_share_db()
if delay(share_db, s_protect.save_share_db) then
function sp.save_share_db()
if delay(share_db, sp.save_share_db) then
return
end
-- Save globally shared areas
local contents = {}
for name, players in pairs(s_protect.share) do
for name, players in pairs(sp.share) do
if #players > 0 then
contents[#contents + 1] = name .. " " ..
table.concat(players, " ")
end
end
minetest.safe_file_write(s_protect.sharefile, table.concat(contents, "\n"))
minetest.safe_file_write(sp.sharefile, table.concat(contents, "\n"))
end
-- Speed up the function access
local get_location = s_protect.get_location
function s_protect.get_claim(pos, direct_access)
local get_location = sp.get_location
function sp.get_claim(pos, direct_access)
if direct_access then
return claim_data[pos], pos
end
@ -120,12 +122,12 @@ function s_protect.get_claim(pos, direct_access)
return claim_data[index], index
end
function s_protect.set_claim(data, index)
function sp.set_claim(data, index)
claim_data[index] = data
save_claims()
end
function s_protect.get_player_claims(owner)
function sp.get_player_claims(owner)
local count = 0
local claims = {}
for index, data in pairs(claim_data) do
@ -137,7 +139,7 @@ function s_protect.get_player_claims(owner)
return claims, count
end
function s_protect.update_claims(updated)
function sp.update_claims(updated)
for index, data in pairs(updated) do
if not data then
claim_data[index] = nil
@ -156,12 +158,12 @@ local function table_contains(t, to_find)
end
return false
end
function s_protect.is_shared(id, player_name)
function sp.is_shared(id, player_name)
if type(id) == "table" and id.shared then
-- by area
return table_contains(id.shared, player_name)
end
assert(type(id) == "string", "is_shared(): Either ClaimData or string expected")
-- by owner
return table_contains(s_protect.share[id] or {}, player_name)
return table_contains(sp.share[id] or {}, player_name)
end

View File

@ -12,42 +12,43 @@ simple_protection/default_settings.lua
unwanted side effects when claims were made.
]]
local sp = simple_protection
-- Width and length of claims in nodes
-- !! Distorts the claim locations along the X and Z axis !!
-- Type: Integer, positive, even number
s_protect.claim_size = 16
sp.claim_size = 16
-- Height of claims in nodes
-- !! Distorts the claim locations along the Y axis !!
-- Type: Integer, positive
s_protect.claim_height = 150
sp.claim_height = 150
-- Defines the Y offset where the 0th claim should start in the underground
-- Example of claim (0,0,0): Ymin = -(50) = -50, Ymax = 150 - (50) - 1 = 99
-- Type: Integer
s_protect.start_underground = 50
sp.start_underground = 50
-- Only allows claiming above this Y value
-- To disable this limit, set the value to 'nil'
-- Type: Integer or nil
s_protect.underground_limit = -300
sp.underground_limit = -300
-- Returns the claim stick when unclaiming the area
-- Type: Boolean
s_protect.claim_return = true
sp.claim_return = true
-- Players will need to claim the area (or have access to it) to dig
-- Digging will be still allowed in the underground,
-- as defined by the setting 's_protect.underground_limit'
-- as defined by the setting 'simple_protection.underground_limit'
-- Type: Boolean
s_protect.claim_to_dig = false
sp.claim_to_dig = false
-- Allows players to list their areas using '/area list'
-- Type: Boolean
s_protect.area_list = true
sp.area_list = true
-- Limits the amount of claims per player
-- Doubled limit for players with the 'simple_protection' privilege
-- Type: Integer
s_protect.max_claims = 200
sp.max_claims = 200

View File

@ -6,16 +6,19 @@ HUD display and refreshing
]]
local S = s_protect.translator
local sp = simple_protection
local S = sp.translator
s_protect.player_huds = {}
sp.player_huds = {}
local hud_time = 0
local hud_timer = 0
-- Text to put in front of the HUD element
local prefix = ""
-- HUD default position
local align_x = 1
local pos_x = 0.02
-- If areas is installed: Move the HUD to th opposite side
-- If areas is installed: Move the HUD to the opposite side
if minetest.get_modpath("areas") then
prefix = "Simple Protection:\n"
align_x = -1
@ -28,7 +31,7 @@ local function generate_hud(player, current_owner, has_access)
if has_access then
color = 0x00CC00
end
s_protect.player_huds[player:get_player_name()] = {
sp.player_huds[player:get_player_name()] = {
hud_id = player:hud_add({
hud_elem_type = "text",
name = "area_hud",
@ -45,18 +48,18 @@ local function generate_hud(player, current_owner, has_access)
end
minetest.register_globalstep(function(dtime)
hud_time = hud_time + dtime
if hud_time < 2.9 then
hud_timer = hud_timer + dtime
if hud_timer < 2.9 then
return
end
hud_time = 0
hud_timer = 0
local is_shared = s_protect.is_shared
local is_shared = sp.is_shared
for _, player in ipairs(minetest.get_connected_players()) do
local player_name = player:get_player_name()
local current_owner = ""
local data = s_protect.get_claim(player:get_pos())
local data = sp.get_claim(player:get_pos())
if data then
current_owner = data.owner
end
@ -72,7 +75,7 @@ minetest.register_globalstep(function(dtime)
end
local changed = true
local hud_table = s_protect.player_huds[player_name]
local hud_table = sp.player_huds[player_name]
if hud_table and hud_table.owner == current_owner
and hud_table.had_access == has_access then
-- still the same hud
@ -81,7 +84,7 @@ minetest.register_globalstep(function(dtime)
if changed and hud_table then
player:hud_remove(hud_table.hud_id)
s_protect.player_huds[player_name] = nil
sp.player_huds[player_name] = nil
end
if changed and current_owner ~= "" then

View File

@ -5,31 +5,37 @@ if not minetest.get_translator then
.. " (version < 5.0.0)")
end
simple_protection = {}
local world_path = minetest.get_worldpath()
s_protect = {}
s_protect.translator = minetest.get_translator("simple_protection")
s_protect.share = {}
s_protect.mod_path = minetest.get_modpath("simple_protection")
s_protect.conf = world_path.."/s_protect.conf"
s_protect.file = world_path.."/s_protect.data"
s_protect.sharefile = world_path.."/s_protect_share.data"
local sp = simple_protection
-- Backwards compat
s_protect = sp
sp.translator = minetest.get_translator("simple_protection")
sp.share = {}
sp.mod_path = minetest.get_modpath("simple_protection")
sp.conf = world_path.."/s_protect.conf"
sp.file = world_path.."/s_protect.data"
sp.sharefile = world_path.."/s_protect_share.data"
local S = sp.translator
minetest.register_privilege("simple_protection",
s_protect.translator("Allows to modify and delete protected areas"))
S("Allows to modify and delete protected areas"))
-- Load helper functions and configuration
dofile(s_protect.mod_path.."/misc_functions.lua")
s_protect.load_config()
dofile(sp.mod_path.."/misc_functions.lua")
sp.load_config()
-- Load database functions
dofile(s_protect.mod_path.."/command_mgr.lua")
dofile(s_protect.mod_path.."/database_raw.lua")
dofile(sp.mod_path.."/command_mgr.lua")
dofile(sp.mod_path.."/database_raw.lua")
-- Spread the load a bit
minetest.after(0.5, s_protect.load_db)
minetest.after(0.5, sp.load_db)
-- General things to make this mod friendlier
dofile(s_protect.mod_path.."/protection.lua")
dofile(s_protect.mod_path.."/hud.lua")
dofile(s_protect.mod_path.."/radar.lua")
dofile(s_protect.mod_path.."/chest.lua")
dofile(sp.mod_path.."/protection.lua")
dofile(sp.mod_path.."/hud.lua")
dofile(sp.mod_path.."/radar.lua")
dofile(sp.mod_path.."/chest.lua")

View File

@ -1,15 +1,8 @@
# textdomain: simple_protection
# Translated by: Krock/SmallJoker
# Privilege description
Allows to modify and delete protected areas=Erlaubt das Abändern und Entfernen von geschützten Gebieten
#### AREA COMMAND ####
Shared Chest=Geteilte Truhe
(by protection)=(durch Gebietsschutz)
# Command description
Manages all of your areas.=Verwaltet alle deine geschützten Gebiete
# /area
Available area commands=Verfügbare 'area' Befehle
Information about this area=Informationen über dieses Gebiet
@ -17,16 +10,10 @@ View of surrounding areas=Übersicht von allen Gebieten
(Un)share one area=Zugriffs-Berechtigung eines Gebietes hinzufügen/entfernen
(Un)share all areas=Zugriffs-Berechtigung für alle Gebiete hinzufügen/entfernen
List claimed areas=Geschützte Gebiete auflisten
Delete all areas of a player=Alle Gebiete eines Spielers löschen
Unclaim this area=Den Schutz für dieses Gebiet aufheben
Delete all areas of a player=Alle Gebiete eines Spielers löschen
# Errors of /area
Unknown command parameter: @1. Check '/area' for correct usage.=Unbekannter Befehls-Parameter: @1. Siehe '/area' für die korrekte Anwendung.
No player name given.=Kein Spielernahme gegeben.
Unknown player.=Unbekannter Spieler.
This area is not claimed yet.=Dieses Gebiet ist noch nicht geschützt.
You do not own this area.=Du besitzt dieses Gebiet nicht.
# /area show
Vertical from Y @1 to @2=Senkrecht von Y @1 bis @2
Area status: @1=Gebiets-Status: @1
@ -34,75 +21,69 @@ Not claimable=Nicht schützbar
Unowned (!)=Nicht geschützt (!)
Owned by @1=Von @1 geschützt
Players with access: @1=Spieler mit Zugriff: @1
# /area radar
North @1=Nord @1
East @1=Ost @1
South @1=Süd @1
West @1=West @1
Your position=Deine Position
Your area=Dein Gebiet
Area claimed\nNo access for you=Gebiet geschützt\nKeine Berechtigung
Access for everybody=Zugriff für jeden
One area unit (@1m) up/down\n-> no claims on this Y level=Ein Gebiet (@1m) ober-/unterhalb
square \= 1 area \= @1x@2x@3 nodes (X,Y,Z)=1 Quadrat \= 1 Gebiet \= @1x@2x@3 Blöcke (X,Y,Z)
This area is not claimed yet.=Dieses Gebiet ist noch nicht geschützt.
You do not own this area.=Du besitzt dieses Gebiet nicht.
No player name given.=Kein Spielernahme gegeben.
Unknown player.=Unbekannter Spieler.
# /area share <name>
@1 already has access to all your areas.=@1 hat bereits Zugriff auf alle deine Gebiete.
@1 already has access to this area.=@1 hat bereits Zugriff auf dieses Gebiet.
@1 shared an area with you.=Du hast jetzt Zugriff auf ein Gebiet von @1.
@1 has now access to this area.=@1 kann jetzt dieses Gebiet abändern.
# /area unshare <name>
That player has no access to this area.=Dieser Spieler hat keinen Zugriff auf dieses Gebiet.
@1 unshared an area with you.=Du hast nun keinen Zugriff auf ein Gebiet von @1 mehr.
@1 has no longer access to this area.=@1 kann jetzt dieses Gebiet nicht mehr abändern.
# /area shareall <name>
You can not share all your areas with everybody.=Du kannst nicht alle Gebiete mit jedem teilen.
@1 already has now access to all your areas.=@1 hat bereits Zugriff auf alle deine Gebiete
@1 shared all areas with you.=@1 hat dir Zufriff auf alle die Gebiete erlaubt.
@1 has now access to all your areas.=@1 kann jetzt alle deine Gebiete abändern.
# /area unshareall <name>
@1 does not have access to any of your areas.=@1 hat keinen Zugriff auf deine Gebiete.
@1 unshared all areas with you.=@1 hat dir den Zugriff auf die Gebiete verwehrt.
@1 has no longer access to your areas.=@1 kann keines deiner Gebiete mehr abändern.
# /area unclaim
This area is unowned now.=Dieses Gebiet ist nun nicht mehr geschützt.
# /area delete <name>
Missing privilege: @1=Fehlendes Privileg: @1
Removed=Entfernt
Globally shared areas=Globale Gebietszugiffe
@1 claimed area(s)=@1 geschützte(s) Gebiet(e)
@1 does not own any claimed areas.=@1 besitzt keine geschützten Gebiete.
Removed=Entfernt
# /area list [name]
This command is not available.=Dieser Befehl ist nicht verfügbar.
Listing all areas of @1. Amount: @2=Auslistung der Gebiete von @1. Anzahl: @2
#### Protection ####
# Item place information
Area owned by: @1=Gebiet geschützt durch: @1
Share this area=
Remove an area share=
Share all areas=
Remove all area shares=
Also removes individual area shares=
Requires the '@1' privilege=
List all areas=
# Hud text
Area owner: @1=Gebiets-Besitzer: @1
Allows to modify and delete protected areas=Erlaubt das Abändern und Entfernen von geschützten Gebieten
Please claim this area to modify it.=Bitte schütze das Gebiet um dieses abändern zu können.
# Item place information
Area owned by: @1=Gebiet geschützt durch: @1
# Item: Claim stick
Claim Stick=Gebietsschutz
(click to protect)=
#(click to protect)=(kicken zum schützen)
This area is already protected by an other protection mod.=Dieses Gebiet ist bereits durch eine andere Mod geschützt.
You can not claim areas below @1.=Du kannst keine Gebiete unterhalb von @1 schützen.
This area is already owned by: @1=@1 besitzt dieses Gebiet bereits.
Congratulations! You now own this area.=Glückwunsch! Du besitzt dieses Gebiet jetzt.
You can not claim any further areas: Limit (@1) reached.=Du kannst keine weiteren Gebiete schützen lassen: Limit (@1) erreicht.
Please claim this area to modify it.=Bitte schütze das Gebiet um dieses abändern zu können.
#### Shared Chest ####
Shared Chest=Geteilte Truhe
(by protection)=(durch Gebietsschutz)
Congratulations! You now own this area.=Glückwunsch! Du besitzt dieses Gebiet jetzt.
# /area radar
North @1=Nord @1
West @1=West @1
South @1=Süd @1
East @1=Ost @1
square @= 1 area @= @1x@2x@3 nodes (X,Y,Z)=1 Quadrat @= 1 Gebiet @= @1x@2x@3 Blöcke (X,Y,Z)
Your position=Deine Position
Your area=Dein Gebiet
Area claimed@nNo access for you=Gebiet geschützt@nKeine Berechtigung
Access for everybody=Zugriff für jeden
One area unit (@1m) up/down@n-> no claims on this Y level=Ein Gebiet (@1m) ober-/unterhalb@n-> kein Gebiet auf dieser Höhe

View File

@ -1,31 +1,19 @@
# textdomain: simple_protection
# Translated by: d-stephane
# Privilege description
Allows to modify and delete protected areas=Permet de modifier et supprimer des zones protégées
#### AREA COMMAND ####
Shared Chest=Coffre partagé
(by protection)=(par protection)
# Command description
Manages all of your areas.=Gestion de toutes vos zones.
# /area
Available area commands=Commandes de zone disponibles
Information about this area=Informations sur cette zone
View of surrounding areas=
(Un)share one area=Partager (ou pas) une zone
(Un)share all areas=Partager (ou pas) toutes les zones
List claimed areas=Liste des zones revendiquées
Delete all areas of a player=Supprimer toutes les zones d'un joueur
Unclaim this area=Libérer cette zone
Delete all areas of a player=Supprimer toutes les zones d'un joueur
# Errors of /area
Unknown command parameter: @1. Check '/area' for correct usage.=Paramètre de commande inconnu : @1. Tappez '/area' pour voir les paramètres possible.
No player name given.=Aucun nom de joueur donné.
Unknown player.=Joueur inconnu.
This area is not claimed yet.=Cette zone n'est pas encore revendiquée.
You do not own this area.=Vous ne possédez pas cette zone.
# /area show
Vertical from Y @1 to @2=Verticale de Y @1 à @2
Area status: @1=Statut de la zone : @1
@ -33,75 +21,75 @@ Not claimable=Non revendiquable
Unowned (!)=Pas de propriétaire (!)
Owned by @1=Possédée par @1
Players with access: @1=Joueurs avec accès : @1
# /area radar
North @1=Nord @1
East @1=Est @1
South @1=Sud @1
West @1=Ouest @1
Your position=Votre position
Your area=Votre zone
Area claimed\nNo access for you=Zone revendiquée\nNon accessible pour vous
Access for everybody=Accès pour tout le monde
One area unit (@1m) up/down\n-> no claims on this Y level=Une unité de zone (@1m) haut/bas\n-> Rien de revendiqué à ce niveau Y
square \= 1 area \= @1x@2x@3 nodes (X,Y,Z)=carré \= 1 zone \= @1x@2x@3 blocs (X,Y,Z)
This area is not claimed yet.=Cette zone n'est pas encore revendiquée.
You do not own this area.=Vous ne possédez pas cette zone.
No player name given.=Aucun nom de joueur donné.
Unknown player.=Joueur inconnu.
# /area share <name>
@1 already has access to all your areas.=@1 a déjà accès à toutes vos zones.
@1 already has access to this area.=@1 a déjà accès à cette zone.
@1 shared an area with you.=@1 a partagé une zone avec vous.
@1 has now access to this area.=@1 a maintenant accès à cette zone.
# /area unshare <name>
That player has no access to this area.=Ce joueur n'a pas accès à cette zone.
@1 unshared an area with you.=@1 a enlevé le partage de la zone avec vous.
@1 has no longer access to this area.=@1 n'a plus accès à cette zone.
# /area shareall <name>
You can not share all your areas with everybody.=Vous ne pouvez pas partager toutes vos zones avec tout le monde.
@1 already has now access to all your areas.=@1 a déjà accès à toutes vos zones.
@1 shared all areas with you.=@1 a partagé toutes les zones avec vous.
@1 has now access to all your areas.=@1 a maintenant accès à toutes vos zones.
# /area unshareall <name>
@1 does not have access to any of your areas.=@1 n'a accès à aucune de vos zones.
@1 unshared all areas with you.=@1 a enlevé le partage de toutes les zones avec vous.
@1 has no longer access to your areas.=@1 n'a plus accès à vos zones.
# /area unclaim
This area is unowned now.=Cette zone n'est plus revendiquée.
# /area delete <name>
Missing privilege: @1=Privilège manquant : @1
Removed=Supprimé
Globally shared areas=Zones partagées globalement
@1 claimed area(s)=@1 a revendiqué des zones
@1 does not own any claimed areas.=@1 ne possède aucune zone revendiquée.
Removed=Supprimé
# /area list [name]
This command is not available.=Cette commande n'est pas disponible.
Listing all areas of @1. Amount: @2=Liste de tous les zones de @1. Total : @2
#### Protection ####
# Item place information
Area owned by: @1=Zone appartenant à : @1
Share this area=
Remove an area share=
Share all areas=
Remove all area shares=
Also removes individual area shares=
Requires the '@1' privilege=
List all areas=
# Hud text
Area owner: @1=Propriétaire de la zone : @1
Allows to modify and delete protected areas=Permet de modifier et supprimer des zones protégées
Please claim this area to modify it.=Veuillez revendiquer cette zone pour la modifier.
# Item place information
Area owned by: @1=Zone appartenant à : @1
# Item: Claim stick
Claim Stick=Bâton de protection
(click to protect)=(cliquez pour protéger)
This area is already protected by an other protection mod.=Cette zone est déjà protégée par un autre mod de protection.
You can not claim areas below @1.=Vous ne pouvez pas revendiquer les zones ci-dessous @1.
This area is already owned by: @1=Cette zone est déjà détenue par : @1.
Congratulations! You now own this area.=Félicitations ! Vous possédez maintenant cette zone.
You can not claim any further areas: Limit (@1) reached.=Vous ne pouvez pas revendiquer d'autres zones : La limite de @1 a été atteinte.
Please claim this area to modify it.=Veuillez revendiquer cette zone pour la modifier.
Congratulations! You now own this area.=Félicitations ! Vous possédez maintenant cette zone.
# /area radar
North @1=Nord @1
West @1=Ouest @1
South @1=Sud @1
East @1=Est @1
square @= 1 area @= @1x@2x@3 nodes (X,Y,Z)=
Your position=Votre position
Your area=Votre zone
Area claimed@nNo access for you=
Access for everybody=Accès pour tout le monde
One area unit (@1m) up/down@n-> no claims on this Y level=
#### Shared Chest ####
##### not used anymore #####
Shared Chest=Coffre partagé
(by protection)=(par protection)
Area claimed\nNo access for you=Zone revendiquée\nNon accessible pour vous
One area unit (@1m) up/down\n-> no claims on this Y level=Une unité de zone (@1m) haut/bas\n-> Rien de revendiqué à ce niveau Y
square \= 1 area \= @1x@2x@3 nodes (X,Y,Z)=carré \= 1 zone \= @1x@2x@3 blocs (X,Y,Z)

View File

@ -1,31 +1,21 @@
# textdomain: simple_protection
# Translated by: BrunoMine
# Privilege description
Allows to modify and delete protected areas=Permitir modificar e deletar areas protegidas
#### AREA COMMAND ####
Shared Chest=
(by protection)=
# Command description
Manages all of your areas.=Gerencia todas as suas areas.
# /area
Available area commands=Comandos disponiveis
Information about this area=Dados sobre essa area
View of surrounding areas=
(Un)share one area=(Des)compartilha uma area
(Un)share all areas=(Des)compartilha todas areas
List claimed areas=
#List claimed areas =
#Delete all areas of a player =
Unclaim this area=Desfazer-se dessa area
Delete all areas of a player=
# Errors of /area
Unknown command parameter: @1. Check '/area' for correct usage.=Parametro de comando desconhecido: @1. Use '/area' para o uso correto.
No player name given.=Nenhum nome de jogador dado.
Unknown player.=Jogador desconhecido.
This area is not claimed yet.=Essa area nao foi reivindicada ainda.
You do not own this area.=Voce nao pode possuir essa area.
# /area show
Vertical from Y @1 to @2=Vertical em Y @1 a @2
Area status: @1=Status da area: @1
@ -33,7 +23,10 @@ Not claimable=Nao reivindicada
Unowned (!)=Sem dono (!)
Owned by @1=Reivindicada por @1
Players with access: @1=Jogadores com acesso: @1
This area is not claimed yet.=Essa area nao foi reivindicada ainda.
You do not own this area.=Voce nao pode possuir essa area.
No player name given.=Nenhum nome de jogador dado.
Unknown player.=Jogador desconhecido.
# /area radar
#North @1 =
#East @1 =
@ -43,63 +36,63 @@ Players with access: @1=Jogadores com acesso: @1
#Your area =
#Area claimed\nNo access for you =
#Access for everybody =
# /area share <name>
@1 already has access to all your areas.=@1 ja possui acesso a todas suas areas.
@1 already has access to this area.=@1 ja possui acesso a essa area.
@1 shared an area with you.=@1 compartilhou uma area contigo.
@1 has now access to this area.=@1 agora tem acesso nessa area.
# /area unshare <name>
That player has no access to this area.=Esse jogador nao tem acesso a essa area.
@1 unshared an area with you.=@1 descompartilhou uma area contigo.
@1 has no longer access to this area.=@1 deixou de ter acesso a essa area.
# /area shareall <name>
You can not share all your areas with everybody.=Nao podes compartilhar todas as suas areas com todos.
@1 already has now access to all your areas.=@1 ja possui agora acesso a todas suas areas.
@1 shared all areas with you.=@1 compartilhou todas as areas contigo.
@1 has now access to all your areas.=@1 agora tem acesso a todas suas areas.
# /area unshareall <name>
@1 does not have access to any of your areas.=@1 nao tem acesso a nenhuma de suas areas.
@1 unshared all areas with you.=@1 descompartilhou todas areas contigo.
@1 has no longer access to your areas.=@1 deixou de ter acesso a todas suas areas.
# /area unclaim
This area is unowned now.=Essa area deixou de ser reivindicada agora.
# /area delete <name>
Missing privilege: @1=Perderam o privilegio: @1
Removed=Removido
Globally shared areas=Areas compartilhadas globalmente
@1 claimed area(s)=@1 area(s) reivindicada(s)
@1 does not own any claimed areas.=@1 nao possui nenhuma area reivindicada.
# /area list [name]
#This command is not available. =
#Listing all areas of @1. Amount: @2 =
#### Protection ####
# Item place information
Area owned by: @1=Area possuida por: @1
Removed=Removido
This command is not available.=
Listing all areas of @1. Amount: @2=
Share this area=
Remove an area share=
Share all areas=
Remove all area shares=
Also removes individual area shares=
Requires the '@1' privilege=
List all areas=
# Hud text
Area owner: @1=Area de: @1
Allows to modify and delete protected areas=Permitir modificar e deletar areas protegidas
Please claim this area to modify it.=
# Item place information
Area owned by: @1=Area possuida por: @1
# Item: Claim stick
Claim Stick=Graveto Reivindicador
(click to protect)=
#(click to protect) =
This area is already protected by an other protection mod.=Essa area ja foi protegida por um outro mod protetor.
You can not claim areas below @1.=Nao podes reivindicar areas abaixo @1.
This area is already owned by: @1=Essa area ja foi reivindicada por: @1.
You can not claim any further areas: Limit (@1) reached.=
Congratulations! You now own this area.=Parabens! Agora reivindicaste essa area.
#You can not claim any further areas: Limit (@1) reached. =
#Please claim this area to modify it. =
#### Shared Chest ####
#Shared Chest =
#(by protection) =
North @1=
West @1=
South @1=
East @1=
square @= 1 area @= @1x@2x@3 nodes (X,Y,Z)=
Your position=
Your area=
Area claimed@nNo access for you=
Access for everybody=
One area unit (@1m) up/down@n-> no claims on this Y level=

View File

@ -1,15 +1,8 @@
# textdomain: simple_protection
# Translated by: YOURNAME
# Privilege description
Allows to modify and delete protected areas=
#### AREA COMMAND ####
Shared Chest=
(by protection)=
# Command description
Manages all of your areas.=
# /area
Available area commands=
Information about this area=
@ -17,16 +10,10 @@ View of surrounding areas=
(Un)share one area=
(Un)share all areas=
List claimed areas=
Delete all areas of a player=
Unclaim this area=
Delete all areas of a player=
# Errors of /area
Unknown command parameter: @1. Check '/area' for correct usage.=
No player name given.=
Unknown player.=
This area is not claimed yet.=
You do not own this area.=
# /area show
Vertical from Y @1 to @2=
Area status: @1=
@ -34,75 +21,73 @@ Not claimable=
Unowned (!)=
Owned by @1=
Players with access: @1=
# /area radar
North @1=
East @1=
South @1=
West @1=
Your position=
Your area=
Area claimed\nNo access for you=
Access for everybody=
One area unit (@1m) up/down\n-> no claims on this Y level=
square \= 1 area \= @1x@2x@3 nodes (X,Y,Z)=
This area is not claimed yet.=
You do not own this area.=
No player name given.=
Unknown player.=
# /area share <name>
@1 already has access to all your areas.=
@1 already has access to this area.=
@1 shared an area with you.=
@1 has now access to this area.=
# /area unshare <name>
That player has no access to this area.=
@1 unshared an area with you.=
@1 has no longer access to this area.=
# /area shareall <name>
You can not share all your areas with everybody.=
@1 already has now access to all your areas.=
@1 shared all areas with you.=
@1 has now access to all your areas.=
# /area unshareall <name>
@1 does not have access to any of your areas.=
@1 unshared all areas with you.=
@1 has no longer access to your areas.=
# /area unclaim
This area is unowned now.=
# /area delete <name>
Missing privilege: @1=
Removed=
Globally shared areas=
@1 claimed area(s)=
@1 does not own any claimed areas.=
Removed=
# /area list [name]
This command is not available.=
Listing all areas of @1. Amount: @2=
#### Protection ####
# Item place information
Area owned by: @1=
Share this area=
Remove an area share=
Share all areas=
Remove all area shares=
Also removes individual area shares=
Requires the '@1' privilege=
List all areas=
# Hud text
Area owner: @1=
Allows to modify and delete protected areas=
Please claim this area to modify it.=
# Item place information
Area owned by: @1=
# Item: Claim stick
Claim Stick=
(click to protect)=
This area is already protected by an other protection mod.=
You can not claim areas below @1.=
This area is already owned by: @1=
Congratulations! You now own this area.=
You can not claim any further areas: Limit (@1) reached.=
Please claim this area to modify it.=
Congratulations! You now own this area.=
# /area radar
North @1=
West @1=
South @1=
East @1=
square @= 1 area @= @1x@2x@3 nodes (X,Y,Z)=
Your position=
Your area=
Area claimed@nNo access for you=
Access for everybody=
One area unit (@1m) up/down@n-> no claims on this Y level=
#### Shared Chest ####
##### not used anymore #####
Shared Chest=
(by protection)=
square \= 1 area \= @1x@2x@3 nodes (X,Y,Z)=

View File

@ -10,8 +10,9 @@ Configuration loading
-- Cache for performance
local get_player_privs = minetest.get_player_privs
local registered_on_access = {}
local sp = simple_protection
s_protect.can_access = function(pos, player_name)
sp.can_access = function(pos, player_name)
if not player_name then
return false
end
@ -28,21 +29,21 @@ s_protect.can_access = function(pos, player_name)
end
-- Data of current area
local data = s_protect.get_claim(pos)
local data = sp.get_claim(pos)
-- Area is not claimed
if not data then
-- Allow digging when claiming is not forced
if not s_protect.claim_to_dig then
if not sp.claim_to_dig then
return true
end
-- Must claim everywhere? Disallow everywhere.
if not s_protect.underground_limit then
if not sp.underground_limit then
return false
end
-- Is it in claimable area? Yes? Disallow.
if pos.y >= s_protect.underground_limit then
if pos.y >= sp.underground_limit then
return false
end
return true
@ -72,42 +73,41 @@ s_protect.can_access = function(pos, player_name)
end
-- Owner shared the area with the player
if s_protect.is_shared(data.owner, player_name) then
if sp.is_shared(data.owner, player_name) then
return true
end
-- Globally shared area
if s_protect.is_shared(data, player_name) then
if sp.is_shared(data, player_name) then
return true
end
if s_protect.is_shared(data, "*all") then
if sp.is_shared(data, "*all") then
return true
end
return false
end
s_protect.register_on_access = function(func)
sp.register_on_access = function(func)
registered_on_access[#registered_on_access + 1] = func
end
s_protect.get_location = function(pos_)
sp.get_location = function(pos_)
local pos = vector.round(pos_)
return vector.floor({
x = pos.x / s_protect.claim_size,
y = (pos.y + s_protect.start_underground) / s_protect.claim_height,
z = pos.z / s_protect.claim_size
x = pos.x / sp.claim_size,
y = (pos.y + sp.start_underground) / sp.claim_height,
z = pos.z / sp.claim_size
})
end
local get_location = s_protect.get_location
s_protect.get_area_bounds = function(pos_)
local cs = s_protect.claim_size
local cy = s_protect.claim_height
sp.get_area_bounds = function(pos_)
local cs = sp.claim_size
local cy = sp.claim_height
local p = get_location(pos_)
local p = sp.get_location(pos_)
local minp = {
x = p.x * cs,
y = p.y * cy - s_protect.start_underground,
y = p.y * cy - sp.start_underground,
z = p.z * cs
}
local maxp = {
@ -119,8 +119,8 @@ s_protect.get_area_bounds = function(pos_)
return minp, maxp
end
s_protect.get_center = function(pos1)
local size = s_protect.claim_size
sp.get_center = function(pos1)
local size = sp.claim_size
local pos = {
x = pos1.x / size,
y = pos1.y + 1.5,
@ -133,14 +133,14 @@ s_protect.get_center = function(pos1)
return pos
end
s_protect.load_config = function()
sp.load_config = function()
-- Load defaults
dofile(s_protect.mod_path.."/default_settings.lua")
local file = io.open(s_protect.conf, "r")
dofile(sp.mod_path.."/default_settings.lua")
local file = io.open(sp.conf, "r")
if not file then
-- Duplicate configuration file on first time
local src = io.open(s_protect.mod_path.."/default_settings.lua", "r")
file = io.open(s_protect.conf, "w")
local src = io.open(sp.mod_path.."/default_settings.lua", "r")
file = io.open(sp.conf, "w")
while true do
local block = src:read(128) -- 128B at once
@ -157,28 +157,28 @@ s_protect.load_config = function()
io.close(file)
-- Load existing config
local simple_protection = {}
dofile(s_protect.conf)
rawset(_G, "s_protect", {})
dofile(sp.conf)
-- Backwards compatibility
for k, v in pairs(simple_protection) do
s_protect[k] = v
for k, v in pairs(s_protect) do
sp[k] = v
end
simple_protection = nil
s_protect = nil
-- Sanity check individual settings
assert((s_protect.claim_size % 2) == 0 and s_protect.claim_size >= 4,
assert((sp.claim_size % 2) == 0 and sp.claim_size >= 4,
"claim_size must be even and >= 4")
assert(s_protect.claim_height >= 4, "claim_height must be >= 4")
assert(sp.claim_height >= 4, "claim_height must be >= 4")
if s_protect.claim_heigh then
if sp.claim_heigh then
minetest.log("warning", "[simple_protection] "
.. "Deprecated setting: claim_heigh")
s_protect.claim_height = s_protect.claim_heigh
sp.claim_height = sp.claim_heigh
end
if s_protect.underground_claim then
if sp.underground_claim then
minetest.log("warning", "[simple_protection] "
.. "Deprecated setting: underground_claim")
s_protect.underground_limit = nil
sp.underground_limit = nil
end
end

View File

@ -6,11 +6,12 @@ Node placement checks
Claim Stick item definition
]]
local S = s_protect.translator
local sp = simple_protection
local S = sp.translator
local function notify_player(pos, player_name)
local data = s_protect.get_claim(pos)
if not data and s_protect.claim_to_dig then
local data = sp.get_claim(pos)
if not data and sp.claim_to_dig then
minetest.chat_send_player(player_name, S("Please claim this area to modify it."))
elseif not data then
-- Access restricted by another protection mod. Not my job.
@ -20,10 +21,10 @@ local function notify_player(pos, player_name)
end
end
s_protect.old_is_protected = minetest.is_protected
sp.old_is_protected = minetest.is_protected
minetest.is_protected = function(pos, player_name)
if s_protect.can_access(pos, player_name) then
return s_protect.old_is_protected(pos, player_name)
if sp.can_access(pos, player_name) then
return sp.old_is_protected(pos, player_name)
end
return true
end
@ -41,34 +42,34 @@ minetest.register_craftitem("simple_protection:claim", {
end
local player_name = user:get_player_name()
local pos = pointed_thing.under
if s_protect.old_is_protected(pos, player_name) then
if sp.old_is_protected(pos, player_name) then
minetest.chat_send_player(player_name,
S("This area is already protected by an other protection mod."))
return
end
if s_protect.underground_limit then
local minp, maxp = s_protect.get_area_bounds(pos)
if minp.y < s_protect.underground_limit then
if sp.underground_limit then
local minp, maxp = sp.get_area_bounds(pos)
if minp.y < sp.underground_limit then
minetest.chat_send_player(player_name,
S("You can not claim areas below @1.",
s_protect.underground_limit .. "m"))
sp.underground_limit .. "m"))
return
end
end
local data, index = s_protect.get_claim(pos)
local data, index = sp.get_claim(pos)
if data then
minetest.chat_send_player(player_name,
S("This area is already owned by: @1", data.owner))
return
end
-- Count number of claims for this user
local claims_max = s_protect.max_claims
local claims_max = sp.max_claims
if minetest.check_player_privs(player_name, {simple_protection=true}) then
claims_max = claims_max * 2
end
local claims, count = s_protect.get_player_claims(player_name)
local claims, count = sp.get_player_claims(player_name)
if count >= claims_max then
minetest.chat_send_player(player_name,
S("You can not claim any further areas: Limit (@1) reached.",
@ -77,11 +78,11 @@ minetest.register_craftitem("simple_protection:claim", {
end
itemstack:take_item(1)
s_protect.update_claims({
sp.update_claims({
[index] = {owner=player_name, shared={}}
})
minetest.add_entity(s_protect.get_center(pos), "simple_protection:marker")
minetest.add_entity(sp.get_center(pos), "simple_protection:marker")
minetest.chat_send_player(player_name, S("Congratulations! You now own this area."))
return itemstack
end,
@ -114,12 +115,12 @@ minetest.register_entity("simple_protection:marker",{
})
-- hacky - I'm not a regular node!
local size = s_protect.claim_size / 2
local size = sp.claim_size / 2
minetest.register_node("simple_protection:mark", {
tiles = {"simple_protection_marker.png"},
groups = {dig_immediate=3, not_in_creative_inventory=1},
drop = "",
use_texture_alpha = "clip",
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
walkable = false,
drawtype = "nodebox",
node_box = {

View File

@ -1,5 +1,6 @@
-- /area radar
local S = s_protect.translator
local sp = simple_protection
local S = sp.translator
local data_cache
local function colorize_area(name, force)
@ -12,7 +13,7 @@ local function colorize_area(name, force)
data_cache.owner == name then
return "[colorize:#0F0:180"
end
local is_shared = s_protect.is_shared
local is_shared = sp.is_shared
if force == "shared" or not force and (
is_shared(data_cache, name)
or is_shared(data_cache.owner, name)) then
@ -30,15 +31,15 @@ local function combine_escape(str)
return str:gsub("%^%[", "\\%^\\%["):gsub(":", "\\:")
end
s_protect.register_subcommand("radar", function(name)
sp.register_subcommand("radar", function(name)
local player = minetest.get_player_by_name(name)
local player_pos = player:get_pos()
local pos = s_protect.get_location(player_pos)
local pos = sp.get_location(player_pos)
local map_w = 15 - 1
local map_wh = map_w / 2
local img_w = 20
local get_single = s_protect.get_claim
local get_single = sp.get_claim
local function getter(x, ymod, z)
data_cache = get_single(x .."," .. (pos.y + ymod) .. "," .. z, true)
return data_cache
@ -69,8 +70,8 @@ s_protect.register_subcommand("radar", function(name)
end
-- Player's position marker (8x8 px)
local pp_x = player_pos.x / s_protect.claim_size
local pp_z = player_pos.z / s_protect.claim_size
local pp_x = player_pos.x / sp.claim_size
local pp_z = player_pos.z / sp.claim_size
-- Get relative position to the map, add map center offset, center image
pp_x = math.floor((pp_x - pos.x + map_wh) * img_w + 0.5) - 4
pp_z = math.floor((pos.z - pp_z + map_wh + 1) * img_w + 0.5) - 4
@ -106,9 +107,9 @@ s_protect.register_subcommand("radar", function(name)
.. parts .. marker_str)
.. dir_mod .. "]" ..
"label[0,6.8;1 " .. S("square = 1 area = @1x@2x@3 nodes (X,Y,Z)",
s_protect.claim_size,
s_protect.claim_height,
s_protect.claim_size) .. "]" ..
sp.claim_size,
sp.claim_height,
sp.claim_size) .. "]" ..
"image[6.25,1.25;0.5,0.5;object_marker_red.png]" ..
"label[7,1.25;" .. S("Your position") .. "]" ..
"image[6,2;1,1;simple_protection_radar.png^"
@ -123,6 +124,6 @@ s_protect.register_subcommand("radar", function(name)
"image[6,5;1,1;simple_protection_radar_down.png]" ..
"image[7,5;1,1;simple_protection_radar_up.png]" ..
"label[6,6;" .. S("One area unit (@1m) up/down\n-> no claims on this Y level",
s_protect.claim_height) .. "]"
sp.claim_height) .. "]"
)
end)