Merge changes made in technic_game

This commit is contained in:
RealBadAngel 2013-07-06 10:35:48 +02:00
parent b78b90d422
commit 3a3700537b
54 changed files with 594 additions and 585 deletions

1
item_drop/depends.txt Normal file

@ -0,0 +1 @@
technic

@ -1,75 +1,38 @@
dofile(minetest.get_modpath("item_drop").."/item_entity.lua") dofile(minetest.get_modpath("item_drop").."/item_entity.lua")
time_pick = 3 time_pick = 3
if technic.config:getBool("enable_item_pickup") then
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
if player and player:get_hp() > 0 then
local pos = player:getpos() local pos = player:getpos()
pos.y = pos.y+0.5 pos.y = pos.y+0.5
local inv = player:get_inventory() local inv = player:get_inventory()
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then if not object:is_player() and object:get_luaentity() then
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then local obj=object:get_luaentity()
if object:get_luaentity().timer > time_pick then if obj.name == "__builtin:item" then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring)) if inv:room_for_item("main", ItemStack(obj.itemstring)) then
if object:get_luaentity().itemstring ~= "" then if obj.timer > time_pick then
minetest.sound_play("item_drop_pickup", { inv:add_item("main", ItemStack(obj.itemstring))
to_player = player:get_player_name(), if obj.itemstring ~= "" then
}) minetest.sound_play("item_drop_pickup",{pos = pos, gain = 1.0, max_hear_distance = 10})
end end
if object:get_luaentity() then
object:get_luaentity().itemstring = "" object:get_luaentity().itemstring = ""
object:remove() object:remove()
end end
end end
end end
end end
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 3)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
--print(dump(object:getpos().y-player:getpos().y))
if object:getpos().y-player:getpos().y > 0 then
if object:get_luaentity().collect then
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
if object:get_luaentity().timer > time_pick then
local pos1 = pos
pos1.y = pos1.y+0.2
local pos2 = object:getpos()
local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z}
vec.x = vec.x*3
vec.y = vec.y*3
vec.z = vec.z*3
object:setvelocity(vec)
minetest.after(1, function(args)
local lua = object:get_luaentity()
if object == nil or lua == nil or lua.itemstring == nil then
return
end
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
if object:get_luaentity().itemstring ~= "" then
minetest.sound_play("item_drop_pickup", {
to_player = player:get_player_name(),
})
end
object:get_luaentity().itemstring = ""
object:remove()
else
object:setvelocity({x=0,y=0,z=0})
end
end, {player, object})
end
end
else
minetest.after(0.5, function(entity)
entity.collect = true
end, object:get_luaentity())
end
end end
end end
end end
end end
end) end)
end
if technic.config:getBool("enable_item_drop") then
function minetest.handle_node_drops(pos, drops, digger) function minetest.handle_node_drops(pos, drops, digger)
for _,item in ipairs(drops) do for _,item in ipairs(drops) do
local count, name local count, name
@ -104,6 +67,8 @@ function minetest.handle_node_drops(pos, drops, digger)
end end
end end
end end
end
--[[ --[[
minetest.register_on_dieplayer(function(name, pos) minetest.register_on_dieplayer(function(name, pos)
local inv = name:get_inventory() local inv = name:get_inventory()

@ -62,15 +62,21 @@ minetest.register_entity(":__builtin:item", {
return minetest.serialize({ return minetest.serialize({
itemstring = self.itemstring, itemstring = self.itemstring,
always_collect = self.always_collect, always_collect = self.always_collect,
timer = self.timer,
}) })
end, end,
on_activate = function(self, staticdata) on_activate = function(self, staticdata, dtime_s)
if string.sub(staticdata, 1, string.len("return")) == "return" then if string.sub(staticdata, 1, string.len("return")) == "return" then
local data = minetest.deserialize(staticdata) local data = minetest.deserialize(staticdata)
if data and type(data) == "table" then if data and type(data) == "table" then
self.itemstring = data.itemstring self.itemstring = data.itemstring
self.always_collect = data.always_collect self.always_collect = data.always_collect
self.timer = data.timer
if not self.timer then
self.timer = 0
end
self.timer = self.timer+dtime_s
end end
else else
self.itemstring = staticdata self.itemstring = staticdata
@ -82,16 +88,77 @@ minetest.register_entity(":__builtin:item", {
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
local time = minetest.setting_get("remove_items")
if not time then
time = 300
end
if not self.timer then
self.timer = 0
end
self.timer = self.timer + dtime self.timer = self.timer + dtime
if (self.timer > 300) then if time ~= 0 and (self.timer > time) then
self.object:remove() self.object:remove()
end end
local p = self.object:getpos() local p = self.object:getpos()
local name = minetest.env:get_node(p).name
if name == "default:lava_flowing" or name == "default:lava_source" then
minetest.sound_play("builtin_item_lava", {pos=self.object:getpos(),gain = 1.0, max_hear_distance = 10})
self.object:remove()
return
end
if minetest.registered_nodes[name] and minetest.registered_nodes[name].liquidtype == "flowing" then
get_flowing_dir = function(self)
local pos = self.object:getpos()
local param2 = minetest.env:get_node(pos).param2
for i,d in ipairs({-1, 1, -1, 1}) do
if i<3 then
pos.x = pos.x+d
else
pos.z = pos.z+d
end
local name = minetest.env:get_node(pos).name
local par2 = minetest.env:get_node(pos).param2
if name == "default:water_flowing" and par2 < param2 then
return pos
end
if i<3 then
pos.x = pos.x-d
else
pos.z = pos.z-d
end
end
end
local vec = get_flowing_dir(self)
if vec then
local v = self.object:getvelocity()
if vec and vec.x-p.x > 0 then
self.object:setvelocity({x=0.5,y=v.y,z=0})
elseif vec and vec.x-p.x < 0 then
self.object:setvelocity({x=-0.5,y=v.y,z=0})
elseif vec and vec.z-p.z > 0 then
self.object:setvelocity({x=0,y=v.y,z=0.5})
elseif vec and vec.z-p.z < 0 then
self.object:setvelocity({x=0,y=v.y,z=-0.5})
end
self.object:setacceleration({x=0, y=-10, z=0})
self.physical_state = true
self.object:set_properties({
physical = true
})
return
end
end
p.y = p.y - 0.3 p.y = p.y - 0.3
local nn = minetest.env:get_node(p).name local nn = minetest.env:get_node(p).name
-- If node is not registered or node is walkably solid and resting on nodebox -- If node is not registered or node is walkably solid
local v = self.object:getvelocity() if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable and v.y == 0 then
if self.physical_state then if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0}) self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0}) self.object:setacceleration({x=0, y=0, z=0})
@ -114,13 +181,12 @@ minetest.register_entity(":__builtin:item", {
on_punch = function(self, hitter) on_punch = function(self, hitter)
if self.itemstring ~= '' then if self.itemstring ~= '' then
local left = hitter:get_inventory():add_item("main", self.itemstring) hitter:get_inventory():add_item("main", self.itemstring)
if not left:is_empty() then
self.itemstring = left:to_string()
return
end
end end
self.object:remove() self.object:remove()
end, end,
}) })
print("ITEM ENTITY LOADED")
if minetest.setting_get("log_mods") then
minetest.log("action", "builtin_item loaded")
end

@ -0,0 +1,126 @@
-- Minetest: builtin/item_entity.lua
function minetest.spawn_item(pos, item)
-- Take item in any format
local stack = ItemStack(item)
local obj = minetest.env:add_entity(pos, "__builtin:item")
obj:get_luaentity():set_item(stack:to_string())
return obj
end
minetest.register_entity(":__builtin:item", {
initial_properties = {
hp_max = 1,
physical = true,
collisionbox = {-0.17,-0.17,-0.17, 0.17,0.17,0.17},
visual = "sprite",
visual_size = {x=0.5, y=0.5},
textures = {""},
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0},
is_visible = false,
},
itemstring = '',
physical_state = true,
timer = 0,
set_item = function(self, itemstring)
self.itemstring = itemstring
local stack = ItemStack(itemstring)
local itemtable = stack:to_table()
local itemname = nil
if itemtable then
itemname = stack:to_table().name
end
local item_texture = nil
local item_type = ""
if minetest.registered_items[itemname] then
item_texture = minetest.registered_items[itemname].inventory_image
item_type = minetest.registered_items[itemname].type
end
prop = {
is_visible = true,
visual = "sprite",
textures = {"unknown_item.png"}
}
if item_texture and item_texture ~= "" then
prop.visual = "sprite"
prop.textures = {item_texture}
prop.visual_size = {x=0.50, y=0.50}
else
prop.visual = "wielditem"
prop.textures = {itemname}
prop.visual_size = {x=0.20, y=0.20}
prop.automatic_rotate = math.pi * 0.25
end
self.object:set_properties(prop)
end,
get_staticdata = function(self)
--return self.itemstring
return minetest.serialize({
itemstring = self.itemstring,
always_collect = self.always_collect,
})
end,
on_activate = function(self, staticdata)
if string.sub(staticdata, 1, string.len("return")) == "return" then
local data = minetest.deserialize(staticdata)
if data and type(data) == "table" then
self.itemstring = data.itemstring
self.always_collect = data.always_collect
end
else
self.itemstring = staticdata
end
self.object:set_armor_groups({immortal=1})
self.object:setvelocity({x=0, y=2, z=0})
self.object:setacceleration({x=0, y=-10, z=0})
self:set_item(self.itemstring)
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if (self.timer > 300) then
self.object:remove()
end
local p = self.object:getpos()
p.y = p.y - 0.3
local nn = minetest.env:get_node(p).name
-- If node is not registered or node is walkably solid and resting on nodebox
local v = self.object:getvelocity()
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable and v.y == 0 then
if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0})
self.physical_state = false
self.object:set_properties({
physical = false
})
end
else
if not self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=-10, z=0})
self.physical_state = true
self.object:set_properties({
physical = true
})
end
end
end,
on_punch = function(self, hitter)
if self.itemstring ~= '' then
local left = hitter:get_inventory():add_item("main", self.itemstring)
if not left:is_empty() then
self.itemstring = left:to_string()
return
end
end
self.object:remove()
end,
})
print("ITEM ENTITY LOADED")

