mirror of
https://github.com/minetest-mods/technic.git
synced 2025-02-23 07:10:19 +01:00
Merge branch 'protected-mithril-chest' into pandorabox
This commit is contained in:
commit
3ee090a7c1
@ -1152,7 +1152,7 @@ dig identical areas, one on each side of the square cross section.
|
||||
### forcefield emitter ###
|
||||
|
||||
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
|
||||
spherical or cubical shape, in either case centered on the emitter.
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- 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.
|
||||
|
||||
local S = technic.getter
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- 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
|
||||
|
||||
@ -18,7 +18,7 @@ minetest.register_craft({
|
||||
|
||||
local function get_water_flow(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
|
||||
end
|
||||
return 0
|
||||
|
@ -129,11 +129,11 @@ local tube = {
|
||||
}
|
||||
|
||||
local function add_on_off_buttons(meta, ltier, charge_percent)
|
||||
local formspec = ""
|
||||
if ltier == "mv" or ltier == "hv" then
|
||||
formspec = "image[1,1;1,2;technic_power_meter_bg.png"
|
||||
local formspec = "image[1,1;1,2;technic_power_meter_bg.png"
|
||||
.."^[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(
|
||||
meta,
|
||||
"image_button[3,2.0;1,0.6",
|
||||
|
@ -27,6 +27,8 @@ technic.chests.can_dig = function(pos, player)
|
||||
return inv:is_empty("main")
|
||||
end
|
||||
|
||||
-- utils for locked chest
|
||||
|
||||
local function inv_change(pos, count, player)
|
||||
-- Skip check for pipeworks (fake player)
|
||||
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)
|
||||
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)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in chest at "
|
||||
@ -63,4 +86,3 @@ function technic.chests.on_inv_take(pos, listname, index, stack, player)
|
||||
" takes " .. stack:get_name() ..
|
||||
" from chest at " .. minetest.pos_to_string(pos))
|
||||
end
|
||||
|
||||
|
@ -4,3 +4,5 @@ moreblocks?
|
||||
moreores?
|
||||
pipeworks?
|
||||
intllib?
|
||||
protector?
|
||||
areas?
|
@ -26,6 +26,7 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
-- plain chest
|
||||
technic.chests:register("Mithril", {
|
||||
width = 15,
|
||||
height = 6,
|
||||
@ -36,6 +37,7 @@ technic.chests:register("Mithril", {
|
||||
locked = false,
|
||||
})
|
||||
|
||||
-- owned locked chest
|
||||
technic.chests:register("Mithril", {
|
||||
width = 15,
|
||||
height = 6,
|
||||
@ -46,3 +48,23 @@ technic.chests:register("Mithril", {
|
||||
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
|
||||
|
@ -3,6 +3,8 @@ local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
||||
local pipeworks = rawget(_G, "pipeworks")
|
||||
local fs_helpers = rawget(_G, "fs_helpers")
|
||||
|
||||
local has_protector_mod = minetest.get_modpath("protector")
|
||||
|
||||
local allow_label = ""
|
||||
local tube_entry = ""
|
||||
local shift_edit_field = 0
|
||||
@ -248,14 +250,25 @@ function technic.chests:definition(name, data)
|
||||
:format(name, meta:get_string("owner")))
|
||||
pipeworks.after_place(pos)
|
||||
end
|
||||
table.insert(front, "technic_"..lname.."_chest_lock_overlay.png")
|
||||
else
|
||||
locked_after_place = pipeworks.after_place
|
||||
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
|
||||
if data.locked then
|
||||
desc = S("%s Locked Chest"):format(name)
|
||||
elseif data.protected then
|
||||
desc = S("%s Protected Chest"):format(name)
|
||||
else
|
||||
desc = S("%s Chest"):format(name)
|
||||
end
|
||||
@ -336,6 +349,16 @@ function technic.chests:definition(name, data)
|
||||
|
||||
return secret, "a locked chest", owner
|
||||
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
|
||||
return def
|
||||
end
|
||||
@ -343,7 +366,21 @@ end
|
||||
function technic.chests:register(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)
|
||||
|
||||
if data.color then
|
||||
@ -367,4 +404,3 @@ function technic.chests:register(name, data)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user