Compare commits
5 Commits
0a059c2ecc
...
4c4836134b
Author | SHA1 | Date |
---|---|---|
fluxionary | 4c4836134b | |
upsilon | b84810f6c3 | |
David Leal | 06fd54342e | |
upsilon | b67fe9ea0d | |
zeuner | 46ecf9a42b |
|
@ -1,3 +0,0 @@
|
|||
unified_inventory?
|
||||
bones?
|
||||
intllib?
|
2
init.lua
2
init.lua
|
@ -1,4 +1,4 @@
|
|||
if not minetest.setting_getbool("enable_pvp") then
|
||||
if not minetest.settings:get_bool("enable_pvp") then
|
||||
minetest.log("error", "[PvP Plus] PvP Plus cannot work if PvP is disabled. Please enable PvP.")
|
||||
else
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/pvp.lua")
|
||||
|
|
|
@ -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
|
1
mod.conf
1
mod.conf
|
@ -1 +1,2 @@
|
|||
name = pvpplus
|
||||
optional_depends = unified_inventory, bones, intllib
|
25
pvp.lua
25
pvp.lua
|
@ -4,14 +4,11 @@ local pvptable = {}
|
|||
-- Public table, containing global functions
|
||||
pvpplus = {}
|
||||
|
||||
local S
|
||||
if minetest.get_modpath("intllib") then
|
||||
S = intllib.Getter()
|
||||
else
|
||||
S = function(translated)
|
||||
return translated
|
||||
end
|
||||
end
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
local S, NS = dofile(
|
||||
MP .. "/intllib.lua"
|
||||
)
|
||||
|
||||
minetest.register_privilege("pvp", S("Can change own PvP state"))
|
||||
minetest.register_privilege("pvp_admin", S("Can change others PvP state"))
|
||||
|
@ -137,6 +134,10 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
|
|||
local localname = player:get_player_name()
|
||||
local hittername = hitter:get_player_name()
|
||||
|
||||
if localname == hittername then
|
||||
return false
|
||||
end
|
||||
|
||||
if not pvptable[localname].state then
|
||||
minetest.chat_send_player(hittername, string.format(S("You can't hit %s because their PvP is disabled."), localname))
|
||||
return true
|
||||
|
@ -147,3 +148,11 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
|
|||
end
|
||||
return false
|
||||
end)
|
||||
|
||||
local old_calculate_knockback = minetest.calculate_knockback
|
||||
function minetest.calculate_knockback(player, hitter, ...)
|
||||
if not pvpplus.is_pvp(player:get_player_name()) or not pvpplus.is_pvp(hitter:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return old_calculate_knockback(player, hitter, ...)
|
||||
end
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
local S
|
||||
if minetest.get_modpath("intllib") then
|
||||
S = intllib.Getter()
|
||||
else
|
||||
S = function(translated)
|
||||
return translated
|
||||
end
|
||||
end
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
local S, NS = dofile(
|
||||
MP .. "/intllib.lua"
|
||||
)
|
||||
|
||||
if minetest.get_modpath("unified_inventory") then
|
||||
unified_inventory.register_button("pvp", {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local tournament_starting_time = tonumber(minetest.setting_get("pvpplus.tournament_starting_time")) or 60 -- seconds
|
||||
local tournament_starting_time = tonumber(minetest.settings:get("pvpplus.tournament_starting_time")) or 60 -- seconds
|
||||
local tournament = pvpplus.tournament -- Shortcut reference
|
||||
|
||||
minetest.register_privilege("tournament_mod", "PvP Tournament Moderator")
|
||||
|
|
|
@ -3,9 +3,9 @@ tournament.hud = {}
|
|||
tournament.hud_list = {}
|
||||
|
||||
-- These values cannot be exact for all clients. Default values should be fine for most of them.
|
||||
local margin = tonumber(minetest.setting_get("pvpplus.tournament_hud_margin")) or 10 -- pixels
|
||||
local font_width = tonumber(minetest.setting_get("pvpplus.font_width")) or 5 -- pixels
|
||||
local separation = tonumber(minetest.setting_get("pvpplus.tournament_hud_separation")) or 18 -- pixels
|
||||
local margin = tonumber(minetest.settings:get("pvpplus.tournament_hud_margin")) or 10 -- pixels
|
||||
local font_width = tonumber(minetest.settings:get("pvpplus.font_width")) or 5 -- pixels
|
||||
local separation = tonumber(minetest.settings:get("pvpplus.tournament_hud_separation")) or 18 -- pixels
|
||||
|
||||
function pvpplus.tournament_hud_update_list()
|
||||
tournament.hud_list = {}
|
||||
|
|
Loading…
Reference in New Issue