@ -25,11 +25,14 @@ alloy_furnace_formspec =
"list[current_name;src2;3,2;1,1;]".. "list[current_name;src2;3,2;1,1;]"..
"list[current_name;dst;5,1;2,2;]".. "list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]".. "list[current_player;main;0,5;8,4;]"..
"label[0,0;Electric Alloy Furnace]".. "label[0,0;LV Electric Alloy Furnace]"..
"label[1,3;Power level]" "label[1,3;Power level]"..
"background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
"background[0,0;8,4;ui_lv_alloy_furnace.png]"..
"background[0,5;8,4;ui_main_inventory.png]"
minetest.register_node("technic:alloy_furnace", { minetest.register_node("technic:alloy_furnace", {
description = "Electric alloy furnace", description = "LV Electric alloy furnace",
tiles = {"technic_alloy_furnace_top.png", "technic_machine_bottom.png", "technic_alloy_furnace_side.png", tiles = {"technic_alloy_furnace_top.png", "technic_machine_bottom.png", "technic_alloy_furnace_side.png",
"technic_alloy_furnace_side.png", "technic_alloy_furnace_side.png", "technic_alloy_furnace_front.png"}, "technic_alloy_furnace_side.png", "technic_alloy_furnace_side.png", "technic_alloy_furnace_front.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
@ -106,15 +109,9 @@ minetest.register_abm({
internal_EU_buffer_size=meta:get_float("internal_EU_buffer") internal_EU_buffer_size=meta:get_float("internal_EU_buffer")
local load = math.floor(internal_EU_buffer/2000 * 100) local load = math.floor(internal_EU_buffer/2000 * 100)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[8,9;]".. alloy_furnace_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]".. (load)..":technic_power_meter_fg.png]")
"list[current_name;src;3,1;1,1;]"..
"list[current_name;src2;3,2;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"..
"label[0,0;Electric Alloy Furnace]"..
"label[1,3;Power level]")
local inv = meta:get_inventory() local inv = meta:get_inventory()

@ -54,13 +54,15 @@ battery_box_formspec =
"invsize[8,9;]".. "invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]".. "image[1,1;1,2;technic_power_meter_bg.png]"..
"list[current_name;src;3,1;1,1;]".. "list[current_name;src;3,1;1,1;]"..
"image[4,1;1,1;technic_battery_reload.png]"..
"list[current_name;dst;5,1;1,1;]".. "list[current_name;dst;5,1;1,1;]"..
"label[0,0;Battery box]".. "label[0,0;LV Battery Box]"..
"label[3,0;Charge]".. "label[3,0;Charge]"..
"label[5,0;Discharge]".. "label[5,0;Discharge]"..
"label[1,3;Power level]".. "label[1,3;Power level]"..
"list[current_player;main;0,5;8,4;]" "list[current_player;main;0,5;8,4;]"..
"background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
"background[0,0;8,4;ui_lv_battery_box.png]"..
"background[0,5;8,4;ui_main_inventory.png]"
minetest.register_node( minetest.register_node(
"technic:battery_box", { "technic:battery_box", {

@ -14,11 +14,14 @@ electric_furnace_formspec =
"list[current_name;src;3,1;1,1;]".. "list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]".. "list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]".. "list[current_player;main;0,5;8,4;]"..
"label[0,0;Electric Furnace]".. "label[0,0;LV Electric Furnace]"..
"label[1,3;Power level]" "label[1,3;Power level]"..
"background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
"background[0,0;8,4;ui_lv_electric_furnace.png]"..
"background[0,5;8,4;ui_main_inventory.png]"
minetest.register_node("technic:electric_furnace", { minetest.register_node("technic:electric_furnace", {
description = "Electric furnace", description = "LV Electric Furnace",
tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png", tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"}, "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
@ -32,7 +35,7 @@ minetest.register_node("technic:electric_furnace", {
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_float("technic_power_machine", 1) meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", electric_furnace_formspec) meta:set_string("formspec", electric_furnace_formspec)
meta:set_string("infotext", "Electric furnace") meta:set_string("infotext", "Electric Furnace")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("src", 1) inv:set_size("src", 1)
inv:set_size("dst", 4) inv:set_size("dst", 4)
@ -56,7 +59,7 @@ minetest.register_node("technic:electric_furnace", {
}) })
minetest.register_node("technic:electric_furnace_active", { minetest.register_node("technic:electric_furnace_active", {
description = "Electric Furnace", description = "LV Electric Furnace",
tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png", tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"}, "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
@ -72,7 +75,7 @@ minetest.register_node("technic:electric_furnace_active", {
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_float("technic_power_machine", 1) meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", electric_furnace_formspec) meta:set_string("formspec", electric_furnace_formspec)
meta:set_string("infotext", "Electric furnace"); meta:set_string("infotext", "LV Electric Furnace");
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("src", 1) inv:set_size("src", 1)
inv:set_size("dst", 4) inv:set_size("dst", 4)
@ -104,14 +107,9 @@ minetest.register_abm({
internal_EU_buffer_size=meta:get_float("internal_EU_buffer_size") internal_EU_buffer_size=meta:get_float("internal_EU_buffer_size")
local load = math.floor(internal_EU_buffer/internal_EU_buffer_size * 100) local load = math.floor(internal_EU_buffer/internal_EU_buffer_size * 100)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[8,9;]".. electric_furnace_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]".. (load)..":technic_power_meter_fg.png]")
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"..
"label[0,0;Electric Furnace]"..
"label[1,3;Power level]")
local inv = meta:get_inventory() local inv = meta:get_inventory()

@ -29,7 +29,6 @@ register_grinder_recipe("default:copper_ingot","technic:copper_dust 1")
register_grinder_recipe("default:gold_lump","technic:gold_dust 2") register_grinder_recipe("default:gold_lump","technic:gold_dust 2")
register_grinder_recipe("default:gold_ingot","technic:gold_dust 1") register_grinder_recipe("default:gold_ingot","technic:gold_dust 1")
--register_grinder_recipe("default:bronze_ingot","technic:bronze_dust 1") -- Dust does not exist yet --register_grinder_recipe("default:bronze_ingot","technic:bronze_dust 1") -- Dust does not exist yet
--register_grinder_recipe("home_decor:brass_ingot","technic:brass_dust 1") -- needs check for the mod
register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2") register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2")
register_grinder_recipe("moreores:tin_ingot","technic:tin_dust 1") register_grinder_recipe("moreores:tin_ingot","technic:tin_dust 1")
register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2") register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
@ -199,15 +198,18 @@ minetest.register_craftitem("technic:grinder", {
grinder_formspec = grinder_formspec =
"invsize[8,9;]".. "invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]".. "image[1,1;1,2;technic_power_meter_bg.png]"..
"label[0,0;Grinder]".. "label[0,0;LV Grinder]"..
"label[1,3;Power level]".. "label[1,3;Power level]"..
"list[current_name;src;3,1;1,1;]".. "list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]".. "list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]" "list[current_player;main;0,5;8,4;]"..
"background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
"background[0,0;8,4;ui_lv_grinder.png]"..
"background[0,5;8,4;ui_main_inventory.png]"
minetest.register_node("technic:grinder", { minetest.register_node("technic:grinder", {
description = "Grinder", description = "LV Grinder",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png", tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"}, "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
@ -279,15 +281,9 @@ minetest.register_abm({
local load = math.floor((charge/max_charge)*100) local load = math.floor((charge/max_charge)*100)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[8,9;]".. grinder_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]".. (load)..":technic_power_meter_fg.png]")
"label[0,0;Grinder]"..
"label[1,3;Power level]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local srclist = inv:get_list("src") local srclist = inv:get_list("src")

@ -10,7 +10,7 @@ minetest.register_craft({
recipe = { recipe = {
{'technic:stainless_steel_ingot', 'technic:diamond_drill_head', 'technic:stainless_steel_ingot'}, {'technic:stainless_steel_ingot', 'technic:diamond_drill_head', 'technic:stainless_steel_ingot'},
{'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'}, {'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'},
{'', 'technic:red_energy_crystal', 'default:copper_ingot'}, {'', 'technic:red_energy_crystal', 'moreores:copper_ingot'},
} }
}) })
minetest.register_craft({ minetest.register_craft({

@ -44,9 +44,13 @@ minetest.register_node(":technic:copper_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[10,9;]".. "invsize[10,10;]"..
"list[current_name;main;0,0;10,4;]".. "label[0,0;Copper Chest]"..
"list[current_player;main;0,5;8,4;]") "list[current_name;main;0,1;10,4;]"..
"list[current_player;main;0,6;8,4;]"..
"background[-0.19,-0.25;10.4,10.75;ui_form_bg.png]"..
"background[0,1;10,4;ui_copper_chest_inventory.png]"..
"background[0,6;8,4;ui_main_inventory.png]")
meta:set_string("infotext", "Copper Chest") meta:set_string("infotext", "Copper Chest")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 10*4) inv:set_size("main", 10*4)
@ -76,9 +80,13 @@ minetest.register_node(":technic:copper_locked_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[10,9;]".. "invsize[10,10;]"..
"list[current_name;main;0,0;10,4;]".. "label[0,0;Copper Locked Chest]"..
"list[current_player;main;0,5;8,4;]") "list[current_name;main;0,1;10,4;]"..
"list[current_player;main;0,6;8,4;]"..
"background[-0.19,-0.25;10.4,10.75;ui_form_bg.png]"..
"background[0,1;10,4;ui_copper_chest_inventory.png]"..
"background[0,6;8,4;ui_main_inventory.png]")
meta:set_string("infotext", "Copper Locked Chest") meta:set_string("infotext", "Copper Locked Chest")
meta:set_string("owner", "") meta:set_string("owner", "")
local inv = meta:get_inventory() local inv = meta:get_inventory()

@ -1,23 +1,24 @@
local chest_mark_colors = { local chest_mark_colors = {
'_black', {'_black','Black'},
'_blue', {'_blue','Blue'},
'_brown', {'_brown','Brown'},
'_cyan', {'_cyan','Cyan'},
'_dark_green', {'_dark_green','Dark Green'},
'_dark_grey', {'_dark_grey','Dark Grey'},
'_green', {'_green','Green'},
'_grey', {'_grey','Grey'},
'_magenta', {'_magenta','Magenta'},
'_orange', {'_orange','Orange'},
'_pink', {'_pink','Pink'},
'_red', {'_red','Red'},
'_violet', {'_violet','Violet'},
'_white', {'_white','White'},
'_yellow', {'_yellow','Yellow'},
{'','None'}
} }
minetest.register_craft({ minetest.register_craft({
output = 'technic:gold_chest 1', output = 'technic:gold_chest',
recipe = { recipe = {
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'}, {'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
{'default:gold_ingot','technic:silver_chest','default:gold_ingot'}, {'default:gold_ingot','technic:silver_chest','default:gold_ingot'},
@ -26,7 +27,7 @@ minetest.register_craft({
}) })
minetest.register_craft({ minetest.register_craft({
output = 'technic:gold_locked_chest 1', output = 'technic:gold_locked_chest',
recipe = { recipe = {
{'default:gold_ingot','default:gold_ingot','default:gold_ingot'}, {'default:gold_ingot','default:gold_ingot','default:gold_ingot'},
{'default:gold_ingot','technic:silver_locked_chest','default:gold_ingot'}, {'default:gold_ingot','technic:silver_locked_chest','default:gold_ingot'},
@ -35,7 +36,7 @@ minetest.register_craft({
}) })
minetest.register_craft({ minetest.register_craft({
output = 'technic:gold_locked_chest 1', output = 'technic:gold_locked_chest',
recipe = { recipe = {
{'default:steel_ingot'}, {'default:steel_ingot'},
{'technic:gold_chest'}, {'technic:gold_chest'},
@ -51,9 +52,24 @@ minetest.register_craftitem(":technic:gold_locked_chest", {
stack_max = 99, stack_max = 99,
}) })
gold_chest_formspec = "invsize[12,9;]".. function get_pallette_buttons ()
"list[current_name;main;0,0;12,4;]".. local buttons_string=""
"list[current_player;main;0,5;8,4;]" for y=0,3,1 do
for x=0,3,1 do
local file_name="ui_colorbutton"..(y*4+x)..".png"
buttons_string=buttons_string.."image_button["..(9.2+x*.7)..","..(6+y*.7)..";.81,.81;"..file_name..";color_button"..(y*4+x)..";]"
end
end
return buttons_string
end
gold_chest_formspec = "invsize[12,10;]"..
"list[current_name;main;0,1;12,4;]"..
"list[current_player;main;0,6;8,4;]"..
"background[-0.19,-0.25;12.4,10.75;ui_form_bg.png]"..
"background[0,1;12,4;ui_gold_chest_inventory.png]"..
"background[0,6;8,4;ui_main_inventory.png]"..
get_pallette_buttons ()
gold_chest_inv_size = 12*4 gold_chest_inv_size = 12*4
@ -69,7 +85,10 @@ minetest.register_node(":technic:gold_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",gold_chest_formspec) meta:set_string("formspec",gold_chest_formspec..
"label[0,0;Gold Chest]"..
"image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]"..
"label[9.2,9;Color Filter: None")
meta:set_string("infotext", "Gold Chest") meta:set_string("infotext", "Gold Chest")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", gold_chest_inv_size) inv:set_size("main", gold_chest_inv_size)
@ -77,16 +96,26 @@ minetest.register_node(":technic:gold_chest", {
can_dig = chest_can_dig, can_dig = chest_can_dig,
on_punch = function (pos, node, puncher)
chest_punched (pos,node,puncher);
end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos)
fields.text = fields.text or "" local page="main"
meta:set_string("text", fields.text) if fields.edit_infotext then
meta:set_string("infotext", '"'..fields.text..'"') page="edit_infotext"
meta:set_string("formspec",gold_chest_formspec) end
if fields.save_infotext then
meta:set_string("infotext",fields.infotext_box)
end
local formspec = gold_chest_formspec.."label[0,0;Gold Chest]"
if page=="main" then
formspec = formspec.."image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]"
formspec = formspec.."label[4,0;"..meta:get_string("infotext").."]"
end
if page=="edit_infotext" then
formspec = formspec.."image_button[3.5,.1;.6,.6;ok_icon.png;save_infotext;]"
formspec = formspec.."field[4.3,.2;6,1;infotext_box;Edit chest description:;"..meta:get_string("infotext").."]"
end
formspec = formspec .. "label[9.2,9;Color Filter: "..chest_mark_colors[check_color_buttons (pos,"technic:gold_chest",fields)][2].."]"
meta:set_string("formspec",formspec)
end, end,
on_metadata_inventory_move = def_on_metadata_inventory_move, on_metadata_inventory_move = def_on_metadata_inventory_move,
@ -94,37 +123,39 @@ minetest.register_node(":technic:gold_chest", {
on_metadata_inventory_take = def_on_metadata_inventory_take on_metadata_inventory_take = def_on_metadata_inventory_take
}) })
for i, state in ipairs(chest_mark_colors) do for i=1,15,1 do
minetest.register_node(":technic:gold_chest".. state, { minetest.register_node(":technic:gold_chest".. chest_mark_colors[i][1], {
description = "Gold Chest", description = "Gold Chest",
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png",
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front"..state..".png"}, "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front"..chest_mark_colors[i][1]..".png"},
paramtype2 = "facedir", paramtype2 = "facedir",
groups = chest_groups2, groups = chest_groups2,
tube = tubes_properties, tube = tubes_properties,
legacy_facedir_simple = true, legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
drop = "technic:gold_chest", drop = "technic:gold_chest",
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",gold_chest_formspec)
meta:set_string("infotext", "Gold Chest")
local inv = meta:get_inventory()
inv:set_size("main", gold_chest_inv_size)
end,
can_dig =chest_can_dig, can_dig =chest_can_dig,
on_punch = function (pos, node, puncher)
chest_punched (pos,node,puncher);
end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos)
fields.text = fields.text or "" local page="main"
meta:set_string("text", fields.text) if fields.edit_infotext then
meta:set_string("infotext", '"'..fields.text..'"') page="edit_infotext"
meta:set_string("formspec",gold_chest_formspec) end
if fields.save_infotext then
meta:set_string("infotext",fields.infotext_box)
end
local formspec = gold_chest_formspec.."label[0,0;Gold Chest]"
if page=="main" then
formspec = formspec.."image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]"
formspec = formspec.."label[4,0;"..meta:get_string("infotext").."]"
end
if page=="edit_infotext" then
formspec = formspec.."image_button[3.5,.1;.6,.6;ok_icon.png;save_infotext;]"
formspec = formspec.."field[4.3,.2;6,1;infotext_box;Edit chest description:;"..meta:get_string("infotext").."]"
end
formspec = formspec .. "label[9.2,9;Color Filter: "..chest_mark_colors[check_color_buttons (pos,"technic:gold_chest",fields)][2].."]"
meta:set_string("formspec",formspec)
end, end,
on_metadata_inventory_move = def_on_metadata_inventory_move, on_metadata_inventory_move = def_on_metadata_inventory_move,
@ -151,8 +182,11 @@ minetest.register_node(":technic:gold_locked_chest", {
end, end,
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",gold_chest_formspec) meta:set_string("formspec",
meta:set_string("infotext", "Gold Locked Chest") gold_chest_formspec..
"label[0,0;Gold Locked Chest]"..
"image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]"..
"label[9.2,9;Color Filter: None")
meta:set_string("owner", "") meta:set_string("owner", "")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", gold_chest_inv_size) inv:set_size("main", gold_chest_inv_size)
@ -160,19 +194,27 @@ minetest.register_node(":technic:gold_locked_chest", {
can_dig =chest_can_dig, can_dig =chest_can_dig,
on_punch = function (pos, node, puncher)
local meta = minetest.env:get_meta(pos);
if (has_locked_chest_privilege(meta, puncher)) then
locked_chest_punched (pos,node,puncher);
end
end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos)
fields.text = fields.text or "" local formspec = gold_chest_formspec..
meta:set_string("text", fields.text) "label[0,0;Gold Locked Chest]"
meta:set_string("infotext", '"'..fields.text..'"') local page="main"
meta:set_string("formspec",gold_chest_formspec) if fields.edit_infotext then
page="edit_infotext"
end
if fields.save_infotext then
meta:set_string("infotext",fields.infotext_box)
end
if page=="main" then
formspec = formspec.."image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]"
formspec = formspec.."label[4,0;"..meta:get_string("infotext").."]"
end
if page=="edit_infotext" then
formspec = formspec.."image_button[3.5,.1;.6,.6;ok_icon.png;save_infotext;]"
formspec = formspec.."field[4.3,.2;6,1;infotext_box;Edit chest description:;"..meta:get_string("infotext").."]"
end
formspec = formspec .. "label[9.2,9;Color Filter: "..chest_mark_colors[check_color_buttons (pos,"technic:gold_locked_chest",fields)][2].."]"
meta:set_string("formspec",formspec)
end, end,
allow_metadata_inventory_move = def_allow_metadata_inventory_move, allow_metadata_inventory_move = def_allow_metadata_inventory_move,
@ -183,47 +225,40 @@ minetest.register_node(":technic:gold_locked_chest", {
on_metadata_inventory_take = def_on_metadata_inventory_take on_metadata_inventory_take = def_on_metadata_inventory_take
}) })
for i, state in ipairs(chest_mark_colors) do for i=1,15,1 do
minetest.register_node(":technic:gold_locked_chest".. state, { minetest.register_node(":technic:gold_locked_chest".. chest_mark_colors[i][1], {
description = "Gold Locked Chest", description = "Gold Locked Chest",
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png",
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked"..state..".png"}, "technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked"..chest_mark_colors[i][1]..".png"},
paramtype2 = "facedir", paramtype2 = "facedir",
drop = "technic:gold_locked_chest", drop = "technic:gold_locked_chest",
groups = chest_groups2, groups = chest_groups2,
tube = tubes_properties, tube = tubes_properties,
legacy_facedir_simple = true, legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", "Gold Locked Chest (owned by "..
meta:get_string("owner")..")")
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",gold_chest_formspec)
meta:set_string("infotext", "Gold Locked Chest")
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", gold_chest_inv_size)
end,
can_dig = chest_can_dig, can_dig = chest_can_dig,
on_punch = function (pos, node, puncher)
local meta = minetest.env:get_meta(pos);
if (has_locked_chest_privilege(meta, puncher)) then
locked_chest_punched (pos,node,puncher);
end
end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos)
fields.text = fields.text or "" local formspec = gold_chest_formspec..
meta:set_string("text", fields.text) "label[0,0;Gold Locked Chest]"
meta:set_string("infotext", '"'..fields.text..'"') local page="main"
meta:set_string("formspec",gold_chest_formspec) if fields.edit_infotext then
page="edit_infotext"
end
if fields.save_infotext then
meta:set_string("infotext",fields.infotext_box)
end
if page=="main" then
formspec = formspec.."image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]"
formspec = formspec.."label[4,0;"..meta:get_string("infotext").."]"
end
if page=="edit_infotext" then
formspec = formspec.."image_button[3.5,.1;.6,.6;ok_icon.png;save_infotext;]"
formspec = formspec.."field[4.3,.2;6,1;infotext_box;Edit chest description:;"..meta:get_string("infotext").."]"
end
formspec = formspec .. "label[9.2,9;Color Filter: "..chest_mark_colors[check_color_buttons (pos,"technic:gold_locked_chest",fields)][2].."]"
meta:set_string("formspec",formspec)
end, end,
allow_metadata_inventory_move = def_allow_metadata_inventory_move, allow_metadata_inventory_move = def_allow_metadata_inventory_move,
@ -235,232 +270,18 @@ minetest.register_node(":technic:gold_locked_chest".. state, {
}) })
end end
function chest_punched (pos,node,puncher) function check_color_buttons (pos,chest_name,fields)
if fields.color_button15 then
local player_tool = puncher:get_wielded_item(); hacky_swap_node(pos,chest_name)
local item=player_tool:get_name(); return 16
if item == "dye:black" then end
if (hacky_swap_node(pos,"technic:gold_chest_black")) then for i=0,14,1 do
player_tool:take_item(1); local button="color_button"..i
puncher:set_wielded_item(player_tool); if fields[button] then
return hacky_swap_node(pos,chest_name..chest_mark_colors[i+1][1])
return i+1
end end
end end
if item == "dye:blue" then return 16
if (hacky_swap_node(pos,"technic:gold_chest_blue")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:brown" then
if (hacky_swap_node(pos,"technic:gold_chest_brown")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:cyan" then
if (hacky_swap_node(pos,"technic:gold_chest_cyan")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:dark_green" then
if (hacky_swap_node(pos,"technic:gold_chest_dark_green")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:dark_grey" then
if (hacky_swap_node(pos,"technic:gold_chest_dark_grey")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:green" then
if (hacky_swap_node(pos,"technic:gold_chest_green")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:grey" then
if (hacky_swap_node(pos,"technic:gold_chest_grey")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:magenta" then
if (hacky_swap_node(pos,"technic:gold_chest_magenta")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:orange" then
if (hacky_swap_node(pos,"technic:gold_chest_orange")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:pink" then
if (hacky_swap_node(pos,"technic:gold_chest_pink")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:red" then
if (hacky_swap_node(pos,"technic:gold_chest_red")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:violet" then
if (hacky_swap_node(pos,"technic:gold_chest_violet")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:white" then
if (hacky_swap_node(pos,"technic:gold_chest_white")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:yellow" then
if (hacky_swap_node(pos,"technic:gold_chest_yellow")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
local meta = minetest.env:get_meta(pos);
meta:set_string("formspec", "hack:sign_text_input")
end
function locked_chest_punched (pos,node,puncher)
local player_tool = puncher:get_wielded_item();
local item=player_tool:get_name();
if item == "dye:black" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_black")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:blue" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_blue")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:brown" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_brown")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:cyan" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_cyan")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:dark_green" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_dark_green")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:dark_grey" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_dark_grey")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:green" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_green")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:grey" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_grey")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:magenta" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_magenta")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:orange" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_orange")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:pink" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_pink")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:red" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_red")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:violet" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_violet")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:white" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_white")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
if item == "dye:yellow" then
if (hacky_swap_node(pos,"technic:gold_locked_chest_yellow")) then
player_tool:take_item(1);
puncher:set_wielded_item(player_tool);
return
end
end
local meta = minetest.env:get_meta(pos);
meta:set_string("formspec", "hack:sign_text_input")
end end

@ -46,9 +46,13 @@ minetest.register_node(":technic:iron_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[9,9;]".. "invsize[9,10;]"..
"list[current_name;main;0,0;9,4;]".. "label[0,0;Iron Chest]"..
"list[current_player;main;0,5;8,4;]") "list[current_name;main;0,1;9,4;]"..
"list[current_player;main;0,6;8,4;]"..
"background[-0.19,-0.25;9.4,10.75;ui_form_bg.png]"..
"background[0,1;9,4;ui_iron_chest_inventory.png]"..
"background[0,6;8,4;ui_main_inventory.png]")
meta:set_string("infotext", "Iron Chest") meta:set_string("infotext", "Iron Chest")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 9*4) inv:set_size("main", 9*4)
@ -77,9 +81,13 @@ minetest.register_node(":technic:iron_locked_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[9,9;]".. "invsize[9,10;]"..
"list[current_name;main;0,0;9,4;]".. "label[0,0;Iron Locked Chest]"..
"list[current_player;main;0,5;8,4;]") "list[current_name;main;0,1;9,4;]"..
"list[current_player;main;0,6;8,4;]"..
"background[-0.19,-0.25;9.4,10.75;ui_form_bg.png]"..
"background[0,1;9,4;ui_iron_chest_inventory.png]"..
"background[0,6;8,4;ui_main_inventory.png]")
meta:set_string("infotext", "Iron Locked Chest") meta:set_string("infotext", "Iron Locked Chest")
meta:set_string("owner", "") meta:set_string("owner", "")
local inv = meta:get_inventory() local inv = meta:get_inventory()

@ -35,9 +35,13 @@ minetest.register_node(":technic:mithril_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[13,9;]".. "invsize[13,10;]"..
"list[current_name;main;0,0;13,4;]".. "label[0,0;Mithril Chest]"..
"list[current_player;main;0,5;8,4;]") "list[current_name;main;0,1;13,4;]"..
"list[current_player;main;0,6;8,4;]"..
"background[-0.19,-0.25;13.4,10.75;ui_form_bg.png]"..
"background[0,1;13,4;ui_mithril_chest_inventory.png]"..
"background[0,6;8,4;ui_main_inventory.png]")
meta:set_string("infotext", "Mithril Chest") meta:set_string("infotext", "Mithril Chest")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 13*4) inv:set_size("main", 13*4)
@ -84,9 +88,13 @@ minetest.register_node(":technic:mithril_locked_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[13,9;]".. "invsize[13,10;]"..
"list[current_name;main;0,0;13,4;]".. "label[0,0;Mithril Locked Chest]"..
"list[current_player;main;0,5;8,4;]") "list[current_name;main;0,1;13,4;]"..
"list[current_player;main;0,6;8,4;]"..
"background[-0.19,-0.25;13.4,10.75;ui_form_bg.png]"..
"background[0,1;13,4;ui_mithril_chest_inventory.png]"..
"background[0,6;8,4;ui_main_inventory.png]")
meta:set_string("infotext", "Mithril Locked Chest") meta:set_string("infotext", "Mithril Locked Chest")
meta:set_string("owner", "") meta:set_string("owner", "")
local inv = meta:get_inventory() local inv = meta:get_inventory()

@ -1,5 +1,5 @@
minetest.register_craft({ minetest.register_craft({
output = 'technic:silver_chest 1', output = 'technic:silver_chest',
recipe = { recipe = {
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'}, {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
{'moreores:silver_ingot','technic:copper_chest','moreores:silver_ingot'}, {'moreores:silver_ingot','technic:copper_chest','moreores:silver_ingot'},
@ -8,7 +8,7 @@ minetest.register_craft({
}) })
minetest.register_craft({ minetest.register_craft({
output = 'technic:silver_locked_chest 1', output = 'technic:silver_locked_chest',
recipe = { recipe = {
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'}, {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
{'moreores:silver_ingot','technic:copper_locked_chest','moreores:silver_ingot'}, {'moreores:silver_ingot','technic:copper_locked_chest','moreores:silver_ingot'},
@ -17,7 +17,7 @@ minetest.register_craft({
}) })
minetest.register_craft({ minetest.register_craft({
output = 'technic:silver_locked_chest 1', output = 'technic:silver_locked_chest',
recipe = { recipe = {
{'default:steel_ingot'}, {'default:steel_ingot'},
{'technic:silver_chest'}, {'technic:silver_chest'},
@ -33,6 +33,14 @@ minetest.register_craftitem(":technic:silver_locked_chest", {
stack_max = 99, stack_max = 99,
}) })
silver_chest_formspec =
"invsize[11,10;]"..
"list[current_name;main;0,1;11,4;]"..
"list[current_player;main;0,6;8,4;]"..
"background[-0.19,-0.25;11.4,10.75;ui_form_bg.png]"..
"background[0,1;11,4;ui_silver_chest_inventory.png]"..
"background[0,6;8,4;ui_main_inventory.png]"
minetest.register_node(":technic:silver_chest", { minetest.register_node(":technic:silver_chest", {
description = "Silver Chest", description = "Silver Chest",
tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png", tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png",
@ -45,30 +53,34 @@ minetest.register_node(":technic:silver_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[11,9;]".. silver_chest_formspec..
"list[current_name;main;0,0;11,4;]".. "label[0,0;Silver Chest]"..
"list[current_player;main;0,5;8,4;]") "image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]")
meta:set_string("infotext", "Silver Chest") meta:set_string("infotext", "Silver Chest")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 11*4) inv:set_size("main", 11*4)
end, end,
can_dig = chest_can_dig, can_dig = chest_can_dig,
on_punch = function (pos, node, puncher)
local meta = minetest.env:get_meta(pos);
meta:set_string("formspec", "hack:sign_text_input")
end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos)
fields.text = fields.text or "" local page="main"
meta:set_string("text", fields.text) if fields.edit_infotext then
meta:set_string("infotext", '"'..fields.text..'"') page="edit_infotext"
end
meta:set_string("formspec", if fields.save_infotext then
"invsize[11,9;]".. meta:set_string("infotext",fields.infotext_box)
"list[current_name;main;0,0;11,4;]".. end
"list[current_player;main;0,5;8,4;]") local formspec = silver_chest_formspec.."label[0,0;Silver Chest]"
if page=="main" then
formspec = formspec.."image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]"
formspec = formspec.."label[4,0;"..meta:get_string("infotext").."]"
end
if page=="edit_infotext" then
formspec = formspec.."image_button[3.5,.1;.6,.6;ok_icon.png;save_infotext;]"
formspec = formspec.."field[4.3,.2;6,1;infotext_box;Edit chest description:;"..meta:get_string("infotext").."]"
end
meta:set_string("formspec",formspec)
end, end,
on_metadata_inventory_move = def_on_metadata_inventory_move, on_metadata_inventory_move = def_on_metadata_inventory_move,
@ -94,34 +106,36 @@ minetest.register_node(":technic:silver_locked_chest", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", meta:set_string("formspec",
"invsize[11,9;]".. silver_chest_formspec..
"list[current_name;main;0,0;11,4;]".. "label[0,0;Silver Locked Chest]"..
"list[current_player;main;0,5;8,4;]") "image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]")
meta:set_string("infotext", "Silver Locked Chest")
meta:set_string("owner", "") meta:set_string("owner", "")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 11*4) inv:set_size("main", 11*4)
end, end,
can_dig = chest_can_dig, can_dig = chest_can_dig,
on_punch = function (pos, node, puncher)
local meta = minetest.env:get_meta(pos);
meta:set_string("formspec", "hack:sign_text_input")
end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos)
fields.text = fields.text or "" local page="main"
meta:set_string("text", fields.text) if fields.edit_infotext then
meta:set_string("infotext", '"'..fields.text..'"') page="edit_infotext"
end
meta:set_string("formspec", if fields.save_infotext then
"invsize[11,9;]".. meta:set_string("infotext",fields.infotext_box)
"list[current_name;main;0,0;11,4;]".. end
"list[current_player;main;0,5;8,4;]") local formspec = silver_chest_formspec.."label[0,0;Silver Locked Chest]"
if page=="main" then
formspec = formspec.."image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]"
formspec = formspec.."label[4,0;"..meta:get_string("infotext").."]"
end
if page=="edit_infotext" then
formspec = formspec.."image_button[3.5,.1;.6,.6;ok_icon.png;save_infotext;]"
formspec = formspec.."field[4.3,.2;6,1;infotext_box;Edit chest description:;"..meta:get_string("infotext").."]"
end
meta:set_string("formspec",formspec)
end, end,
allow_metadata_inventory_move = def_allow_metadata_inventory_move, allow_metadata_inventory_move = def_allow_metadata_inventory_move,
allow_metadata_inventory_put = def_allow_metadata_inventory_put, allow_metadata_inventory_put = def_allow_metadata_inventory_put,
allow_metadata_inventory_take = def_allow_metadata_inventory_take, allow_metadata_inventory_take = def_allow_metadata_inventory_take,

@ -31,10 +31,9 @@ minetest.register_craftitem( ":technic:stainless_steel_ingot", {
inventory_image = "technic_stainless_steel_ingot.png", inventory_image = "technic_stainless_steel_ingot.png",
}) })
minetest.register_craftitem( ":technic:brass_ingot", { minetest.register_craftitem( ":group:brass_ingot", {
description = "Brass Ingot", description = "Brass Ingot",
inventory_image = "technic_brass_ingot.png", inventory_image = "technic_brass_ingot.png",
groups = {brass_ingot=1}
}) })
minetest.register_craft({ minetest.register_craft({
@ -86,14 +85,14 @@ minetest.register_craft({
}) })
minetest.register_craft({ minetest.register_craft({
output = "node technic:brass_block", output = "node group:brass_block",
recipe = {{"group:brass_ingot", "group:brass_ingot", "group:brass_ingot"}, recipe = {{"group:brass_ingot", "group:brass_ingot", "group:brass_ingot"},
{"group:brass_ingot", "group:brass_ingot", "group:brass_ingot"}, {"group:brass_ingot", "group:brass_ingot", "group:brass_ingot"},
{"group:brass_ingot", "group:brass_ingot", "group:brass_ingot"}} {"group:brass_ingot", "group:brass_ingot", "group:brass_ingot"}}
}) })
minetest.register_craft({ minetest.register_craft({
output = "craft technic:brass_ingot 9", output = "craft group:brass_ingot 9",
recipe = {{"group:brass_block"}} recipe = {{"group:brass_block"}}
}) })

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB