mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +00:00
added protection check for PAPI
This commit is contained in:
parent
97082b060b
commit
ba9ea7f8eb
1 changed files with 22 additions and 2 deletions
|
@ -1,10 +1,30 @@
|
||||||
|
local function check_protection(pos, name)
|
||||||
|
if minetest.is_protected(pos, name) then
|
||||||
|
minetest.log("action", name
|
||||||
|
.. " tried to place a PAPI"
|
||||||
|
.. " at protected position "
|
||||||
|
.. minetest.pos_to_string(pos)
|
||||||
|
)
|
||||||
|
minetest.record_protection_violation(pos, name)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function airutils.PAPIplace(player,pos)
|
function airutils.PAPIplace(player,pos)
|
||||||
|
if not player then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local dir = minetest.dir_to_facedir(player:get_look_dir())
|
local dir = minetest.dir_to_facedir(player:get_look_dir())
|
||||||
local pos1 = vector.new(pos)
|
local pos1 = vector.new(pos)
|
||||||
|
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
if check_protection(pos, player_name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
core.set_node(pos, {name="airutils:papi", param2=dir})
|
core.set_node(pos, {name="airutils:papi", param2=dir})
|
||||||
local player_name = player:get_player_name()
|
|
||||||
local meta = core.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
meta:set_string("infotext", "PAPI\rOwned by: "..player_name)
|
meta:set_string("infotext", "PAPI\rOwned by: "..player_name)
|
||||||
meta:set_string("owner", player_name)
|
meta:set_string("owner", player_name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue