Compare commits
10 commits
97b0da0cf9
...
f397dd8824
| Author | SHA1 | Date | |
|---|---|---|---|
| f397dd8824 | |||
|
|
943acbcf50 | ||
|
|
4196fd0c4f | ||
|
|
04ef9e3432 | ||
|
|
72f4e36b7b | ||
|
|
33a5b6eadb | ||
|
|
2503310260 | ||
|
|
de98f04667 | ||
|
|
ce84ac68b2 | ||
|
|
f272486f4f |
6 changed files with 476 additions and 548 deletions
45
admin.lua
45
admin.lua
|
|
@ -1,27 +1,30 @@
|
||||||
|
|
||||||
local S = protector.intllib
|
-- translation and default name vars
|
||||||
|
|
||||||
|
local S = minetest.get_translator("protector")
|
||||||
local removal_names = ""
|
local removal_names = ""
|
||||||
local replace_names = ""
|
local replace_names = ""
|
||||||
|
|
||||||
|
-- remove protection command
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_remove", {
|
minetest.register_chatcommand("protector_remove", {
|
||||||
params = S("<names list>"),
|
params = S("<names list>"),
|
||||||
description = S("Remove Protectors around players (separate names with spaces)"),
|
description = S("Remove Protectors around players (separate names with spaces)"),
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
|
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
|
||||||
if not param or param == "" then
|
if not param or param == "" then
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
S("Protector Names to remove: @1",
|
S("Protector Names to remove: @1", removal_names))
|
||||||
removal_names))
|
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if param == "-" then
|
if param == "-" then
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name, S("Name List Reset"))
|
||||||
S("Name List Reset"))
|
|
||||||
|
|
||||||
removal_names = ""
|
removal_names = ""
|
||||||
|
|
||||||
|
|
@ -32,11 +35,13 @@ minetest.register_chatcommand("protector_remove", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- replace protection command
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_replace", {
|
minetest.register_chatcommand("protector_replace", {
|
||||||
params = S("<owner name> <name to replace with>"),
|
params = S("<owner name> <name to replace with>"),
|
||||||
description = S("Replace Protector Owner with name provided"),
|
description = S("Replace Protector Owner with name provided"),
|
||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
|
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
|
||||||
-- reset list to empty
|
-- reset list to empty
|
||||||
|
|
@ -50,13 +55,11 @@ minetest.register_chatcommand("protector_replace", {
|
||||||
end
|
end
|
||||||
|
|
||||||
-- show name info
|
-- show name info
|
||||||
if param == ""
|
if param == "" and replace_names ~= "" then
|
||||||
and replace_names ~= "" then
|
|
||||||
|
|
||||||
local names = replace_names:split(" ")
|
local names = replace_names:split(" ")
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name, S("Replacing Protector name @1 with @2",
|
||||||
S("Replacing Protector name @1 with @2",
|
|
||||||
names[1] or "", names[2] or ""))
|
names[1] or "", names[2] or ""))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -66,18 +69,17 @@ minetest.register_chatcommand("protector_replace", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Abm to remove or replace protectors within active player area
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"protector:protect", "protector:protect2", "protector:protect_hidden"},
|
nodenames = {"protector:protect", "protector:protect2", "protector:protect_hidden"},
|
||||||
interval = 6,
|
interval = 6,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
|
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
|
|
||||||
if removal_names == ""
|
if removal_names == "" and replace_names == "" then return end
|
||||||
and replace_names == "" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
|
|
@ -90,9 +92,7 @@ minetest.register_abm({
|
||||||
local names = removal_names:split(" ")
|
local names = removal_names:split(" ")
|
||||||
|
|
||||||
for _, n in pairs(names) do
|
for _, n in pairs(names) do
|
||||||
if n == owner then
|
if n == owner then minetest.set_node(pos, {name = "air"}) end
|
||||||
minetest.set_node(pos, {name = "air"})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -108,16 +108,19 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- get protection radius
|
-- get protection radius (max 30)
|
||||||
|
|
||||||
local r = tonumber(minetest.settings:get("protector_radius")) or 5
|
local r = tonumber(minetest.settings:get("protector_radius")) or 5
|
||||||
|
|
||||||
if r > 30 then r = 30 end
|
if r > 30 then r = 30 end
|
||||||
|
|
||||||
-- show protection areas of nearby protectors owned by you (thanks agaran)
|
-- show protection areas of nearby protectors owned by you (thanks agaran)
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_show_area", {
|
minetest.register_chatcommand("protector_show_area", {
|
||||||
params = "",
|
params = "",
|
||||||
description = S("Show protected areas of your nearby protectors"),
|
description = S("Show protected areas of your nearby protectors"),
|
||||||
privs = {},
|
privs = {},
|
||||||
|
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
|
|
@ -145,8 +148,8 @@ minetest.register_chatcommand("protector_show_area", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- ability to hide protection blocks (borrowed from doors mod :)
|
-- ability to hide protection blocks (borrowed from doors mod :)
|
||||||
|
|
||||||
minetest.register_node("protector:protect_hidden", {
|
minetest.register_node("protector:protect_hidden", {
|
||||||
description = "Hidden Protector",
|
description = "Hidden Protector",
|
||||||
drawtype = "airlike",
|
drawtype = "airlike",
|
||||||
|
|
@ -165,11 +168,11 @@ minetest.register_node("protector:protect_hidden", {
|
||||||
on_blast = function() end,
|
on_blast = function() end,
|
||||||
-- 1px block inside door hinge near node top
|
-- 1px block inside door hinge near node top
|
||||||
collision_box = {
|
collision_box = {
|
||||||
type = "fixed",
|
type = "fixed", fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32}
|
||||||
fixed = {-15/32, 13/32, -15/32, -13/32, 1/2, -13/32}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- make own protectors visible in area
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_show", {
|
minetest.register_chatcommand("protector_show", {
|
||||||
params = "",
|
params = "",
|
||||||
|
|
@ -206,6 +209,8 @@ minetest.register_chatcommand("protector_show", {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- make own protectors invisible in area
|
||||||
|
|
||||||
minetest.register_chatcommand("protector_hide", {
|
minetest.register_chatcommand("protector_hide", {
|
||||||
params = "",
|
params = "",
|
||||||
description = S("Hide your nearby protection blocks"),
|
description = S("Hide your nearby protection blocks"),
|
||||||
|
|
|
||||||
274
doors_chest.lua
274
doors_chest.lua
|
|
@ -1,22 +1,25 @@
|
||||||
|
|
||||||
-- Since the doors mod has changed in the latest daily builds I have taken the
|
-- doors code from an old client re-used
|
||||||
-- WTFPL licenced code from the old doors mod and included an edited version
|
|
||||||
-- within this mod for local use.
|
|
||||||
|
|
||||||
local S = protector.intllib
|
local S = minetest.get_translator("protector")
|
||||||
local F = minetest.formspec_escape
|
local F = minetest.formspec_escape
|
||||||
|
|
||||||
-- MineClone2 support
|
-- MineClone support
|
||||||
|
|
||||||
local mcl = minetest.get_modpath("mcl_core")
|
local mcl = minetest.get_modpath("mcl_core")
|
||||||
local mcf = minetest.get_modpath("mcl_formspec")
|
local mcf = minetest.get_modpath("mcl_formspec")
|
||||||
|
|
||||||
-- Are crafts enabled?
|
-- Are crafts enabled?
|
||||||
|
|
||||||
local protector_crafts = minetest.settings:get_bool("protector_crafts") ~= false
|
local protector_crafts = minetest.settings:get_bool("protector_crafts") ~= false
|
||||||
|
|
||||||
-- Registers a door
|
-- Registers a door
|
||||||
function register_door(name, def)
|
|
||||||
|
local function register_door(name, def)
|
||||||
|
|
||||||
def.groups.not_in_creative_inventory = 1
|
def.groups.not_in_creative_inventory = 1
|
||||||
def.groups.handy = 1
|
def.groups.handy = 1
|
||||||
|
def.groups.prot_door = 1
|
||||||
|
|
||||||
local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5 + 1.5/16}}
|
local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5 + 1.5/16}}
|
||||||
|
|
||||||
|
|
@ -24,20 +27,20 @@ function register_door(name, def)
|
||||||
def.node_box_top = box
|
def.node_box_top = box
|
||||||
def.selection_box_bottom = box
|
def.selection_box_bottom = box
|
||||||
def.selection_box_top = box
|
def.selection_box_top = box
|
||||||
def.sound_close_door = "doors_door_close"
|
|
||||||
def.sound_open_door = "doors_door_open"
|
|
||||||
|
|
||||||
minetest.register_craftitem(name, {
|
minetest.register_craftitem(name, {
|
||||||
description = def.description,
|
description = def.description,
|
||||||
inventory_image = def.inventory_image,
|
inventory_image = def.inventory_image,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local ptu = pointed_thing.under
|
local ptu = pointed_thing.under
|
||||||
local nu = minetest.get_node(ptu)
|
local nu = minetest.get_node(ptu)
|
||||||
|
|
||||||
if minetest.registered_nodes[nu.name]
|
if minetest.registered_nodes[nu.name]
|
||||||
and minetest.registered_nodes[nu.name].on_rightclick then
|
and minetest.registered_nodes[nu.name].on_rightclick then
|
||||||
return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
|
return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
|
||||||
|
|
@ -45,24 +48,24 @@ function register_door(name, def)
|
||||||
|
|
||||||
local pt = pointed_thing.above
|
local pt = pointed_thing.above
|
||||||
local pt2 = {x = pt.x, y = pt.y, z = pt.z}
|
local pt2 = {x = pt.x, y = pt.y, z = pt.z}
|
||||||
|
|
||||||
pt2.y = pt2.y + 1
|
pt2.y = pt2.y + 1
|
||||||
if
|
|
||||||
not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to or
|
if not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to
|
||||||
not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to or
|
or not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to
|
||||||
not placer or
|
or not placer or not placer:is_player() then
|
||||||
not placer:is_player()
|
|
||||||
then
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.is_protected(pt, placer:get_player_name()) or
|
if minetest.is_protected(pt, placer:get_player_name())
|
||||||
minetest.is_protected(pt2, placer:get_player_name()) then
|
or minetest.is_protected(pt2, placer:get_player_name()) then
|
||||||
minetest.record_protection_violation(pt, placer:get_player_name())
|
minetest.record_protection_violation(pt, placer:get_player_name())
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
|
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
local pt3 = {x = pt.x, y = pt.y, z = pt.z}
|
local pt3 = {x = pt.x, y = pt.y, z = pt.z}
|
||||||
|
|
||||||
if p2 == 0 then
|
if p2 == 0 then
|
||||||
pt3.x = pt3.x - 1
|
pt3.x = pt3.x - 1
|
||||||
elseif p2 == 1 then
|
elseif p2 == 1 then
|
||||||
|
|
@ -72,12 +75,14 @@ function register_door(name, def)
|
||||||
elseif p2 == 3 then
|
elseif p2 == 3 then
|
||||||
pt3.z = pt3.z - 1
|
pt3.z = pt3.z - 1
|
||||||
end
|
end
|
||||||
if minetest.get_item_group(minetest.get_node(pt3).name, "door") == 0 then
|
|
||||||
|
if minetest.get_item_group(minetest.get_node(pt3).name, "prot_door") == 0 then
|
||||||
minetest.set_node(pt, {name = name .. "_b_1", param2 = p2})
|
minetest.set_node(pt, {name = name .. "_b_1", param2 = p2})
|
||||||
minetest.set_node(pt2, {name = name .. "_t_1", param2 = p2})
|
minetest.set_node(pt2, {name = name .. "_t_1", param2 = p2})
|
||||||
else
|
else
|
||||||
minetest.set_node(pt, {name = name .. "_b_2", param2 = p2})
|
minetest.set_node(pt, {name = name .. "_b_2", param2 = p2})
|
||||||
minetest.set_node(pt2, {name = name .. "_t_2", param2 = p2})
|
minetest.set_node(pt2, {name = name .. "_t_2", param2 = p2})
|
||||||
|
|
||||||
minetest.get_meta(pt):set_int("right", 1)
|
minetest.get_meta(pt):set_int("right", 1)
|
||||||
minetest.get_meta(pt2):set_int("right", 1)
|
minetest.get_meta(pt2):set_int("right", 1)
|
||||||
end
|
end
|
||||||
|
|
@ -85,69 +90,70 @@ function register_door(name, def)
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.sound_play(def.sounds.place, {pos = pt2}, true)
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
local tt = def.tiles_top
|
local tt = def.tiles_top
|
||||||
local tb = def.tiles_bottom
|
local tb = def.tiles_bottom
|
||||||
|
|
||||||
local function after_dig_node(pos, name, digger)
|
local function after_dig_node(pos, name, digger)
|
||||||
|
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
|
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
minetest.node_dig(pos, node, digger)
|
minetest.node_dig(pos, node, digger)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
||||||
|
|
||||||
pos.y = pos.y + dir
|
pos.y = pos.y + dir
|
||||||
if minetest.get_node(pos).name ~= check_name then
|
|
||||||
return
|
if minetest.get_node(pos).name ~= check_name then return end
|
||||||
end
|
|
||||||
local p2 = minetest.get_node(pos).param2
|
local p2 = minetest.get_node(pos).param2
|
||||||
|
|
||||||
p2 = params[p2 + 1]
|
p2 = params[p2 + 1]
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = replace_dir, param2 = p2})
|
minetest.swap_node(pos, {name = replace_dir, param2 = p2})
|
||||||
|
|
||||||
pos.y = pos.y - dir
|
pos.y = pos.y - dir
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = replace, param2=p2})
|
minetest.swap_node(pos, {name = replace, param2=p2})
|
||||||
|
|
||||||
local snd_1 = def.sound_close_door
|
minetest.sound_play("default_dug_node",
|
||||||
local snd_2 = def.sound_open_door
|
{pos = pos, gain = 0.3, max_hear_distance = 10}, true)
|
||||||
if params[1] == 3 then
|
|
||||||
snd_1 = def.sound_open_door
|
|
||||||
snd_2 = def.sound_close_door
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.get_meta(pos):get_int("right") ~= 0 then
|
|
||||||
minetest.sound_play(snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10})
|
|
||||||
else
|
|
||||||
minetest.sound_play(snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_rotate(pos, node, dir, user, check_name, mode, new_param2)
|
local function on_rotate(pos, node, dir, user, check_name, mode, new_param2)
|
||||||
|
|
||||||
if mode ~= screwdriver.ROTATE_FACE then
|
if mode ~= screwdriver.ROTATE_FACE then return false end
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
pos.y = pos.y + dir
|
pos.y = pos.y + dir
|
||||||
if minetest.get_node(pos).name ~= check_name then
|
|
||||||
return false
|
if minetest.get_node(pos).name ~= check_name then return false end
|
||||||
end
|
|
||||||
if minetest.is_protected(pos, user:get_player_name()) then
|
if minetest.is_protected(pos, user:get_player_name()) then
|
||||||
minetest.record_protection_violation(pos, user:get_player_name())
|
minetest.record_protection_violation(pos, user:get_player_name())
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local node2 = minetest.get_node(pos)
|
local node2 = minetest.get_node(pos)
|
||||||
|
|
||||||
node2.param2 = (node2.param2 + 1) % 4
|
node2.param2 = (node2.param2 + 1) % 4
|
||||||
|
|
||||||
minetest.swap_node(pos, node2)
|
minetest.swap_node(pos, node2)
|
||||||
|
|
||||||
pos.y = pos.y - dir
|
pos.y = pos.y - dir
|
||||||
|
|
||||||
node.param2 = (node.param2 + 1) % 4
|
node.param2 = (node.param2 + 1) % 4
|
||||||
|
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -157,16 +163,11 @@ function register_door(name, def)
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
node_dig_prediction = "",
|
||||||
drop = name,
|
drop = name,
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = { type = "fixed", fixed = def.node_box_bottom },
|
||||||
type = "fixed",
|
selection_box = { type = "fixed", fixed = def.selection_box_bottom },
|
||||||
fixed = def.node_box_bottom
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = def.selection_box_bottom
|
|
||||||
},
|
|
||||||
groups = def.groups,
|
groups = def.groups,
|
||||||
_mcl_hardness = 0.8,
|
_mcl_hardness = 0.8,
|
||||||
_mcl_blast_resistance = 1,
|
_mcl_blast_resistance = 1,
|
||||||
|
|
@ -177,6 +178,7 @@ function register_door(name, def)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
|
|
||||||
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
||||||
on_rightclick(pos, 1, name .. "_t_1", name .. "_b_2", name .. "_t_2", {1,2,3,0})
|
on_rightclick(pos, 1, name .. "_t_1", name .. "_b_2", name .. "_t_2", {1,2,3,0})
|
||||||
end
|
end
|
||||||
|
|
@ -188,7 +190,7 @@ function register_door(name, def)
|
||||||
|
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sunlight_propagates = def.sunlight,
|
sunlight_propagates = def.sunlight,
|
||||||
on_blast = function() end,
|
on_blast = function() end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name .. "_t_1", {
|
minetest.register_node(name .. "_t_1", {
|
||||||
|
|
@ -197,16 +199,11 @@ function register_door(name, def)
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
node_dig_prediction = "",
|
||||||
drop = "",
|
drop = "",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = { type = "fixed", fixed = def.node_box_top },
|
||||||
type = "fixed",
|
selection_box = { type = "fixed", fixed = def.selection_box_top },
|
||||||
fixed = def.node_box_top
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = def.selection_box_top
|
|
||||||
},
|
|
||||||
groups = def.groups,
|
groups = def.groups,
|
||||||
_mcl_hardness = 0.8,
|
_mcl_hardness = 0.8,
|
||||||
_mcl_blast_resistance = 1,
|
_mcl_blast_resistance = 1,
|
||||||
|
|
@ -228,7 +225,7 @@ function register_door(name, def)
|
||||||
|
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sunlight_propagates = def.sunlight,
|
sunlight_propagates = def.sunlight,
|
||||||
on_blast = function() end,
|
on_blast = function() end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name .. "_b_2", {
|
minetest.register_node(name .. "_b_2", {
|
||||||
|
|
@ -237,16 +234,11 @@ function register_door(name, def)
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
node_dig_prediction = "",
|
||||||
drop = name,
|
drop = name,
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = { type = "fixed", fixed = def.node_box_bottom },
|
||||||
type = "fixed",
|
selection_box = { type = "fixed", fixed = def.selection_box_bottom },
|
||||||
fixed = def.node_box_bottom
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = def.selection_box_bottom
|
|
||||||
},
|
|
||||||
groups = def.groups,
|
groups = def.groups,
|
||||||
_mcl_hardness = 0.8,
|
_mcl_hardness = 0.8,
|
||||||
_mcl_blast_resistance = 1,
|
_mcl_blast_resistance = 1,
|
||||||
|
|
@ -268,7 +260,7 @@ function register_door(name, def)
|
||||||
|
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sunlight_propagates = def.sunlight,
|
sunlight_propagates = def.sunlight,
|
||||||
on_blast = function() end,
|
on_blast = function() end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name .. "_t_2", {
|
minetest.register_node(name .. "_t_2", {
|
||||||
|
|
@ -277,16 +269,11 @@ function register_door(name, def)
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
node_dig_prediction = "",
|
||||||
drop = "",
|
drop = "",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = { type = "fixed", fixed = def.node_box_top },
|
||||||
type = "fixed",
|
selection_box = { type = "fixed", fixed = def.selection_box_top },
|
||||||
fixed = def.node_box_top
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = def.selection_box_top
|
|
||||||
},
|
|
||||||
groups = def.groups,
|
groups = def.groups,
|
||||||
_mcl_hardness = 0.8,
|
_mcl_hardness = 0.8,
|
||||||
_mcl_blast_resistance = 1,
|
_mcl_blast_resistance = 1,
|
||||||
|
|
@ -308,7 +295,7 @@ function register_door(name, def)
|
||||||
|
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sunlight_propagates = def.sunlight,
|
sunlight_propagates = def.sunlight,
|
||||||
on_blast = function() end,
|
on_blast = function() end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -319,10 +306,7 @@ local name = "protector:door_wood"
|
||||||
register_door(name, {
|
register_door(name, {
|
||||||
description = S("Protected Wooden Door"),
|
description = S("Protected Wooden Door"),
|
||||||
inventory_image = "doors_wood.png^protector_logo.png",
|
inventory_image = "doors_wood.png^protector_logo.png",
|
||||||
groups = {
|
groups = {snappy = 1, choppy = 2, dig_immediate = 2, unbreakable = 1, axey = 1},
|
||||||
snappy = 1, choppy = 2, dig_immediate = 2,
|
|
||||||
unbreakable = 1, axey = 1, --door = 1
|
|
||||||
},
|
|
||||||
tiles_bottom = {"doors_wood_b.png^protector_logo.png", "doors_brown.png"},
|
tiles_bottom = {"doors_wood_b.png^protector_logo.png", "doors_brown.png"},
|
||||||
tiles_top = {"doors_wood_a.png", "doors_brown.png"},
|
tiles_top = {"doors_wood_a.png", "doors_brown.png"},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
|
@ -330,12 +314,12 @@ register_door(name, {
|
||||||
})
|
})
|
||||||
|
|
||||||
if protector_crafts then
|
if protector_crafts then
|
||||||
|
|
||||||
if mcl then
|
if mcl then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = {
|
recipe = { {"mcl_doors:wooden_door", "mcl_core:gold_ingot"} }
|
||||||
{"mcl_doors:wooden_door", "mcl_core:gold_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
@ -349,9 +333,7 @@ if protector_crafts then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = {
|
recipe = { {"doors:door_wood", "default:copper_ingot"} }
|
||||||
{"doors:door_wood", "default:copper_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -365,7 +347,7 @@ register_door(name, {
|
||||||
inventory_image = "doors_steel.png^protector_logo.png",
|
inventory_image = "doors_steel.png^protector_logo.png",
|
||||||
groups = {
|
groups = {
|
||||||
snappy = 1, bendy = 2, cracky = 1,
|
snappy = 1, bendy = 2, cracky = 1,
|
||||||
level = mcl and 0 or 2, pickaxey = 2, unbreakable = 1, -- door = 1
|
level = (mcl and 0 or 2), pickaxey = 2, unbreakable = 1
|
||||||
},
|
},
|
||||||
tiles_bottom = {"doors_steel_b.png^protector_logo.png", "doors_grey.png"},
|
tiles_bottom = {"doors_steel_b.png^protector_logo.png", "doors_grey.png"},
|
||||||
tiles_top = {"doors_steel_a.png", "doors_grey.png"},
|
tiles_top = {"doors_steel_a.png", "doors_grey.png"},
|
||||||
|
|
@ -379,9 +361,7 @@ if protector_crafts then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = {
|
recipe = { {"mcl_doors:iron_door", "mcl_core:gold_ingot"} }
|
||||||
{"mcl_doors:iron_door", "mcl_core:gold_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
@ -395,31 +375,29 @@ if protector_crafts then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = name,
|
output = name,
|
||||||
recipe = {
|
recipe = { {"doors:door_steel", "default:copper_ingot"} }
|
||||||
{"doors:door_steel", "default:copper_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
----trapdoor----
|
----trapdoor----
|
||||||
|
|
||||||
function register_trapdoor(name, def)
|
local function register_trapdoor(name, def)
|
||||||
|
|
||||||
local name_closed = name
|
local name_closed = name
|
||||||
local name_opened = name .. "_open"
|
local name_opened = name .. "_open"
|
||||||
|
|
||||||
def.on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
def.on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||||
if minetest.is_protected(pos, clicker:get_player_name()) then
|
|
||||||
return
|
if minetest.is_protected(pos, clicker:get_player_name()) then return end
|
||||||
end
|
|
||||||
local newname = node.name == name_closed and name_opened or name_closed
|
local newname = node.name == name_closed and name_opened or name_closed
|
||||||
local sound = false
|
|
||||||
if node.name == name_closed then sound = "doors_door_open" end
|
minetest.sound_play("default_dug_node",
|
||||||
if node.name == name_opened then sound = "doors_door_close" end
|
{pos = pos, gain = 0.3, max_hear_distance = 10}, true)
|
||||||
if sound then
|
|
||||||
minetest.sound_play(sound, {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.swap_node(pos,
|
||||||
end
|
{name = newname, param1 = node.param1, param2 = node.param2})
|
||||||
minetest.swap_node(pos, {name = newname, param1 = node.param1, param2 = node.param2})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Common trapdoor configuration
|
-- Common trapdoor configuration
|
||||||
|
|
@ -428,28 +406,25 @@ function register_trapdoor(name, def)
|
||||||
def.paramtype2 = "facedir"
|
def.paramtype2 = "facedir"
|
||||||
def.use_texture_alpha = "clip"
|
def.use_texture_alpha = "clip"
|
||||||
def.is_ground_content = false
|
def.is_ground_content = false
|
||||||
|
def.node_dig_prediction = ""
|
||||||
|
|
||||||
local def_opened = table.copy(def)
|
local def_opened = table.copy(def)
|
||||||
local def_closed = table.copy(def)
|
local def_closed = table.copy(def)
|
||||||
|
|
||||||
def_closed.node_box = {
|
def_closed.node_box = {
|
||||||
type = "fixed",
|
type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
|
|
||||||
}
|
}
|
||||||
def_closed.selection_box = {
|
def_closed.selection_box = {
|
||||||
type = "fixed",
|
type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
|
|
||||||
}
|
}
|
||||||
def_closed.tiles = { def.tile_front, def.tile_front, def.tile_side, def.tile_side,
|
def_closed.tiles = { def.tile_front, def.tile_front, def.tile_side, def.tile_side,
|
||||||
def.tile_side, def.tile_side }
|
def.tile_side, def.tile_side }
|
||||||
|
|
||||||
def_opened.node_box = {
|
def_opened.node_box = {
|
||||||
type = "fixed",
|
type = "fixed", fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
|
||||||
fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
|
|
||||||
}
|
}
|
||||||
def_opened.selection_box = {
|
def_opened.selection_box = {
|
||||||
type = "fixed",
|
type = "fixed", fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
|
||||||
fixed = {-0.5, -0.5, 6/16, 0.5, 0.5, 0.5}
|
|
||||||
}
|
}
|
||||||
def_opened.tiles = { def.tile_side, def.tile_side,
|
def_opened.tiles = { def.tile_side, def.tile_side,
|
||||||
def.tile_side .. "^[transform3",
|
def.tile_side .. "^[transform3",
|
||||||
|
|
@ -471,22 +446,19 @@ register_trapdoor("protector:trapdoor", {
|
||||||
wield_image = "doors_trapdoor.png^protector_logo.png",
|
wield_image = "doors_trapdoor.png^protector_logo.png",
|
||||||
tile_front = "doors_trapdoor.png^protector_logo.png",
|
tile_front = "doors_trapdoor.png^protector_logo.png",
|
||||||
tile_side = "doors_trapdoor_side.png",
|
tile_side = "doors_trapdoor_side.png",
|
||||||
groups = {
|
groups = {snappy = 1, choppy = 2, dig_immediate = 2, unbreakable = 1, axey = 1},
|
||||||
snappy = 1, choppy = 2, dig_immediate = 2,
|
|
||||||
unbreakable = 1, axey = 1, --door = 1
|
|
||||||
},
|
|
||||||
_mcl_hardness = 0.8,
|
_mcl_hardness = 0.8,
|
||||||
_mcl_blast_resistance = 1,
|
_mcl_blast_resistance = 1,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if protector_crafts then
|
if protector_crafts then
|
||||||
|
|
||||||
if mcl then
|
if mcl then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:trapdoor",
|
output = "protector:trapdoor",
|
||||||
recipe = {
|
recipe = { {"mcl_doors:trapdoor", "mcl_core:gold_ingot"} }
|
||||||
{"mcl_doors:trapdoor", "mcl_core:gold_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
@ -499,9 +471,7 @@ if protector_crafts then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:trapdoor",
|
output = "protector:trapdoor",
|
||||||
recipe = {
|
recipe = { {"doors:trapdoor", "default:copper_ingot"} }
|
||||||
{"doors:trapdoor", "default:copper_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -515,21 +485,21 @@ register_trapdoor("protector:trapdoor_steel", {
|
||||||
tile_front = "doors_trapdoor_steel.png^protector_logo.png",
|
tile_front = "doors_trapdoor_steel.png^protector_logo.png",
|
||||||
tile_side = "doors_trapdoor_steel_side.png",
|
tile_side = "doors_trapdoor_steel_side.png",
|
||||||
groups = {
|
groups = {
|
||||||
snappy = 1, bendy = 2, cracky = 1, melty = 2, level = mcl and 0 or 2,
|
snappy = 1, bendy = 2, cracky = 1, melty = 2, level = (mcl and 0 or 2),
|
||||||
unbreakable = 1, pickaxey = 2, --door = 1
|
unbreakable = 1, pickaxey = 2
|
||||||
},
|
},
|
||||||
_mcl_hardness = 1,
|
_mcl_hardness = 1,
|
||||||
_mcl_blast_resistance = 1,
|
_mcl_blast_resistance = 1,
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults()
|
||||||
})
|
})
|
||||||
|
|
||||||
if protector_crafts then
|
if protector_crafts then
|
||||||
|
|
||||||
if mcl then
|
if mcl then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:trapdoor_steel",
|
output = "protector:trapdoor_steel",
|
||||||
recipe = {
|
recipe = { {"mcl_doors:iron_trapdoor", "mcl_core:gold_ingot"} }
|
||||||
{"mcl_doors:iron_trapdoor", "mcl_core:gold_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
@ -542,9 +512,7 @@ if protector_crafts then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:trapdoor_steel",
|
output = "protector:trapdoor_steel",
|
||||||
recipe = {
|
recipe = { {"doors:trapdoor_steel", "default:copper_ingot"} }
|
||||||
{"doors:trapdoor_steel", "default:copper_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -591,24 +559,21 @@ minetest.register_node("protector:chest", {
|
||||||
|
|
||||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name()
|
||||||
" moves stuff to protected chest at " ..
|
.. " moves stuff to protected chest at " .. minetest.pos_to_string(pos))
|
||||||
minetest.pos_to_string(pos))
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name()
|
||||||
" takes stuff from protected chest at " ..
|
.. " takes stuff from protected chest at " .. minetest.pos_to_string(pos))
|
||||||
minetest.pos_to_string(pos))
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_metadata_inventory_move = function(
|
on_metadata_inventory_move = function(
|
||||||
pos, from_list, from_index, to_list, to_index, count, player)
|
pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name()
|
||||||
" moves stuff inside protected chest at " ..
|
.. " moves stuff inside protected chest at " .. minetest.pos_to_string(pos))
|
||||||
minetest.pos_to_string(pos))
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
|
@ -641,15 +606,9 @@ minetest.register_node("protector:chest", {
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
|
|
||||||
if minetest.is_protected(pos, clicker:get_player_name()) then
|
if minetest.is_protected(pos, clicker:get_player_name()) then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos) ; if not meta then return end
|
||||||
|
|
||||||
if not meta then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||||
local formspec
|
local formspec
|
||||||
|
|
@ -697,11 +656,12 @@ minetest.register_node("protector:chest", {
|
||||||
"protector:chest_" .. minetest.pos_to_string(pos), formspec)
|
"protector:chest_" .. minetest.pos_to_string(pos), formspec)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_blast = function() end,
|
on_blast = function() end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Container transfer helper
|
-- Container transfer helper
|
||||||
local to_from = function(src, dst)
|
|
||||||
|
local function to_from(src, dst)
|
||||||
|
|
||||||
local stack, item, leftover
|
local stack, item, leftover
|
||||||
local size = dst:get_size("main")
|
local size = dst:get_size("main")
|
||||||
|
|
@ -728,16 +688,12 @@ end
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
if string.sub(formname, 0, 16) ~= "protector:chest_" then
|
if string.sub(formname, 0, 16) ~= "protector:chest_" then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos_s = string.sub(formname, 17)
|
local pos_s = string.sub(formname, 17)
|
||||||
local pos = minetest.string_to_pos(pos_s)
|
local pos = minetest.string_to_pos(pos_s)
|
||||||
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos) ; if not meta then return end
|
local meta = minetest.get_meta(pos) ; if not meta then return end
|
||||||
local chest_inv = meta:get_inventory() ; if not chest_inv then return end
|
local chest_inv = meta:get_inventory() ; if not chest_inv then return end
|
||||||
|
|
@ -781,9 +737,7 @@ if protector_crafts then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:chest",
|
output = "protector:chest",
|
||||||
recipe = {
|
recipe = { {"mcl_chests:chest", "mcl_core:gold_ingot"} }
|
||||||
{"mcl_chests:chest", "mcl_core:gold_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
@ -797,9 +751,7 @@ if protector_crafts then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:chest",
|
output = "protector:chest",
|
||||||
recipe = {
|
recipe = { {"default:chest", "default:copper_ingot"} }
|
||||||
{"default:chest", "default:copper_ingot"}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
15
hud.lua
15
hud.lua
|
|
@ -1,23 +1,27 @@
|
||||||
|
|
||||||
local S = protector.intllib
|
-- translation and protector radius
|
||||||
|
|
||||||
|
local S = minetest.get_translator("protector")
|
||||||
local radius = (tonumber(minetest.settings:get("protector_radius")) or 5)
|
local radius = (tonumber(minetest.settings:get("protector_radius")) or 5)
|
||||||
|
|
||||||
-- radius limiter (minetest cannot handle node volume of more than 4096000)
|
-- radius limiter (minetest cannot handle node volume of more than 4096000)
|
||||||
|
|
||||||
if radius > 30 then radius = 30 end
|
if radius > 30 then radius = 30 end
|
||||||
|
|
||||||
|
-- hud settings
|
||||||
|
|
||||||
local hud = {}
|
local hud = {}
|
||||||
local hud_timer = 0
|
local hud_timer = 0
|
||||||
local hud_interval = (tonumber(minetest.settings:get("protector_hud_interval")) or 5)
|
local hud_interval = (tonumber(minetest.settings:get("protector_hud_interval")) or 5)
|
||||||
local hud_style = minetest.has_feature("hud_def_type_field")
|
local hud_style = minetest.has_feature("hud_def_type_field")
|
||||||
|
|
||||||
if hud_interval > 0 then
|
if hud_interval > 0 then
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
-- every 5 seconds
|
-- every 5 seconds
|
||||||
hud_timer = hud_timer + dtime
|
hud_timer = hud_timer + dtime
|
||||||
if hud_timer < hud_interval then
|
if hud_timer < hud_interval then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
hud_timer = 0
|
hud_timer = 0
|
||||||
|
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
|
|
@ -32,6 +36,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
{"protector:protect","protector:protect2", "protector:protect_hidden"})
|
{"protector:protect","protector:protect2", "protector:protect_hidden"})
|
||||||
|
|
||||||
if #protectors > 0 then
|
if #protectors > 0 then
|
||||||
|
|
||||||
local npos = protectors[1]
|
local npos = protectors[1]
|
||||||
local meta = minetest.get_meta(npos)
|
local meta = minetest.get_meta(npos)
|
||||||
local nodeowner = meta:get_string("owner")
|
local nodeowner = meta:get_string("owner")
|
||||||
|
|
@ -72,4 +77,4 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
hud[player:get_player_name()] = nil
|
hud[player:get_player_name()] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end
|
end -- END hud_interval > 0
|
||||||
|
|
|
||||||
413
init.lua
413
init.lua
|
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
-- default support (for use with MineClone2 and other [games]
|
-- default support (for use with MineClone2 and other [games]
|
||||||
default = default or {
|
|
||||||
node_sound_stone_defaults = function(table) end,
|
if not minetest.global_exists("default") then
|
||||||
node_sound_wood_defaults = function(table) end,
|
|
||||||
gui_bg = "",
|
default = {
|
||||||
gui_bg_img = "",
|
node_sound_stone_defaults = function(table) return {} end,
|
||||||
gui_slots = ""
|
node_sound_wood_defaults = function(table) return {} end,
|
||||||
|
node_sound_metal_defaults = function(table) return {} end,
|
||||||
|
gui_bg = "", gui_bg_img = "", gui_slots = ""
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("mcl_sounds") then
|
if minetest.get_modpath("mcl_sounds") then
|
||||||
default.node_sound_stone_defaults = mcl_sounds.node_sound_stone_defaults
|
default.node_sound_stone_defaults = mcl_sounds.node_sound_stone_defaults
|
||||||
|
|
@ -14,23 +17,20 @@ if minetest.get_modpath("mcl_sounds") then
|
||||||
default.node_sound_metal_defaults = mcl_sounds.node_sound_metal_defaults
|
default.node_sound_metal_defaults = mcl_sounds.node_sound_metal_defaults
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- modpath, formspec helper and translator
|
||||||
|
|
||||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||||
local F = minetest.formspec_escape
|
local F = minetest.formspec_escape
|
||||||
|
|
||||||
-- Translation support
|
|
||||||
local S = minetest.get_translator("protector")
|
local S = minetest.get_translator("protector")
|
||||||
|
|
||||||
-- Load support for factions
|
-- global table
|
||||||
|
|
||||||
|
protector = { mod = "redo", modpath = MP }
|
||||||
|
|
||||||
|
-- settings
|
||||||
|
|
||||||
local factions_available = minetest.global_exists("factions")
|
local factions_available = minetest.global_exists("factions")
|
||||||
|
|
||||||
protector = {
|
|
||||||
mod = "redo",
|
|
||||||
modpath = MP,
|
|
||||||
intllib = S
|
|
||||||
}
|
|
||||||
|
|
||||||
local protector_max_share_count = 12
|
local protector_max_share_count = 12
|
||||||
-- get minetest.conf settings
|
|
||||||
local protector_radius = tonumber(minetest.settings:get("protector_radius")) or 5
|
local protector_radius = tonumber(minetest.settings:get("protector_radius")) or 5
|
||||||
local protector_flip = minetest.settings:get_bool("protector_flip") or false
|
local protector_flip = minetest.settings:get_bool("protector_flip") or false
|
||||||
local protector_hurt = tonumber(minetest.settings:get("protector_hurt")) or 0
|
local protector_hurt = tonumber(minetest.settings:get("protector_hurt")) or 0
|
||||||
|
|
@ -41,110 +41,94 @@ local protector_recipe = minetest.settings:get_bool("protector_recipe") ~= false
|
||||||
local protector_msg = minetest.settings:get_bool("protector_msg") ~= false
|
local protector_msg = minetest.settings:get_bool("protector_msg") ~= false
|
||||||
|
|
||||||
-- radius limiter (minetest cannot handle node volume of more than 4096000)
|
-- radius limiter (minetest cannot handle node volume of more than 4096000)
|
||||||
|
|
||||||
if protector_radius > 30 then protector_radius = 30 end
|
if protector_radius > 30 then protector_radius = 30 end
|
||||||
|
|
||||||
|
|
||||||
-- get static spawn position
|
-- get static spawn position
|
||||||
|
|
||||||
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
|
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
|
||||||
or {x = 0, y = 2, z = 0}
|
or {x = 0, y = 2, z = 0}
|
||||||
|
|
||||||
|
|
||||||
-- return list of members as a table
|
-- return list of members as a table
|
||||||
local get_member_list = function(meta)
|
|
||||||
|
local function get_member_list(meta)
|
||||||
|
|
||||||
return meta:get_string("members"):split(" ")
|
return meta:get_string("members"):split(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_faction_list(meta)
|
||||||
|
return meta:get_string("factions"):split(" ")
|
||||||
|
end
|
||||||
|
|
||||||
-- write member list table in protector meta as string
|
-- write member list table in protector meta as string
|
||||||
local set_member_list = function(meta, list)
|
|
||||||
|
local function set_member_list(meta, list)
|
||||||
|
|
||||||
meta:set_string("members", table.concat(list, " "))
|
meta:set_string("members", table.concat(list, " "))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function set_faction_list(meta, list)
|
||||||
|
meta:set_string("factions", table.concat(list, " "))
|
||||||
|
end
|
||||||
|
|
||||||
-- check for owner name
|
-- check for owner name
|
||||||
local is_owner = function(meta, name)
|
|
||||||
|
local function is_owner(meta, name)
|
||||||
|
|
||||||
return name == meta:get_string("owner")
|
return name == meta:get_string("owner")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- check for member name
|
-- check for member name
|
||||||
local is_member = function(meta, name)
|
|
||||||
|
|
||||||
if factions_available
|
local function is_member(meta, name)
|
||||||
and meta:get_int("faction_members") == 1 then
|
|
||||||
|
|
||||||
if factions.version == nil then
|
|
||||||
|
|
||||||
-- backward compatibility
|
|
||||||
if factions.get_player_faction(name) ~= nil
|
|
||||||
and factions.get_player_faction(meta:get_string("owner")) ==
|
|
||||||
factions.get_player_faction(name) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- is member if player and owner share at least one faction
|
|
||||||
local owner_factions = factions.get_player_factions(name)
|
|
||||||
local owner = meta:get_string("owner")
|
|
||||||
|
|
||||||
if owner_factions ~= nil and owner_factions ~= false then
|
|
||||||
|
|
||||||
for _, f in ipairs(owner_factions) do
|
|
||||||
|
|
||||||
if factions.player_is_in_faction(f, owner) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, n in pairs(get_member_list(meta)) do
|
for _, n in pairs(get_member_list(meta)) do
|
||||||
|
|
||||||
if n == name then
|
if n == name then return true end
|
||||||
|
end
|
||||||
|
|
||||||
|
if factions_available then
|
||||||
|
for _, faction in pairs(get_faction_list(meta)) do
|
||||||
|
if factions.player_is_in_faction(faction, name) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- add player name to table as member
|
-- add player name to table as member
|
||||||
local add_member = function(meta, name)
|
|
||||||
|
local function add_member(meta, name)
|
||||||
|
|
||||||
-- Validate player name for MT compliance
|
-- Validate player name for MT compliance
|
||||||
if name ~= string.match(name, "[%w_-]+") then
|
if name ~= string.match(name, "[%w_-]+") then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Constant (20) defined by player.h
|
-- Constant (20) defined by player.h
|
||||||
if name:len() > 25 then
|
if name:len() > 25 then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- does name already exist?
|
|
||||||
if is_owner(meta, name)
|
|
||||||
or is_member(meta, name) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local list = get_member_list(meta)
|
local list = get_member_list(meta)
|
||||||
|
|
||||||
if #list >= protector_max_share_count then
|
if #list >= protector_max_share_count then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(list, name)
|
table.insert(list, name)
|
||||||
|
|
||||||
set_member_list(meta, list)
|
set_member_list(meta, list)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function add_faction(meta, name)
|
||||||
|
if name ~= string.match(name, "[%w_-]+") then return end
|
||||||
|
if name:len() > 25 then return end
|
||||||
|
local list = get_faction_list(meta)
|
||||||
|
if #list >= 4 then return end
|
||||||
|
table.insert(list, name)
|
||||||
|
set_faction_list(meta, list)
|
||||||
|
end
|
||||||
|
|
||||||
-- remove player name from table
|
-- remove player name from table
|
||||||
local del_member = function(meta, name)
|
|
||||||
|
local function del_member(meta, name)
|
||||||
|
|
||||||
local list = get_member_list(meta)
|
local list = get_member_list(meta)
|
||||||
|
|
||||||
|
|
@ -159,65 +143,53 @@ local del_member = function(meta, name)
|
||||||
set_member_list(meta, list)
|
set_member_list(meta, list)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function del_faction(meta, name)
|
||||||
|
local list = get_faction_list(meta)
|
||||||
|
for i, n in pairs(list) do
|
||||||
|
if n == name then
|
||||||
|
table.remove(list, i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set_faction_list(meta, list)
|
||||||
|
end
|
||||||
|
|
||||||
-- protector interface
|
-- protector interface
|
||||||
local protector_formspec = function(meta)
|
|
||||||
|
local function protector_formspec(meta)
|
||||||
|
|
||||||
local formspec = "size[8,7]"
|
local formspec = "size[8,7]"
|
||||||
.. default.gui_bg
|
.. default.gui_bg
|
||||||
.. default.gui_bg_img
|
.. default.gui_bg_img
|
||||||
.. "label[2.5,0;" .. F(S("-- Protector interface --")) .. "]"
|
.. "label[2.5,0;" .. F(S("-- Protector interface --")) .. "]"
|
||||||
.. "label[0,1;" .. F(S("PUNCH node to show protected area")) .. "]"
|
.. "label[0,1;" .. F(S("PUNCH node to show protected area")) .. "]"
|
||||||
.. "label[0,2;" .. F(S("Members:")) .. "]"
|
.. "label[0,1.5;" .. F(S("Members:")) .. "]"
|
||||||
.. "button_exit[2.5,6.2;3,0.5;close_me;" .. F(S("Close")) .. "]"
|
.. "button_exit[2.5,6.2;3,0.5;close_me;" .. F(S("Close")) .. "]"
|
||||||
.. "field_close_on_enter[protector_add_member;false]"
|
.. "field_close_on_enter[protector_add_member;false]"
|
||||||
|
|
||||||
local members = get_member_list(meta)
|
local members = get_member_list(meta)
|
||||||
local npp = protector_max_share_count -- max users added to protector list
|
local npp = protector_max_share_count -- max users added to protector list
|
||||||
local i = 0
|
|
||||||
local checkbox_faction = false
|
|
||||||
|
|
||||||
-- Display the checkbox only if the owner is member of at least 1 faction
|
|
||||||
if factions_available then
|
if factions_available then
|
||||||
|
formspec = formspec .. "label[0,4.25;" .. F(S("Factions:")) .. "]"
|
||||||
|
.. "field_close_on_enter[protector_add_faction;false]"
|
||||||
|
|
||||||
if factions.version == nil then
|
if npp > 8 then npp = 8 end
|
||||||
|
|
||||||
-- backward compatibility
|
|
||||||
if factions.get_player_faction(meta:get_string("owner")) then
|
|
||||||
checkbox_faction = true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local player_factions = factions.get_player_factions(meta:get_string("owner"))
|
|
||||||
|
|
||||||
if player_factions ~= nil and #player_factions >= 1 then
|
|
||||||
checkbox_faction = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if checkbox_faction then
|
|
||||||
|
|
||||||
formspec = formspec .. "checkbox[0,5;faction_members;"
|
|
||||||
.. F(S("Allow faction access"))
|
|
||||||
.. ";" .. (meta:get_int("faction_members") == 1 and
|
|
||||||
"true" or "false") .. "]"
|
|
||||||
|
|
||||||
if npp > 8 then
|
|
||||||
npp = 8
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local i = 0
|
||||||
for n = 1, #members do
|
for n = 1, #members do
|
||||||
|
|
||||||
if i < npp then
|
if i < npp then
|
||||||
|
|
||||||
-- show username
|
-- show username
|
||||||
formspec = formspec .. "button[" .. (i % 4 * 2)
|
formspec = formspec .. "button[" .. (i % 4 * 2)
|
||||||
.. "," .. math.floor(i / 4 + 3)
|
.. "," .. (math.floor(i / 4) + 2.5)
|
||||||
.. ";1.5,.5;protector_member;" .. F(members[n]) .. "]"
|
.. ";1.5,.5;protector_member;" .. F(members[n]) .. "]"
|
||||||
|
|
||||||
-- username remove button
|
-- username remove button
|
||||||
.. "button[" .. (i % 4 * 2 + 1.25) .. ","
|
.. "button[" .. (i % 4 * 2 + 1.25) .. ","
|
||||||
.. math.floor(i / 4 + 3)
|
.. (math.floor(i / 4) + 2.5)
|
||||||
.. ";.75,.5;protector_del_member_" .. F(members[n]) .. ";X]"
|
.. ";.75,.5;protector_del_member_" .. F(members[n]) .. ";X]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -228,47 +200,61 @@ local protector_formspec = function(meta)
|
||||||
|
|
||||||
-- user name entry field
|
-- user name entry field
|
||||||
formspec = formspec .. "field[" .. (i % 4 * 2 + 1 / 3) .. ","
|
formspec = formspec .. "field[" .. (i % 4 * 2 + 1 / 3) .. ","
|
||||||
.. (math.floor(i / 4 + 3) + 1 / 3)
|
.. (math.floor(i / 4) + 2.5 + 1 / 3)
|
||||||
.. ";1.433,.5;protector_add_member;;]"
|
.. ";1.433,.5;protector_add_member;;]"
|
||||||
|
|
||||||
-- username add button
|
-- username add button
|
||||||
.."button[" .. (i % 4 * 2 + 1.25) .. ","
|
.."button[" .. (i % 4 * 2 + 1.25) .. ","
|
||||||
.. math.floor(i / 4 + 3) .. ";.75,.5;protector_submit;+]"
|
.. (math.floor(i / 4) + 2.5) .. ";.75,.5;protector_submit;+]"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if factions_available then
|
||||||
|
local member_factions = get_faction_list(meta)
|
||||||
|
i = 0
|
||||||
|
for n = 1, #member_factions do
|
||||||
|
if i < 4 then
|
||||||
|
formspec = formspec .. "button[" .. (i % 4 * 2)
|
||||||
|
.. "," .. math.floor(i / 4 + 5)
|
||||||
|
.. ";1.5,.5;protector_faction;" .. F(member_factions[n]) .. "]"
|
||||||
|
.. "button[" .. (i % 4 * 2 + 1.25) .. ","
|
||||||
|
.. math.floor(i / 4 + 5)
|
||||||
|
.. ";.75,.5;protector_del_faction_" .. F(member_factions[n]) .. ";X]"
|
||||||
|
end
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
if i < 4 then
|
||||||
|
formspec = formspec .. "field[" .. (i % 4 * 2 + 1 / 3) .. ","
|
||||||
|
.. (math.floor(i / 4 + 5) + 1 / 3)
|
||||||
|
.. ";1.433,.5;protector_add_faction;;]"
|
||||||
|
.."button[" .. (i % 4 * 2 + 1.25) .. ","
|
||||||
|
.. math.floor(i / 4 + 5) .. ";.75,.5;protector_submit_faction;+]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- check if pos is inside a protected spawn area
|
-- check if pos is inside a protected spawn area
|
||||||
local inside_spawn = function(pos, radius)
|
|
||||||
|
|
||||||
if protector_spawn <= 0 then
|
local function inside_spawn(pos, radius)
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
if pos.x < statspawn.x + radius
|
if protector_spawn <= 0 then return false end
|
||||||
and pos.x > statspawn.x - radius
|
|
||||||
and pos.y < statspawn.y + radius
|
if pos.x < statspawn.x + radius and pos.x > statspawn.x - radius
|
||||||
and pos.y > statspawn.y - radius
|
and pos.y < statspawn.y + radius and pos.y > statspawn.y - radius
|
||||||
and pos.z < statspawn.z + radius
|
and pos.z < statspawn.z + radius and pos.z > statspawn.z - radius then
|
||||||
and pos.z > statspawn.z - radius then
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- show protection message if enabled
|
-- show protection message if enabled
|
||||||
local show_msg = function(player, msg)
|
|
||||||
|
local function show_msg(player, msg)
|
||||||
|
|
||||||
-- if messages disabled or no player name provided
|
-- if messages disabled or no player name provided
|
||||||
if protector_msg == false or not player or player == "" then
|
if protector_msg == false or not player or player == "" then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.chat_send_player(player, msg)
|
minetest.chat_send_player(player, msg)
|
||||||
end
|
end
|
||||||
|
|
@ -280,11 +266,9 @@ end
|
||||||
-- 2 for "This area is owned by <owner>.
|
-- 2 for "This area is owned by <owner>.
|
||||||
-- 3 for checking protector overlaps
|
-- 3 for checking protector overlaps
|
||||||
|
|
||||||
protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
function protector.can_dig(r, pos, digger, onlyowner, infolevel)
|
||||||
|
|
||||||
if not digger or not pos then
|
if not digger or not pos then return false end
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- protector_bypass privileged users can override protection
|
-- protector_bypass privileged users can override protection
|
||||||
if infolevel == 1
|
if infolevel == 1
|
||||||
|
|
@ -298,8 +282,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||||
-- is spawn area protected ?
|
-- is spawn area protected ?
|
||||||
if inside_spawn(pos, protector_spawn) then
|
if inside_spawn(pos, protector_spawn) then
|
||||||
|
|
||||||
show_msg(digger,
|
show_msg(digger, S("Spawn @1 has been protected up to a @2 block radius.",
|
||||||
S("Spawn @1 has been protected up to a @2 block radius.",
|
|
||||||
minetest.pos_to_string(statspawn), protector_spawn))
|
minetest.pos_to_string(statspawn), protector_spawn))
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
@ -325,8 +308,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||||
-- and you aren't on the member list
|
-- and you aren't on the member list
|
||||||
if onlyowner or not is_member(meta, digger) then
|
if onlyowner or not is_member(meta, digger) then
|
||||||
|
|
||||||
show_msg(digger,
|
show_msg(digger, S("This area is owned by @1", owner) .. "!")
|
||||||
S("This area is owned by @1", owner) .. "!")
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
@ -342,7 +324,6 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||||
S("Protection located at: @1", minetest.pos_to_string(pos[n])))
|
S("Protection located at: @1", minetest.pos_to_string(pos[n])))
|
||||||
|
|
||||||
if members ~= "" then
|
if members ~= "" then
|
||||||
|
|
||||||
minetest.chat_send_player(digger, S("Members: @1.", members))
|
minetest.chat_send_player(digger, S("Members: @1.", members))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -355,7 +336,6 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||||
if infolevel == 2 then
|
if infolevel == 2 then
|
||||||
|
|
||||||
if #pos < 1 then
|
if #pos < 1 then
|
||||||
|
|
||||||
minetest.chat_send_player(digger, S("This area is not protected."))
|
minetest.chat_send_player(digger, S("This area is not protected."))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -365,8 +345,8 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- add protector hurt and flip to protection violation function
|
-- add protector hurt and flip to protection violation function
|
||||||
|
|
||||||
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 player = minetest.get_player_by_name(name)
|
||||||
|
|
@ -401,21 +381,18 @@ minetest.register_on_protection_violation(function(pos, name)
|
||||||
local pla_pos = player:get_pos()
|
local pla_pos = player:get_pos()
|
||||||
|
|
||||||
if pos.y < pla_pos.y then
|
if pos.y < pla_pos.y then
|
||||||
|
player:set_pos({x = pla_pos.x, y = pla_pos.y + 0.8, z = pla_pos.z})
|
||||||
player:set_pos({
|
|
||||||
x = pla_pos.x,
|
|
||||||
y = pla_pos.y + 0.8,
|
|
||||||
z = pla_pos.z
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- backup old is_protected function
|
||||||
|
|
||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = minetest.is_protected
|
||||||
|
|
||||||
-- check for protected area, return true if protected and digger isn't on list
|
-- check for protected area, return true if protected and digger isn't on list
|
||||||
|
|
||||||
function minetest.is_protected(pos, digger)
|
function minetest.is_protected(pos, digger)
|
||||||
|
|
||||||
digger = digger or "" -- nil check
|
digger = digger or "" -- nil check
|
||||||
|
|
@ -429,13 +406,11 @@ function minetest.is_protected(pos, digger)
|
||||||
return old_is_protected(pos, digger)
|
return old_is_protected(pos, digger)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- make sure protection block doesn't overlap another protector's area
|
-- make sure protection block doesn't overlap another protector's area
|
||||||
local check_overlap = function(itemstack, placer, pointed_thing)
|
|
||||||
|
|
||||||
if pointed_thing.type ~= "node" then
|
local function check_overlap(itemstack, placer, pointed_thing)
|
||||||
return itemstack
|
|
||||||
end
|
if pointed_thing.type ~= "node" then return itemstack end
|
||||||
|
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
local name = placer:get_player_name()
|
local name = placer:get_player_name()
|
||||||
|
|
@ -460,35 +435,43 @@ local check_overlap = function(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- remove protector display entities
|
-- remove protector display entities
|
||||||
local del_display = function(pos)
|
|
||||||
|
local function del_display(pos)
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
||||||
|
|
||||||
for _, v in ipairs(objects) do
|
for _, v in ipairs(objects) do
|
||||||
|
|
||||||
if v and v:get_luaentity()
|
if v and v:get_luaentity() and v:get_luaentity().name == "protector:display" then
|
||||||
and v:get_luaentity().name == "protector:display" then
|
|
||||||
v:remove()
|
v:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- temporary pos store
|
-- temporary position store
|
||||||
|
|
||||||
local player_pos = {}
|
local player_pos = {}
|
||||||
|
|
||||||
|
-- stone texture
|
||||||
|
|
||||||
|
local stone_tex = "default_stone.png"
|
||||||
|
|
||||||
|
if minetest.get_modpath("nc_terrain") then
|
||||||
|
stone_tex = "nc_terrain_stone.png"
|
||||||
|
end
|
||||||
|
|
||||||
-- protection node
|
-- protection node
|
||||||
|
|
||||||
minetest.register_node("protector:protect", {
|
minetest.register_node("protector:protect", {
|
||||||
description = S("Protection Block") .. " (" .. S("USE for area check") .. ")",
|
description = S("Protection Block") .. " (" .. S("USE for area check") .. ")",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
"default_stone.png^protector_overlay.png",
|
stone_tex .. "^protector_overlay.png",
|
||||||
"default_stone.png^protector_overlay.png",
|
stone_tex .. "^protector_overlay.png",
|
||||||
"default_stone.png^protector_overlay.png^protector_logo.png"
|
stone_tex .. "^protector_overlay.png^protector_logo.png"
|
||||||
},
|
},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
groups = {dig_immediate = 2, unbreakable = 1},
|
groups = {dig_immediate = 2, unbreakable = 1},
|
||||||
|
|
@ -497,10 +480,7 @@ minetest.register_node("protector:protect", {
|
||||||
light_source = 4,
|
light_source = 4,
|
||||||
|
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed", fixed = {{-0.499 ,-0.499, -0.499, 0.499, 0.499, 0.499}}
|
||||||
fixed = {
|
|
||||||
{-0.499 ,-0.499, -0.499, 0.499, 0.499, 0.499}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
on_place = check_overlap,
|
on_place = check_overlap,
|
||||||
|
|
@ -517,9 +497,7 @@ minetest.register_node("protector:protect", {
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
protector.can_dig(protector_radius, pointed_thing.under,
|
protector.can_dig(protector_radius, pointed_thing.under,
|
||||||
user:get_player_name(), false, 2)
|
user:get_player_name(), false, 2)
|
||||||
|
|
@ -530,8 +508,7 @@ minetest.register_node("protector:protect", {
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local name = clicker:get_player_name()
|
local name = clicker:get_player_name()
|
||||||
|
|
||||||
if meta
|
if meta and protector.can_dig(1, pos, name, true, 1) then
|
||||||
and protector.can_dig(1, pos, name, true, 1) then
|
|
||||||
|
|
||||||
player_pos[name] = pos
|
player_pos[name] = pos
|
||||||
|
|
||||||
|
|
@ -541,9 +518,7 @@ minetest.register_node("protector:protect", {
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
|
||||||
if minetest.is_protected(pos, puncher:get_player_name()) then
|
if minetest.is_protected(pos, puncher:get_player_name()) then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.add_entity(pos, "protector:display")
|
minetest.add_entity(pos, "protector:display")
|
||||||
end,
|
end,
|
||||||
|
|
@ -559,32 +534,29 @@ minetest.register_node("protector:protect", {
|
||||||
})
|
})
|
||||||
|
|
||||||
-- default recipe and alternative for MineClone2
|
-- default recipe and alternative for MineClone2
|
||||||
|
|
||||||
if protector_recipe then
|
if protector_recipe then
|
||||||
|
|
||||||
if minetest.registered_items["default:stone"] then
|
local item_gold = "default:gold_ingot"
|
||||||
|
local item_stone = "default:stone"
|
||||||
|
|
||||||
minetest.register_craft({
|
if minetest.get_modpath("mcl_core") then
|
||||||
output = "protector:protect",
|
item_gold = "mcl_core:gold_ingot"
|
||||||
recipe = {
|
item_stone = "mcl_core:stone"
|
||||||
{"default:stone", "default:stone", "default:stone"},
|
|
||||||
{"default:stone", "default:gold_ingot", "default:stone"},
|
|
||||||
{"default:stone", "default:stone", "default:stone"}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
else
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "protector:protect",
|
|
||||||
recipe = {
|
|
||||||
{"mcl_core:stone", "mcl_core:stone", "mcl_core:stone"},
|
|
||||||
{"mcl_core:stone", "mcl_core:gold_ingot", "mcl_core:stone"},
|
|
||||||
{"mcl_core:stone", "mcl_core:stone", "mcl_core:stone"}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "protector:protect",
|
||||||
|
recipe = {
|
||||||
|
{item_stone, item_stone, item_stone},
|
||||||
|
{item_stone, item_gold, item_stone},
|
||||||
|
{item_stone, item_stone, item_stone}
|
||||||
|
}
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- protection logo
|
-- protection logo
|
||||||
|
|
||||||
minetest.register_node("protector:protect2", {
|
minetest.register_node("protector:protect2", {
|
||||||
description = S("Protection Logo") .. " (" .. S("USE for area check") .. ")",
|
description = S("Protection Logo") .. " (" .. S("USE for area check") .. ")",
|
||||||
tiles = {"protector_logo.png"},
|
tiles = {"protector_logo.png"},
|
||||||
|
|
@ -623,9 +595,7 @@ minetest.register_node("protector:protect2", {
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
protector.can_dig(protector_radius, pointed_thing.under,
|
protector.can_dig(protector_radius, pointed_thing.under,
|
||||||
user:get_player_name(), false, 2)
|
user:get_player_name(), false, 2)
|
||||||
|
|
@ -636,8 +606,7 @@ minetest.register_node("protector:protect2", {
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local name = clicker:get_player_name()
|
local name = clicker:get_player_name()
|
||||||
|
|
||||||
if meta
|
if meta and protector.can_dig(1, pos, name, true, 1) then
|
||||||
and protector.can_dig(1, pos, name, true, 1) then
|
|
||||||
|
|
||||||
player_pos[name] = pos
|
player_pos[name] = pos
|
||||||
|
|
||||||
|
|
@ -647,9 +616,7 @@ minetest.register_node("protector:protect2", {
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher)
|
on_punch = function(pos, node, puncher)
|
||||||
|
|
||||||
if minetest.is_protected(pos, puncher:get_player_name()) then
|
if minetest.is_protected(pos, puncher:get_player_name()) then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.add_entity(pos, "protector:display")
|
minetest.add_entity(pos, "protector:display")
|
||||||
end,
|
end,
|
||||||
|
|
@ -665,6 +632,7 @@ minetest.register_node("protector:protect2", {
|
||||||
})
|
})
|
||||||
|
|
||||||
-- recipes to switch between protectors
|
-- recipes to switch between protectors
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:protect",
|
output = "protector:protect",
|
||||||
recipe = {{"protector:protect2"}}
|
recipe = {{"protector:protect2"}}
|
||||||
|
|
@ -675,20 +643,16 @@ minetest.register_craft({
|
||||||
recipe = {{"protector:protect"}}
|
recipe = {{"protector:protect"}}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- check formspec buttons or when name entered
|
-- check formspec buttons or when name entered
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
if formname ~= "protector:node" then
|
if formname ~= "protector:node" then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local pos = player_pos[name]
|
local pos = player_pos[name]
|
||||||
|
|
||||||
if not name or not pos then
|
if not name or not pos then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local add_member_input = fields.protector_add_member
|
local add_member_input = fields.protector_add_member
|
||||||
|
|
||||||
|
|
@ -707,21 +671,26 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
-- are we adding member to a protection node ? (csm protection)
|
-- are we adding member to a protection node ? (csm protection)
|
||||||
local nod = minetest.get_node(pos).name
|
local nod = minetest.get_node(pos).name
|
||||||
|
|
||||||
if nod ~= "protector:protect"
|
if nod ~= "protector:protect" and nod ~= "protector:protect2" then
|
||||||
and nod ~= "protector:protect2" then
|
|
||||||
player_pos[name] = nil
|
player_pos[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos) ; if not meta then return end
|
||||||
|
|
||||||
if not meta then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- add faction members
|
-- add faction members
|
||||||
if factions_available and fields.faction_members ~= nil then
|
if factions_available then
|
||||||
meta:set_int("faction_members", fields.faction_members == "true" and 1 or 0)
|
local add_faction_input = fields.protector_add_faction
|
||||||
|
if add_faction_input and add_faction_input ~= "" then
|
||||||
|
for _, i in pairs(add_faction_input:split(" ")) do
|
||||||
|
add_faction(meta, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for field, value in pairs(fields) do
|
||||||
|
if string.sub(field, 0, string.len("protector_del_faction_")) == "protector_del_faction_" then
|
||||||
|
del_faction(meta, string.sub(field, string.len("protector_del_faction_") + 1))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add member [+]
|
-- add member [+]
|
||||||
|
|
@ -746,12 +715,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
minetest.show_formspec(name, formname, protector_formspec(meta))
|
minetest.show_formspec(name, formname, protector_formspec(meta))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- display entity shown when protector node is punched
|
-- display entity shown when protector node is punched
|
||||||
|
|
||||||
minetest.register_entity("protector:display", {
|
minetest.register_entity("protector:display", {
|
||||||
|
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
|
|
||||||
physical = false,
|
physical = false,
|
||||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||||
visual = "wielditem",
|
visual = "wielditem",
|
||||||
|
|
@ -768,17 +736,15 @@ minetest.register_entity("protector:display", {
|
||||||
self.timer = self.timer + dtime
|
self.timer = self.timer + dtime
|
||||||
|
|
||||||
-- remove after set number of seconds
|
-- remove after set number of seconds
|
||||||
if self.timer > protector_show then
|
if self.timer > protector_show then self.object:remove() end
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- Display-zone node, Do NOT place the display as a node,
|
-- Display-zone node, Do NOT place the display as a node,
|
||||||
-- it is made to be used as an entity (see above)
|
-- it is made to be used as an entity (see above)
|
||||||
|
|
||||||
local x = protector_radius
|
local x = protector_radius
|
||||||
|
|
||||||
minetest.register_node("protector:display_node", {
|
minetest.register_node("protector:display_node", {
|
||||||
tiles = {"protector_display.png"},
|
tiles = {"protector_display.png"},
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
|
|
@ -787,27 +753,22 @@ minetest.register_node("protector:display_node", {
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
-- sides
|
{-(x+.55), -(x+.55), -(x+.55), -(x+.45), (x+.55), (x+.55)}, -- sides
|
||||||
{-(x+.55), -(x+.55), -(x+.55), -(x+.45), (x+.55), (x+.55)},
|
|
||||||
{-(x+.55), -(x+.55), (x+.45), (x+.55), (x+.55), (x+.55)},
|
{-(x+.55), -(x+.55), (x+.45), (x+.55), (x+.55), (x+.55)},
|
||||||
{(x+.45), -(x+.55), -(x+.55), (x+.55), (x+.55), (x+.55)},
|
{(x+.45), -(x+.55), -(x+.55), (x+.55), (x+.55), (x+.55)},
|
||||||
{-(x+.55), -(x+.55), -(x+.55), (x+.55), (x+.55), -(x+.45)},
|
{-(x+.55), -(x+.55), -(x+.55), (x+.55), (x+.55), -(x+.45)},
|
||||||
-- top
|
{-(x+.55), (x+.45), -(x+.55), (x+.55), (x+.55), (x+.55)}, -- top
|
||||||
{-(x+.55), (x+.45), -(x+.55), (x+.55), (x+.55), (x+.55)},
|
{-(x+.55), -(x+.55), -(x+.55), (x+.55), -(x+.45), (x+.55)}, -- bottom
|
||||||
-- bottom
|
{-.55,-.55,-.55, .55,.55,.55} -- middle (surrounding protector)
|
||||||
{-(x+.55), -(x+.55), -(x+.55), (x+.55), -(x+.45), (x+.55)},
|
|
||||||
-- middle (surround protector)
|
|
||||||
{-.55,-.55,-.55, .55,.55,.55}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selection_box = {
|
selection_box = {type = "regular"},
|
||||||
type = "regular",
|
|
||||||
},
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = ""
|
drop = ""
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- load mod sections
|
||||||
|
|
||||||
dofile(MP .. "/doors_chest.lua")
|
dofile(MP .. "/doors_chest.lua")
|
||||||
dofile(MP .. "/pvp.lua")
|
dofile(MP .. "/pvp.lua")
|
||||||
|
|
@ -819,13 +780,13 @@ if minetest.get_modpath("lucky_block") then
|
||||||
dofile(MP .. "/lucky_block.lua")
|
dofile(MP .. "/lucky_block.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- stop mesecon pistons from pushing protectors
|
-- stop mesecon pistons from pushing protectors
|
||||||
|
|
||||||
if minetest.get_modpath("mesecons_mvps") then
|
if minetest.get_modpath("mesecons_mvps") then
|
||||||
mesecon.register_mvps_stopper("protector:protect")
|
mesecon.register_mvps_stopper("protector:protect")
|
||||||
mesecon.register_mvps_stopper("protector:protect2")
|
mesecon.register_mvps_stopper("protector:protect2")
|
||||||
|
mesecon.register_mvps_stopper("protector:protect_hidden")
|
||||||
mesecon.register_mvps_stopper("protector:chest")
|
mesecon.register_mvps_stopper("protector:chest")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
print ("[MOD] Protector Redo loaded")
|
print ("[MOD] Protector Redo loaded")
|
||||||
|
|
|
||||||
14
pvp.lua
14
pvp.lua
|
|
@ -1,18 +1,20 @@
|
||||||
|
|
||||||
local S = protector.intllib
|
|
||||||
|
|
||||||
-- get static spawn position
|
-- get static spawn position
|
||||||
|
|
||||||
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
|
local statspawn = minetest.string_to_pos(minetest.settings:get("static_spawnpoint"))
|
||||||
or {x = 0, y = 2, z = 0}
|
or {x = 0, y = 2, z = 0}
|
||||||
|
|
||||||
-- is spawn protected
|
-- is spawn protected
|
||||||
|
|
||||||
local protector_spawn = tonumber(minetest.settings:get("protector_spawn")
|
local protector_spawn = tonumber(minetest.settings:get("protector_spawn")
|
||||||
or minetest.settings:get("protector_pvp_spawn")) or 0
|
or minetest.settings:get("protector_pvp_spawn")) or 0
|
||||||
|
|
||||||
-- is night-only pvp enabled
|
-- is night-only pvp enabled
|
||||||
|
|
||||||
local protector_night_pvp = minetest.settings:get_bool("protector_night_pvp")
|
local protector_night_pvp = minetest.settings:get_bool("protector_night_pvp")
|
||||||
|
|
||||||
-- disables PVP in your own protected areas
|
-- disables PVP in your own protected areas
|
||||||
|
|
||||||
if minetest.settings:get_bool("enable_pvp")
|
if minetest.settings:get_bool("enable_pvp")
|
||||||
and minetest.settings:get_bool("protector_pvp") then
|
and minetest.settings:get_bool("protector_pvp") then
|
||||||
|
|
||||||
|
|
@ -21,15 +23,13 @@ and minetest.settings:get_bool("protector_pvp") then
|
||||||
minetest.register_on_punchplayer(function(player, hitter,
|
minetest.register_on_punchplayer(function(player, hitter,
|
||||||
time_from_last_punch, tool_capabilities, dir, damage)
|
time_from_last_punch, tool_capabilities, dir, damage)
|
||||||
|
|
||||||
if not player
|
if not player or not hitter then
|
||||||
or not hitter then
|
|
||||||
print("[MOD] Protector - on_punchplayer called with nil objects")
|
print("[MOD] Protector - on_punchplayer called with nil objects")
|
||||||
end
|
|
||||||
|
|
||||||
if not hitter:is_player() then
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not hitter:is_player() then return false end
|
||||||
|
|
||||||
-- no pvp at spawn area
|
-- no pvp at spawn area
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
|
|
|
||||||
31
tool.lua
31
tool.lua
|
|
@ -1,14 +1,18 @@
|
||||||
|
|
||||||
-- protector placement tool (thanks to Shara for code and idea)
|
-- protector placement tool (thanks to Shara for code and idea)
|
||||||
|
|
||||||
local S = protector.intllib
|
local S = minetest.get_translator("protector")
|
||||||
|
|
||||||
-- get protection radius
|
-- get protection radius
|
||||||
|
|
||||||
local r = tonumber(minetest.settings:get("protector_radius")) or 5
|
local r = tonumber(minetest.settings:get("protector_radius")) or 5
|
||||||
|
|
||||||
-- radius limiter (minetest cannot handle node volume of more than 4096000)
|
-- radius limiter (minetest cannot handle node volume of more than 4096000)
|
||||||
|
|
||||||
if r > 30 then r = 30 end
|
if r > 30 then r = 30 end
|
||||||
|
|
||||||
|
-- protector placement tool
|
||||||
|
|
||||||
minetest.register_craftitem("protector:tool", {
|
minetest.register_craftitem("protector:tool", {
|
||||||
description = S("Protector Placer Tool (stand near protector, face direction and use)"),
|
description = S("Protector Placer Tool (stand near protector, face direction and use)"),
|
||||||
inventory_image = "protector_tool.png",
|
inventory_image = "protector_tool.png",
|
||||||
|
|
@ -68,8 +72,7 @@ minetest.register_craftitem("protector:tool", {
|
||||||
end
|
end
|
||||||
|
|
||||||
-- does a protector already exist ?
|
-- does a protector already exist ?
|
||||||
if #minetest.find_nodes_in_area(
|
if #minetest.find_nodes_in_area(vector.subtract(pos, 1), vector.add(pos, 1),
|
||||||
vector.subtract(pos, 1), vector.add(pos, 1),
|
|
||||||
{"protector:protect", "protector:protect2",
|
{"protector:protect", "protector:protect2",
|
||||||
"protector:protect_hidden"}) > 0 then
|
"protector:protect_hidden"}) > 0 then
|
||||||
|
|
||||||
|
|
@ -78,8 +81,11 @@ minetest.register_craftitem("protector:tool", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- do not place protector out of map bounds
|
-- do not place protector out of map bounds or replace bedrock
|
||||||
if minetest.find_node_near(pos, 1, {"ignore", "mcl_core:bedrock"}) then
|
if #minetest.find_nodes_in_area(pos, pos, {"ignore", "mcl_core:bedrock"}) > 0 then
|
||||||
|
|
||||||
|
minetest.chat_send_player(name, S("Out of bounds!"))
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -114,17 +120,17 @@ minetest.register_craftitem("protector:tool", {
|
||||||
local inv = minetest.get_inventory({type = "node", pos = pos})
|
local inv = minetest.get_inventory({type = "node", pos = pos})
|
||||||
|
|
||||||
if inv then
|
if inv then
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name, S("Cannot place protector, container at") ..
|
||||||
S("Cannot place protector, container at") ..
|
|
||||||
" " .. minetest.pos_to_string(pos))
|
" " .. minetest.pos_to_string(pos))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- protection check for other mods like Areas
|
-- protection check for other mods like Areas
|
||||||
if minetest.is_protected(pos, name) then
|
if minetest.is_protected(pos, name) then
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
S("Cannot place protector, already protected at") ..
|
S("Cannot place protector, already protected at")
|
||||||
" " .. minetest.pos_to_string(pos))
|
.. " " .. minetest.pos_to_string(pos))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -147,18 +153,17 @@ minetest.register_craftitem("protector:tool", {
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
S("Protector placed at") ..
|
S("Protector placed at") ..
|
||||||
" " .. minetest.pos_to_string(pos))
|
" " .. minetest.pos_to_string(pos))
|
||||||
|
end
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- tool recipe
|
-- tool recipe
|
||||||
|
|
||||||
local df = "default:steel_ingot"
|
local df = "default:steel_ingot"
|
||||||
|
|
||||||
if not minetest.registered_items[df] then
|
if minetest.get_modpath("mcl_core") then
|
||||||
df = "mcl_core:iron_ingot"
|
df = "mcl_core:iron_ingot"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:tool",
|
output = "protector:tool",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue