ratelimit and syntax bugfix

master
Emoji 2022-08-01 09:48:23 +08:00
parent 920849eb33
commit a88101fef2
5 changed files with 26 additions and 1 deletions

View File

@ -1,7 +1,10 @@
local aS = minetest.get_translator("areas")
local S = minetest.get_translator("protect_block_area")
local protector_radius = tonumber(minetest.settings:get("protector_radius")) or 5
local protector_radius = tonumber(minetest.settings:get("area_protector_radius")) or tonumber(minetest.settings:get("protector_radius")) or 5
local protector_placing_delay = tonumber(minetest.settings:get("area_protector_delay")) or 2
local in_delay = {}
local function get_node_place_position(pointed_thing)
if pointed_thing.type ~= "node" then return false end
@ -37,6 +40,10 @@ minetest.register_node("protect_block_area:protect", {
return itemstack
end
local pname = placer:get_player_name()
if in_delay[pname] then
minetest.chat_send_player(pname,S("You cannot place more than 1 protector blocks within @1 seconds!",protector_placing_delay))
return itemstack
end
local privs = minetest.get_player_privs(pname)
if not privs[areas.config.self_protection_privilege] then
minetest.chat_send_player(pname,S("You are not allowed to protect!"))
@ -70,6 +77,10 @@ minetest.register_node("protect_block_area:protect", {
local meta = minetest.get_meta(pos)
meta:set_int("AreaID",id)
meta:set_string("infotext",S("Area protection block, ID: @1",id))
in_delay[pname] = true
minetest.after(protector_placing_delay,function()
in_delay[pname] = false
end)
return itemstack
end,
on_dig = function(pos,node,digger)
@ -120,4 +131,5 @@ if not minetest.global_exists("protector") then
{"default:stone", "default:stone", "default:stone"}
}
})
end

View File

@ -1,6 +1,7 @@
# textdomain: protect_block_area
Protection Block=保護區方塊
Create areas quickly=快速保護區域
You cannot place more than 1 protector blocks within @1 seconds!=在@1秒之內只可放置一個保護區方塊
You are not allowed to protect!=你無權保護區域!
Area protection block, ID: @1=保護區方塊區域ID@1
Failed.=失敗。

View File

@ -0,0 +1,6 @@
# textdomain: protect_block_area
Protection Block=保護區方塊
Create areas quickly=快速保護區域
You are not allowed to protect!=你無權保護區域!
Area protection block, ID: @1=保護區方塊區域ID@1
Failed.=失敗。

View File

@ -1,6 +1,7 @@
# textdomain: protect_block_area
Protection Block=
Create areas quickly=
You cannot place more than 1 protector blocks within @1 seconds!=
You are not allowed to protect!=
Area protection block, ID: @1=
Failed.=

5
settingtypes.txt Normal file
View File

@ -0,0 +1,5 @@
# Area protector radius (fallback: protector_radius)
area_protector_radius (Area protector radius) int 5
# Area protector placing delay
area_protector_delay (Area protector placing delay) int 2