Merge branch 'protected-mithril-chest' into pandorabox

This commit is contained in:
Thomas Rudin 2019-02-01 21:24:08 +01:00
commit 3ee090a7c1
38 changed files with 188 additions and 106 deletions

View File

@ -1152,7 +1152,7 @@ dig identical areas, one on each side of the square cross section.
### forcefield emitter ### ### forcefield emitter ###
The forcefield emitter is an HV powered machine that generates a The forcefield emitter is an HV powered machine that generates a
forcefield remeniscent of those seen in many science-fiction stories. forcefield reminiscent of those seen in many science-fiction stories.
The emitter can be configured to generate a forcefield of either The emitter can be configured to generate a forcefield of either
spherical or cubical shape, in either case centered on the emitter. spherical or cubical shape, in either case centered on the emitter.

View File

@ -1,5 +1,5 @@
-- A water mill produces LV EUs by exploiting flowing water across it -- A water mill produces LV EUs by exploiting flowing water across it
-- It is a LV EU supplyer and fairly low yield (max 180EUs) -- It is a LV EU supplier and fairly low yield (max 180EUs)
-- It is a little over half as good as the thermal generator. -- It is a little over half as good as the thermal generator.
local S = technic.getter local S = technic.getter

View File

@ -1,5 +1,5 @@
-- A Hydro Turbine produces MV EUs by exploiting flowing water across it -- A Hydro Turbine produces MV EUs by exploiting flowing water across it
-- It is a MV EU supplyer and fairly high yield (max 1800EUs) -- It is a MV EU supplier and fairly high yield (max 1800EUs)
local S = technic.getter local S = technic.getter
@ -18,7 +18,7 @@ minetest.register_craft({
local function get_water_flow(pos) local function get_water_flow(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "water") == 3 then if minetest.get_item_group(node.name, "water") == 3 and string.find(node.name, "flowing") then
return node.param2 -- returns approx. water flow, if any return node.param2 -- returns approx. water flow, if any
end end
return 0 return 0

View File

@ -129,11 +129,11 @@ local tube = {
} }
local function add_on_off_buttons(meta, ltier, charge_percent) local function add_on_off_buttons(meta, ltier, charge_percent)
local formspec = "" local formspec = "image[1,1;1,2;technic_power_meter_bg.png"
if ltier == "mv" or ltier == "hv" then
formspec = "image[1,1;1,2;technic_power_meter_bg.png"
.."^[lowpart:"..charge_percent .."^[lowpart:"..charge_percent
..":technic_power_meter_fg.png]".. ..":technic_power_meter_fg.png]"
if ltier == "mv" or ltier == "hv" then
formspec = formspec..
fs_helpers.cycling_button( fs_helpers.cycling_button(
meta, meta,
"image_button[3,2.0;1,0.6", "image_button[3,2.0;1,0.6",

View File

@ -27,6 +27,8 @@ technic.chests.can_dig = function(pos, player)
return inv:is_empty("main") return inv:is_empty("main")
end end
-- utils for locked chest
local function inv_change(pos, count, player) local function inv_change(pos, count, player)
-- Skip check for pipeworks (fake player) -- Skip check for pipeworks (fake player)
if minetest.is_player(player) and if minetest.is_player(player) and
@ -46,6 +48,27 @@ 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
-- utils for protected chest
local function inv_change_protected(pos, count, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
return count
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
-- logging utils
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 "
@ -63,4 +86,3 @@ function technic.chests.on_inv_take(pos, listname, index, stack, player)
" takes " .. stack:get_name() .. " takes " .. stack:get_name() ..
" from chest at " .. minetest.pos_to_string(pos)) " from chest at " .. minetest.pos_to_string(pos))
end end

View File

@ -4,3 +4,5 @@ moreblocks?
moreores? moreores?
pipeworks? pipeworks?
intllib? intllib?
protector?
areas?

View File

@ -26,6 +26,7 @@ minetest.register_craft({
} }
}) })
-- plain chest
technic.chests:register("Mithril", { technic.chests:register("Mithril", {
width = 15, width = 15,
height = 6, height = 6,
@ -36,6 +37,7 @@ technic.chests:register("Mithril", {
locked = false, locked = false,
}) })
-- owned locked chest
technic.chests:register("Mithril", { technic.chests:register("Mithril", {
width = 15, width = 15,
height = 6, height = 6,
@ -46,3 +48,23 @@ technic.chests:register("Mithril", {
locked = true, locked = true,
}) })
if minetest.get_modpath("protector") or minetest.get_modpath("areas") then
-- protected chest (works with any protection mod that overrides minetest.is_protected)
technic.chests:register("Mithril", {
width = 15,
height = 6,
sort = true,
autosort = true,
infotext = false,
color = false,
protected = true,
})
minetest.register_craft({
output = 'technic:mithril_protected_chest 1',
recipe = {
{'basic_materials:padlock'},
{'technic:mithril_locked_chest'},
}
})
end

View File

@ -3,6 +3,8 @@ local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
local pipeworks = rawget(_G, "pipeworks") local pipeworks = rawget(_G, "pipeworks")
local fs_helpers = rawget(_G, "fs_helpers") local fs_helpers = rawget(_G, "fs_helpers")
local has_protector_mod = minetest.get_modpath("protector")
local allow_label = "" local allow_label = ""
local tube_entry = "" local tube_entry = ""
local shift_edit_field = 0 local shift_edit_field = 0
@ -248,14 +250,25 @@ function technic.chests:definition(name, data)
:format(name, meta:get_string("owner"))) :format(name, meta:get_string("owner")))
pipeworks.after_place(pos) pipeworks.after_place(pos)
end end
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
else else
locked_after_place = pipeworks.after_place locked_after_place = pipeworks.after_place
end end
if data.locked then
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
end
if data.protected and has_protector_mod then
-- use overlay from protector mod
table.insert(front, "protector_logo.png")
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)
elseif data.protected then
desc = S("%s Protected Chest"):format(name)
else else
desc = S("%s Chest"):format(name) desc = S("%s Chest"):format(name)
end end
@ -336,6 +349,16 @@ function technic.chests:definition(name, data)
return secret, "a locked chest", owner return secret, "a locked chest", owner
end end
elseif 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 not minetest.is_protected(pos, player:get_player_name())
end
end end
return def return def
end end
@ -343,7 +366,21 @@ end
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" -- prefix
local nn = "technic:"..name:lower()
if data.locked then
-- locked chest
nn = nn .. "_locked"
elseif data.protected then
-- protected chest
nn = nn .. "_protected"
end
-- suffix
nn = nn .. "_chest"
minetest.register_node(":"..nn, def) minetest.register_node(":"..nn, def)
if data.color then if data.color then
@ -367,4 +404,3 @@ function technic.chests:register(name, data)
end end
end end