mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-28 03:30:39 +01:00
Improvements from alexerate
* update player location when protected * function anti_lag added * Add delay for anti_lag * remove obsolete code * localization * utf-8 * make self_protection true by default
This commit is contained in:
commit
86a7b76be4
14
interact.lua
14
interact.lua
@ -1,3 +1,5 @@
|
|||||||
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
local S, NS = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = minetest.is_protected
|
||||||
function minetest.is_protected(pos, name)
|
function minetest.is_protected(pos, name)
|
||||||
@ -8,12 +10,16 @@ function minetest.is_protected(pos, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_protection_violation(function(pos, name)
|
minetest.register_on_protection_violation(function(pos, name)
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
local playerpos = player:getpos()
|
||||||
if not areas:canInteract(pos, name) then
|
if not areas:canInteract(pos, name) then
|
||||||
local owners = areas:getNodeOwners(pos)
|
local owners = areas:getNodeOwners(pos)
|
||||||
minetest.chat_send_player(name,
|
--minetest.chat_send_player(name, ("%s is protected by %s."):format(minetest.pos_to_string(pos), table.concat(owners, ", ")))
|
||||||
("%s is protected by %s."):format(
|
minetest.chat_send_player(name,S("@1 is protected by @2",minetest.pos_to_string(pos),table.concat(owners, ", ")))
|
||||||
minetest.pos_to_string(pos),
|
minetest.after(1,anti_lag,{player=player,playerpos=playerpos})
|
||||||
table.concat(owners, ", ")))
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
function anti_lag(player)
|
||||||
|
player.player:setpos(player.playerpos)
|
||||||
|
end
|
||||||
|
45
intllib.lua
Normal file
45
intllib.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
-- Fallback functions for when `intllib` is not installed.
|
||||||
|
-- Code released under Unlicense <http://unlicense.org>.
|
||||||
|
|
||||||
|
-- Get the latest version of this file at:
|
||||||
|
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
|
||||||
|
|
||||||
|
local function format(str, ...)
|
||||||
|
local args = { ... }
|
||||||
|
local function repl(escape, open, num, close)
|
||||||
|
if escape == "" then
|
||||||
|
local replacement = tostring(args[tonumber(num)])
|
||||||
|
if open == "" then
|
||||||
|
replacement = replacement..close
|
||||||
|
end
|
||||||
|
return replacement
|
||||||
|
else
|
||||||
|
return "@"..open..num..close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||||
|
end
|
||||||
|
|
||||||
|
local gettext, ngettext
|
||||||
|
if minetest.get_modpath("intllib") then
|
||||||
|
if intllib.make_gettext_pair then
|
||||||
|
-- New method using gettext.
|
||||||
|
gettext, ngettext = intllib.make_gettext_pair()
|
||||||
|
else
|
||||||
|
-- Old method using text files.
|
||||||
|
gettext = intllib.Getter()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fill in missing functions.
|
||||||
|
|
||||||
|
gettext = gettext or function(msgid, ...)
|
||||||
|
return format(msgid, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
|
||||||
|
return format(n==1 and msgid or msgid_plural, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return gettext, ngettext
|
23
locale/fr.po
Normal file
23
locale/fr.po
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||||
|
# This file is distributed under the same license as the PACKAGE package.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: \n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2018-01-29 11:28+0200\n"
|
||||||
|
"PO-Revision-Date: 2018-01-29 09:18+0200\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"Language: fr\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"X-Generator: Poedit 1.8.12\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
|
#: init.lua
|
||||||
|
msgid "@1 is protected by @2"
|
||||||
|
msgstr "@1 est protégé par @2"
|
@ -30,7 +30,7 @@ setting("string", "filename", world_path.."/areas.dat")
|
|||||||
|
|
||||||
-- Allow players with a privilege create their own areas
|
-- Allow players with a privilege create their own areas
|
||||||
-- within the maximum size and number.
|
-- within the maximum size and number.
|
||||||
setting("boolean", "self_protection", false)
|
setting("boolean", "self_protection", true)
|
||||||
setting("string", "self_protection_privilege", "interact")
|
setting("string", "self_protection_privilege", "interact")
|
||||||
setting("position", "self_protection_max_size", {x=64, y=128, z=64})
|
setting("position", "self_protection_max_size", {x=64, y=128, z=64})
|
||||||
setting("number", "self_protection_max_areas", 4)
|
setting("number", "self_protection_max_areas", 4)
|
||||||
@ -40,4 +40,3 @@ setting("number", "self_protection_max_areas_high", 32)
|
|||||||
|
|
||||||
-- legacy_table (owner_defs) compatibility. Untested and has known issues.
|
-- legacy_table (owner_defs) compatibility. Untested and has known issues.
|
||||||
setting("boolean", "legacy_table", false)
|
setting("boolean", "legacy_table", false)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user