Added protector mod support
This commit is contained in:
parent
f3828c1943
commit
c2bbdc7745
|
@ -36,6 +36,15 @@ local function inv_change(pos, count, player)
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function inv_change_protected(pos, count, player)
|
||||||
|
-- Skip check for pipeworks (fake player)
|
||||||
|
if minetest.is_player(player) and
|
||||||
|
minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
function technic.chests.inv_move(pos, from_list, from_index, to_list, to_index, count, player)
|
function technic.chests.inv_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
return inv_change(pos, count, player)
|
return inv_change(pos, count, player)
|
||||||
end
|
end
|
||||||
|
@ -46,6 +55,16 @@ function technic.chests.inv_take(pos, listname, index, stack, player)
|
||||||
return inv_change(pos, stack:get_count(), player)
|
return inv_change(pos, stack:get_count(), player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function technic.chests.inv_move_protected(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
return inv_change_protected(pos, count, player)
|
||||||
|
end
|
||||||
|
function technic.chests.inv_put_protected(pos, listname, index, stack, player)
|
||||||
|
return inv_change_protected(pos, stack:get_count(), player)
|
||||||
|
end
|
||||||
|
function technic.chests.inv_take_protected(pos, listname, index, stack, player)
|
||||||
|
return inv_change_protected(pos, stack:get_count(), player)
|
||||||
|
end
|
||||||
|
|
||||||
function technic.chests.on_inv_move(pos, from_list, from_index, to_list, to_index, count, player)
|
function technic.chests.on_inv_move(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 in chest at "
|
" moves stuff in chest at "
|
||||||
|
|
|
@ -17,11 +17,11 @@ minetest.register_craft({
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'technic:copper_locked_chest 1',
|
output = 'technic:copper_locked_chest 1',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'basic_materials:padlock'},
|
{'basic_materials:padlock'},
|
||||||
{'technic:copper_chest'},
|
{'technic:copper_chest'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.chests:register("Copper", {
|
technic.chests:register("Copper", {
|
||||||
|
@ -32,6 +32,7 @@ technic.chests:register("Copper", {
|
||||||
infotext = false,
|
infotext = false,
|
||||||
color = false,
|
color = false,
|
||||||
locked = false,
|
locked = false,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.chests:register("Copper", {
|
technic.chests:register("Copper", {
|
||||||
|
@ -42,5 +43,35 @@ technic.chests:register("Copper", {
|
||||||
infotext = false,
|
infotext = false,
|
||||||
color = false,
|
color = false,
|
||||||
locked = true,
|
locked = true,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if minetest.get_modpath("protector") then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:copper_protected_chest 1',
|
||||||
|
recipe = {
|
||||||
|
{'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
|
||||||
|
{'default:copper_ingot','technic:iron_protected_chest','default:copper_ingot'},
|
||||||
|
{'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:copper_protected_chest 1',
|
||||||
|
recipe = {
|
||||||
|
{'default:copper_ingot'},
|
||||||
|
{'technic:copper_chest'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
technic.chests:register("Copper", {
|
||||||
|
width = 12,
|
||||||
|
height = 5,
|
||||||
|
sort = true,
|
||||||
|
autosort = true,
|
||||||
|
infotext = false,
|
||||||
|
color = false,
|
||||||
|
locked = false,
|
||||||
|
protected = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
|
@ -5,3 +5,4 @@ moreores?
|
||||||
pipeworks?
|
pipeworks?
|
||||||
intllib?
|
intllib?
|
||||||
tubelib?
|
tubelib?
|
||||||
|
protector?
|
||||||
|
|
|
@ -25,6 +25,17 @@ for _, material in ipairs(material_list) do
|
||||||
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
|
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if minetest.get_modpath("protector") then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:gold_protected_chest',
|
||||||
|
recipe = {
|
||||||
|
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
|
||||||
|
{'default:gold_ingot',"technic:"..material.."_protected_chest",'default:gold_ingot'},
|
||||||
|
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -43,6 +54,7 @@ technic.chests:register("Gold", {
|
||||||
infotext = true,
|
infotext = true,
|
||||||
color = true,
|
color = true,
|
||||||
locked = false,
|
locked = false,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.chests:register("Gold", {
|
technic.chests:register("Gold", {
|
||||||
|
@ -53,5 +65,26 @@ technic.chests:register("Gold", {
|
||||||
infotext = true,
|
infotext = true,
|
||||||
color = true,
|
color = true,
|
||||||
locked = true,
|
locked = true,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if minetest.get_modpath("protector") then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:gold_protected_chest',
|
||||||
|
recipe = {
|
||||||
|
{'default:copper_ingot'},
|
||||||
|
{'technic:gold_chest'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
technic.chests:register("Gold", {
|
||||||
|
width = 15,
|
||||||
|
height = 6,
|
||||||
|
sort = true,
|
||||||
|
autosort = true,
|
||||||
|
infotext = true,
|
||||||
|
color = true,
|
||||||
|
locked = false,
|
||||||
|
protected = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
|
@ -39,6 +39,7 @@ technic.chests:register("Iron", {
|
||||||
infotext = false,
|
infotext = false,
|
||||||
color = false,
|
color = false,
|
||||||
locked = false,
|
locked = false,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.chests:register("Iron", {
|
technic.chests:register("Iron", {
|
||||||
|
@ -49,5 +50,35 @@ technic.chests:register("Iron", {
|
||||||
infotext = false,
|
infotext = false,
|
||||||
color = false,
|
color = false,
|
||||||
locked = true,
|
locked = true,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if minetest.get_modpath("protector") then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:iron_protected_chest 1',
|
||||||
|
recipe = {
|
||||||
|
{cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
|
||||||
|
{cast_iron_ingot,'protector:chest',cast_iron_ingot},
|
||||||
|
{cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:iron_protected_chest 1',
|
||||||
|
recipe = {
|
||||||
|
{'default:copper_ingot'},
|
||||||
|
{'technic:iron_chest'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
technic.chests:register("Iron", {
|
||||||
|
width = 9,
|
||||||
|
height = 5,
|
||||||
|
sort = true,
|
||||||
|
autosort = false,
|
||||||
|
infotext = false,
|
||||||
|
color = false,
|
||||||
|
locked = false,
|
||||||
|
protected = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
|
@ -16,6 +16,16 @@ if minetest.get_modpath("moreores") then
|
||||||
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
|
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if minetest.get_modpath("protector") then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:mithril_protected_chest 1',
|
||||||
|
recipe = {
|
||||||
|
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
|
||||||
|
{'moreores:mithril_ingot','technic:gold_protected_chest','moreores:mithril_ingot'},
|
||||||
|
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -34,6 +44,7 @@ technic.chests:register("Mithril", {
|
||||||
infotext = false,
|
infotext = false,
|
||||||
color = false,
|
color = false,
|
||||||
locked = false,
|
locked = false,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.chests:register("Mithril", {
|
technic.chests:register("Mithril", {
|
||||||
|
@ -44,5 +55,26 @@ technic.chests:register("Mithril", {
|
||||||
infotext = false,
|
infotext = false,
|
||||||
color = false,
|
color = false,
|
||||||
locked = true,
|
locked = true,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if minetest.get_modpath("protector") then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:mithril_protected_chest 1',
|
||||||
|
recipe = {
|
||||||
|
{'default:copper_ingot'},
|
||||||
|
{'technic:mithril_chest'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
technic.chests:register("Mithril", {
|
||||||
|
width = 15,
|
||||||
|
height = 6,
|
||||||
|
sort = true,
|
||||||
|
autosort = true,
|
||||||
|
infotext = false,
|
||||||
|
color = false,
|
||||||
|
locked = false,
|
||||||
|
protected = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
name = technic_chests
|
name = technic_chests
|
||||||
depends = default, basic_materials
|
depends = default, basic_materials
|
||||||
optional_depends = moreblocks, moreores, pipeworks, intllib, tubelib
|
optional_depends = moreblocks, moreores, pipeworks, intllib, tubelib, protector
|
||||||
|
|
|
@ -172,7 +172,10 @@ local function get_receive_fields(name, data)
|
||||||
end
|
end
|
||||||
if data.color then
|
if data.color then
|
||||||
-- This sets the node
|
-- This sets the node
|
||||||
local nn = "technic:"..lname..(data.locked and "_locked" or "").."_chest"
|
-- local nn = "technic:"..lname..(data.locked and "_locked" or "").."_chest"
|
||||||
|
local nn = "technic:"..name:lower()..
|
||||||
|
(data.locked and "_locked" or "")..
|
||||||
|
(data.protected and "_protected" or "").."_chest"
|
||||||
check_color_buttons(pos, meta, nn, fields)
|
check_color_buttons(pos, meta, nn, fields)
|
||||||
end
|
end
|
||||||
if fields["fs_helpers_cycling:0:splitstacks"]
|
if fields["fs_helpers_cycling:0:splitstacks"]
|
||||||
|
@ -240,14 +243,23 @@ function technic.chests:definition(name, data)
|
||||||
pipeworks.after_place(pos)
|
pipeworks.after_place(pos)
|
||||||
end
|
end
|
||||||
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
|
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
|
||||||
else
|
elseif data.protected then
|
||||||
|
locked_after_place = function(pos, _)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext",
|
||||||
|
S("%s Protected Chest"):format(name))
|
||||||
|
pipeworks.after_place(pos)
|
||||||
|
end
|
||||||
|
else
|
||||||
locked_after_place = pipeworks.after_place
|
locked_after_place = pipeworks.after_place
|
||||||
end
|
end
|
||||||
|
|
||||||
local desc
|
local desc
|
||||||
if data.locked then
|
if data.locked then
|
||||||
desc = S("%s Locked Chest"):format(name)
|
desc = S("%s Locked Chest"):format(name)
|
||||||
else
|
elseif data.protected then
|
||||||
|
desc = S("%s Protected Chest"):format(name)
|
||||||
|
else
|
||||||
desc = S("%s Chest"):format(name)
|
desc = S("%s Chest"):format(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -292,7 +304,10 @@ function technic.chests:definition(name, data)
|
||||||
on_blast = function(pos)
|
on_blast = function(pos)
|
||||||
local drops = {}
|
local drops = {}
|
||||||
default.get_inventory_drops(pos, "main", drops)
|
default.get_inventory_drops(pos, "main", drops)
|
||||||
drops[#drops+1] = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest"
|
-- drops[#drops+1] = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest"
|
||||||
|
drops[#drops+1] = "technic:"..name:lower()..
|
||||||
|
(data.locked and "_locked" or "")..
|
||||||
|
(data.protected and "_protected" or "").."_chest"
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return drops
|
return drops
|
||||||
end,
|
end,
|
||||||
|
@ -328,6 +343,37 @@ function technic.chests:definition(name, data)
|
||||||
return secret, "a locked chest", owner
|
return secret, "a locked chest", owner
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if data.protected then
|
||||||
|
def.allow_metadata_inventory_move = self.inv_move_protected
|
||||||
|
def.allow_metadata_inventory_put = self.inv_put_protected
|
||||||
|
def.allow_metadata_inventory_take = self.inv_take_protected
|
||||||
|
def.on_blast = function() end
|
||||||
|
def.can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:is_empty("main") and default.can_interact_with_node(player, pos)
|
||||||
|
end
|
||||||
|
def.on_skeleton_key_use = function(pos, player, newsecret)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
local name = player:get_player_name()
|
||||||
|
|
||||||
|
-- verify placer is owner of lockable chest
|
||||||
|
if owner ~= name then
|
||||||
|
minetest.record_protection_violation(pos, name)
|
||||||
|
minetest.chat_send_player(name, "You do not own this chest.")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local secret = meta:get_string("key_lock_secret")
|
||||||
|
if secret == "" then
|
||||||
|
secret = newsecret
|
||||||
|
meta:set_string("key_lock_secret", secret)
|
||||||
|
end
|
||||||
|
|
||||||
|
return secret, "a locked chest", owner
|
||||||
|
end
|
||||||
|
end
|
||||||
return def
|
return def
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -364,7 +410,9 @@ local _TUBELIB_CALLBACKS = {
|
||||||
function technic.chests:register(name, data)
|
function technic.chests:register(name, data)
|
||||||
local def = technic.chests:definition(name, data)
|
local def = technic.chests:definition(name, data)
|
||||||
|
|
||||||
local nn = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest"
|
local nn = "technic:"..name:lower()..
|
||||||
|
(data.locked and "_locked" or "")..
|
||||||
|
(data.protected and "_protected" or "").."_chest"
|
||||||
minetest.register_node(":"..nn, def)
|
minetest.register_node(":"..nn, def)
|
||||||
|
|
||||||
if tubelib_exists then
|
if tubelib_exists then
|
||||||
|
|
|
@ -16,6 +16,17 @@ if minetest.get_modpath("moreores") then
|
||||||
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
|
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if minetest.get_modpath("protector") then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:silver_protected_chest',
|
||||||
|
recipe = {
|
||||||
|
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
|
||||||
|
{'moreores:silver_ingot','technic:copper_protected_chest','moreores:silver_ingot'},
|
||||||
|
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -34,6 +45,7 @@ technic.chests:register("Silver", {
|
||||||
infotext = true,
|
infotext = true,
|
||||||
color = false,
|
color = false,
|
||||||
locked = false,
|
locked = false,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.chests:register("Silver", {
|
technic.chests:register("Silver", {
|
||||||
|
@ -44,5 +56,26 @@ technic.chests:register("Silver", {
|
||||||
infotext = true,
|
infotext = true,
|
||||||
color = false,
|
color = false,
|
||||||
locked = true,
|
locked = true,
|
||||||
|
protected = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if minetest.get_modpath("protector") then
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:silver_protected_chest',
|
||||||
|
recipe = {
|
||||||
|
{'default:copper_ingot'},
|
||||||
|
{'technic:silver_chest'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
technic.chests:register("Silver", {
|
||||||
|
width = 12,
|
||||||
|
height = 6,
|
||||||
|
sort = true,
|
||||||
|
autosort = true,
|
||||||
|
infotext = true,
|
||||||
|
color = false,
|
||||||
|
locked = false,
|
||||||
|
protected = true,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue