dofile(minetest.get_modpath("item_drop").."/item_entity.lua")
time_pick = 3
-minetest.register_globalstep(function(dtime)
- for _,player in ipairs(minetest.get_connected_players()) do
- local pos = player:getpos()
- pos.y = pos.y+0.5
- local inv = player:get_inventory()
- for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
- if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
- if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
- if object:get_luaentity().timer > time_pick 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()
- 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})
+
+if technic.config:getBool("enable_item_pickup") then
+ minetest.register_globalstep(function(dtime)
+ for _,player in ipairs(minetest.get_connected_players()) do
+ if player and player:get_hp() > 0 then
+ local pos = player:getpos()
+ pos.y = pos.y+0.5
+ local inv = player:get_inventory()
+ for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
+ if not object:is_player() and object:get_luaentity() then
+ local obj=object:get_luaentity()
+ if obj.name == "__builtin:item" then
+ if inv:room_for_item("main", ItemStack(obj.itemstring)) then
+ if obj.timer > time_pick then
+ inv:add_item("main", ItemStack(obj.itemstring))
+ if obj.itemstring ~= "" then
+ minetest.sound_play("item_drop_pickup",{pos = pos, gain = 1.0, max_hear_distance = 10})
+ end
+ if object:get_luaentity() then
+ object:get_luaentity().itemstring = ""
+ object:remove()
+ end
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
-function minetest.handle_node_drops(pos, drops, digger)
- for _,item in ipairs(drops) do
- local count, name
- if type(item) == "string" then
- count = 1
- name = item
- else
- count = item:get_count()
- name = item:get_name()
- end
- for i=1,count do
- local obj = minetest.env:add_item(pos, name)
- if obj ~= nil then
- obj:get_luaentity().collect = true
- local x = math.random(1, 5)
- if math.random(1,2) == 1 then
- x = -x
- end
- local z = math.random(1, 5)
- if math.random(1,2) == 1 then
- z = -z
- end
- obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
- obj:get_luaentity().timer = time_pick
- -- FIXME this doesnt work for deactiveted objects
- if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
- minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
- obj:remove()
- end, obj)
+if technic.config:getBool("enable_item_drop") then
+ function minetest.handle_node_drops(pos, drops, digger)
+ for _,item in ipairs(drops) do
+ local count, name
+ if type(item) == "string" then
+ count = 1
+ name = item
+ else
+ count = item:get_count()
+ name = item:get_name()
+ end
+ for i=1,count do
+ local obj = minetest.env:add_item(pos, name)
+ if obj ~= nil then
+ obj:get_luaentity().collect = true
+ local x = math.random(1, 5)
+ if math.random(1,2) == 1 then
+ x = -x
+ end
+ local z = math.random(1, 5)
+ if math.random(1,2) == 1 then
+ z = -z
+ end
+ obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
+ obj:get_luaentity().timer = time_pick
+ -- FIXME this doesnt work for deactiveted objects
+ if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
+ minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
+ obj:remove()
+ end, obj)
+ end
end
end
end
end
end
+
--[[
minetest.register_on_dieplayer(function(name, pos)
local inv = name:get_inventory()
end
end)
]]--
-print("DROPS LOADED!")
\ No newline at end of file
+print("DROPS LOADED!")
itemstring = '',
physical_state = true,
timer = 0,
-
+
set_item = function(self, itemstring)
self.itemstring = itemstring
local stack = ItemStack(itemstring)
return minetest.serialize({
itemstring = self.itemstring,
always_collect = self.always_collect,
+ timer = self.timer,
})
end,
- on_activate = function(self, staticdata)
+ on_activate = function(self, staticdata, dtime_s)
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
+ self.timer = data.timer
+ if not self.timer then
+ self.timer = 0
+ end
+ self.timer = self.timer+dtime_s
end
else
self.itemstring = staticdata
self.object:setacceleration({x=0, y=-10, z=0})
self:set_item(self.itemstring)
end,
-
+
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
- if (self.timer > 300) then
+ if time ~= 0 and (self.timer > time) then
self.object:remove()
end
+
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
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 node is not registered or node is walkably solid
+ if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0})
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
+ hitter:get_inventory():add_item("main", self.itemstring)
end
self.object:remove()
end,
})
-print("ITEM ENTITY LOADED")
+
+if minetest.setting_get("log_mods") then
+ minetest.log("action", "builtin_item loaded")
+end
--- /dev/null
+-- 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")
minetest.register_craft({
output = 'technic:alloy_furnace',
recipe = {
- {'default:brick', 'default:brick', 'default:brick'},
- {'default:brick', '', 'default:brick'},
+ {'default:brick', 'default:brick', 'default:brick'},
+ {'default:brick', '', 'default:brick'},
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
}
})
"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]"
+ "label[0,0;LV Electric Alloy Furnace]"..
+ "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", {
- description = "Electric alloy furnace",
+ description = "LV Electric alloy furnace",
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"},
paramtype2 = "facedir",
internal_EU_buffer_size=meta:get_float("internal_EU_buffer")
local load = math.floor(internal_EU_buffer/2000 * 100)
meta:set_string("formspec",
- "invsize[8,9;]"..
+ alloy_furnace_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
- (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]")
+ (load)..":technic_power_meter_fg.png]")
local inv = meta:get_inventory()
output = 'technic:battery 1',
recipe = {
{'default:wood', 'default:copper_ingot', 'default:wood'},
- {'default:wood', 'moreores:tin_ingot', 'default:wood'},
+ {'default:wood', 'moreores:tin_ingot', 'default:wood'},
{'default:wood', 'default:copper_ingot', 'default:wood'},
}
})
battery_box_formspec =
- "invsize[8,9;]"..
- "image[1,1;1,2;technic_power_meter_bg.png]"..
- "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;]"..
- "label[0,0;Battery box]"..
- "label[3,0;Charge]"..
- "label[5,0;Discharge]"..
- "label[1,3;Power level]"..
- "list[current_player;main;0,5;8,4;]"
+ "invsize[8,9;]"..
+ "image[1,1;1,2;technic_power_meter_bg.png]"..
+ "list[current_name;src;3,1;1,1;]"..
+ "list[current_name;dst;5,1;1,1;]"..
+ "label[0,0;LV Battery Box]"..
+ "label[3,0;Charge]"..
+ "label[5,0;Discharge]"..
+ "label[1,3;Power level]"..
+ "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(
"technic:battery_box", {
output = 'technic:chainsaw',
recipe = {
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'},
- {'technic:stainless_steel_ingot', 'technic:motor', 'technic:battery'},
- {'', '', 'default:copper_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:motor', 'technic:battery'},
+ {'','','default:copper_ingot'},
}
})
output = 'technic:battery 1',
recipe = {
{'default:wood', 'default:copper_ingot', 'default:wood'},
- {'default:wood', 'moreores:tin_ingot', 'default:wood'},
+ {'default:wood', 'moreores:tin_ingot', 'default:wood'},
{'default:wood', 'default:copper_ingot', 'default:wood'},
}
})
minetest.register_craft({
output = 'technic:battery_box 1',
recipe = {
- {'technic:battery', 'default:wood', 'technic:battery'},
- {'technic:battery', 'default:copper_ingot', 'technic:battery'},
- {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
+ {'technic:battery', 'default:wood', 'technic:battery'},
+ {'technic:battery', 'default:copper_ingot', 'technic:battery'},
+ {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
}
})
minetest.register_craft({
output = 'technic:electric_furnace',
recipe = {
- {'default:brick', 'default:brick', 'default:brick'},
- {'default:brick', '', 'default:brick'},
+ {'default:brick', 'default:brick', 'default:brick'},
+ {'default:brick', '', 'default:brick'},
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
}
})
"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]"
+ "label[0,0;LV Electric Furnace]"..
+ "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", {
- description = "Electric furnace",
+ description = "LV Electric Furnace",
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"},
paramtype2 = "facedir",
local meta = minetest.env:get_meta(pos)
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", electric_furnace_formspec)
- meta:set_string("infotext", "Electric furnace")
+ meta:set_string("infotext", "Electric Furnace")
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
})
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",
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
paramtype2 = "facedir",
local meta = minetest.env:get_meta(pos)
meta:set_float("technic_power_machine", 1)
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()
inv:set_size("src", 1)
inv:set_size("dst", 4)
internal_EU_buffer_size=meta:get_float("internal_EU_buffer_size")
local load = math.floor(internal_EU_buffer/internal_EU_buffer_size * 100)
meta:set_string("formspec",
- "invsize[8,9;]"..
+ electric_furnace_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
- (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]")
+ (load)..":technic_power_meter_fg.png]")
local inv = meta:get_inventory()
minetest.register_craft({
output = 'technic:generator',
recipe = {
- {'default:stone', 'default:stone', 'default:stone'},
- {'default:stone', '', 'default:stone'},
+ {'default:stone', 'default:stone', 'default:stone'},
+ {'default:stone', '', 'default:stone'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
register_grinder_recipe("default:gold_lump","technic:gold_dust 2")
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("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_ingot","technic:tin_dust 1")
register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
register_grinder_recipe("technic:chromium_ingot","technic:chromium_dust 1")
register_grinder_recipe("technic:stainless_steel_ingot","stainless_steel_dust 1")
register_grinder_recipe("technic:brass_ingot","technic:brass_dust 1")
-register_grinder_recipe("homedecor:brass_ingot","technic:brass_dust 1")
+register_grinder_recipe("homedecor:brass_ingot","technic:brass_dust 1")
register_grinder_recipe("technic:zinc_lump","technic:zinc_dust 2")
register_grinder_recipe("technic:zinc_ingot","technic:zinc_dust 1")
register_grinder_recipe("technic:coal_dust","dye:black 2")
output = 'technic:grinder',
recipe = {
{'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
- {'default:desert_stone', 'default:diamond', 'default:desert_stone'},
- {'default:stone', 'default:copper_ingot', 'default:stone'},
+ {'default:desert_stone', 'default:diamond', 'default:desert_stone'},
+ {'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
grinder_formspec =
"invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
- "label[0,0;Grinder]"..
+ "label[0,0;LV 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;]"
+ "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", {
- description = "Grinder",
+ description = "LV Grinder",
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"},
paramtype2 = "facedir",
local load = math.floor((charge/max_charge)*100)
meta:set_string("formspec",
- "invsize[8,9;]"..
+ grinder_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
- (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;]"
- )
+ (load)..":technic_power_meter_fg.png]")
local inv = meta:get_inventory()
local srclist = inv:get_list("src")
minetest.register_craft({
output = 'technic:mining_drill',
recipe = {
- {'technic:stainless_steel_ingot', 'technic:diamond_drill_head', 'technic:stainless_steel_ingot'},
- {'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'},
- {'', 'technic:red_energy_crystal', 'default:copper_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:diamond_drill_head', 'technic:stainless_steel_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'},
+ {'', 'technic:red_energy_crystal', 'moreores:copper_ingot'},
}
})
minetest.register_craft({
output = 'technic:mining_drill_mk2',
recipe = {
- {'technic:diamond_drill_head', 'technic:diamond_drill_head', 'technic:diamond_drill_head'},
- {'technic:stainless_steel_ingot', 'technic:mining_drill', 'technic:stainless_steel_ingot'},
- {'', 'technic:green_energy_crystal', ''},
+ {'technic:diamond_drill_head', 'technic:diamond_drill_head', 'technic:diamond_drill_head'},
+ {'technic:stainless_steel_ingot', 'technic:mining_drill', 'technic:stainless_steel_ingot'},
+ {'', 'technic:green_energy_crystal', ''},
}
})
minetest.register_craft({
output = 'technic:mining_drill_mk3',
recipe = {
- {'technic:diamond_drill_head', 'technic:diamond_drill_head', 'technic:diamond_drill_head'},
- {'technic:stainless_steel_ingot', 'technic:mining_drill_mk2', 'technic:stainless_steel_ingot'},
- {'', 'technic:blue_energy_crystal', ''},
+ {'technic:diamond_drill_head', 'technic:diamond_drill_head', 'technic:diamond_drill_head'},
+ {'technic:stainless_steel_ingot', 'technic:mining_drill_mk2', 'technic:stainless_steel_ingot'},
+ {'', 'technic:blue_energy_crystal', ''},
}
})
output = 'technic:laser_mk1',
recipe = {
{'default:diamond', 'default:steel_ingot', 'technic:battery'},
- {'', 'default:steel_ingot', 'technic:battery'},
- {'', '', 'default:copper_ingot'},
+ {'', 'default:steel_ingot', 'technic:battery'},
+ {'', '', 'default:copper_ingot'},
}
})
minetest.register_craft({
output = 'technic:music_player',
recipe = {
- {'default:wood', 'default:wood', 'default:wood'},
- {'default:diamond', 'default:diamond', 'default:diamond'},
- {'default:stone', 'default:copper_ingot', 'default:stone'},
+ {'default:wood', 'default:wood', 'default:wood'},
+ {'default:diamond', 'default:diamond', 'default:diamond'},
+ {'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
minetest.register_craft({
output = 'technic:tool_workshop',
recipe = {
- {'default:wood', 'default:wood', 'default:wood'},
- {'default:wood', 'default:diamond', 'default:wood'},
+ {'default:wood', 'default:wood', 'default:wood'},
+ {'default:wood', 'default:diamond', 'default:wood'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
minetest.register_craft({
output = 'technic:water_mill',
recipe = {
- {'default:stone', 'default:stone', 'default:stone'},
- {'default:wood', 'default:diamond', 'default:wood'},
+ {'default:stone', 'default:stone', 'default:stone'},
+ {'default:wood', 'default:diamond', 'default:wood'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
minetest.register_craft({
output = 'technic:copper_chest 1',
recipe = {
- {'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
- {'default:copper_ingot', 'technic:iron_chest', 'default:copper_ingot'},
- {'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
+ {'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
+ {'default:copper_ingot','technic:iron_chest','default:copper_ingot'},
+ {'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
}
})
minetest.register_craft({
output = 'technic:copper_locked_chest 1',
recipe = {
- {'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
- {'default:copper_ingot', 'technic:iron_locked_chest', 'default:copper_ingot'},
- {'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
+ {'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
+ {'default:copper_ingot','technic:iron_locked_chest','default:copper_ingot'},
+ {'default:copper_ingot','default:copper_ingot','default:copper_ingot'},
}
})
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
- "invsize[10,9;]"..
- "list[current_name;main;0,0;10,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ "invsize[10,10;]"..
+ "label[0,0;Copper Chest]"..
+ "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")
local inv = meta:get_inventory()
inv:set_size("main", 10*4)
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
- "invsize[10,9;]"..
- "list[current_name;main;0,0;10,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ "invsize[10,10;]"..
+ "label[0,0;Copper Locked Chest]"..
+ "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("owner", "")
local inv = meta:get_inventory()
local chest_mark_colors = {
- '_black',
- '_blue',
- '_brown',
- '_cyan',
- '_dark_green',
- '_dark_grey',
- '_green',
- '_grey',
- '_magenta',
- '_orange',
- '_pink',
- '_red',
- '_violet',
- '_white',
- '_yellow',
+ {'_black','Black'},
+ {'_blue','Blue'},
+ {'_brown','Brown'},
+ {'_cyan','Cyan'},
+ {'_dark_green','Dark Green'},
+ {'_dark_grey','Dark Grey'},
+ {'_green','Green'},
+ {'_grey','Grey'},
+ {'_magenta','Magenta'},
+ {'_orange','Orange'},
+ {'_pink','Pink'},
+ {'_red','Red'},
+ {'_violet','Violet'},
+ {'_white','White'},
+ {'_yellow','Yellow'},
+ {'','None'}
}
minetest.register_craft({
- output = 'technic:gold_chest 1',
+ output = 'technic:gold_chest',
recipe = {
- {'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot'},
- {'default:gold_ingot', 'technic:silver_chest', 'default:gold_ingot'},
- {'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','default:gold_ingot','default:gold_ingot'},
}
})
minetest.register_craft({
- output = 'technic:gold_locked_chest 1',
+ output = 'technic:gold_locked_chest',
recipe = {
- {'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot'},
- {'default:gold_ingot', 'technic:silver_locked_chest', 'default:gold_ingot'},
- {'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','default:gold_ingot','default:gold_ingot'},
}
})
minetest.register_craft({
- output = 'technic:gold_locked_chest 1',
+ output = 'technic:gold_locked_chest',
recipe = {
{'default:steel_ingot'},
{'technic:gold_chest'},
stack_max = 99,
})
-gold_chest_formspec = "invsize[12,9;]"..
- "list[current_name;main;0,0;12,4;]"..
- "list[current_player;main;0,5;8,4;]"
+function get_pallette_buttons ()
+local buttons_string=""
+ 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
on_construct = function(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")
local inv = meta:get_inventory()
inv:set_size("main", gold_chest_inv_size)
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)
- local meta = minetest.env:get_meta(pos);
- fields.text = fields.text or ""
- meta:set_string("text", fields.text)
- meta:set_string("infotext", '"'..fields.text..'"')
- meta:set_string("formspec",gold_chest_formspec)
+ local meta = minetest.env:get_meta(pos)
+ local page="main"
+ if fields.edit_infotext then
+ page="edit_infotext"
+ 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,
on_metadata_inventory_move = def_on_metadata_inventory_move,
on_metadata_inventory_take = def_on_metadata_inventory_take
})
-for i, state in ipairs(chest_mark_colors) do
-minetest.register_node(":technic:gold_chest".. state, {
+for i=1,15,1 do
+minetest.register_node(":technic:gold_chest".. chest_mark_colors[i][1], {
description = "Gold Chest",
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",
groups = chest_groups2,
tube = tubes_properties,
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
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,
-
- on_punch = function (pos, node, puncher)
- chest_punched (pos,node,puncher);
- end,
on_receive_fields = function(pos, formname, fields, sender)
- local meta = minetest.env:get_meta(pos);
- fields.text = fields.text or ""
- meta:set_string("text", fields.text)
- meta:set_string("infotext", '"'..fields.text..'"')
- meta:set_string("formspec",gold_chest_formspec)
+ local meta = minetest.env:get_meta(pos)
+ local page="main"
+ if fields.edit_infotext then
+ page="edit_infotext"
+ 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,
on_metadata_inventory_move = def_on_metadata_inventory_move,
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("formspec",
+ 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", "")
local inv = meta:get_inventory()
inv:set_size("main", gold_chest_inv_size)
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)
- local meta = minetest.env:get_meta(pos);
- fields.text = fields.text or ""
- meta:set_string("text", fields.text)
- meta:set_string("infotext", '"'..fields.text..'"')
- meta:set_string("formspec",gold_chest_formspec)
+ local meta = minetest.env:get_meta(pos)
+ local formspec = gold_chest_formspec..
+ "label[0,0;Gold Locked Chest]"
+ local page="main"
+ 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,
allow_metadata_inventory_move = def_allow_metadata_inventory_move,
on_metadata_inventory_take = def_on_metadata_inventory_take
})
-for i, state in ipairs(chest_mark_colors) do
-minetest.register_node(":technic:gold_locked_chest".. state, {
+for i=1,15,1 do
+minetest.register_node(":technic:gold_locked_chest".. chest_mark_colors[i][1], {
description = "Gold Locked Chest",
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",
drop = "technic:gold_locked_chest",
groups = chest_groups2,
tube = tubes_properties,
legacy_facedir_simple = true,
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,
- 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)
- local meta = minetest.env:get_meta(pos);
- fields.text = fields.text or ""
- meta:set_string("text", fields.text)
- meta:set_string("infotext", '"'..fields.text..'"')
- meta:set_string("formspec",gold_chest_formspec)
+ local meta = minetest.env:get_meta(pos)
+ local formspec = gold_chest_formspec..
+ "label[0,0;Gold Locked Chest]"
+ local page="main"
+ 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,
allow_metadata_inventory_move = def_allow_metadata_inventory_move,
})
end
-function 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_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_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")
+function check_color_buttons (pos,chest_name,fields)
+ if fields.color_button15 then
+ hacky_swap_node(pos,chest_name)
+ return 16
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
+ for i=0,14,1 do
+ local button="color_button"..i
+ if fields[button] then
+ hacky_swap_node(pos,chest_name..chest_mark_colors[i+1][1])
+ return i+1
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
+ return 16
+end
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
- "invsize[9,9;]"..
- "list[current_name;main;0,0;9,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ "invsize[9,10;]"..
+ "label[0,0;Iron Chest]"..
+ "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")
local inv = meta:get_inventory()
inv:set_size("main", 9*4)
local meta = minetest.env:get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", "Locked Iron Chest (owned by "..
- meta:get_string("owner")..")")
+ meta:get_string("owner")..")")
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
- "invsize[9,9;]"..
- "list[current_name;main;0,0;9,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ "invsize[9,10;]"..
+ "label[0,0;Iron Locked Chest]"..
+ "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("owner", "")
local inv = meta:get_inventory()
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
- "invsize[13,9;]"..
- "list[current_name;main;0,0;13,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ "invsize[13,10;]"..
+ "label[0,0;Mithril Chest]"..
+ "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")
local inv = meta:get_inventory()
inv:set_size("main", 13*4)
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
- "invsize[13,9;]"..
- "list[current_name;main;0,0;13,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ "invsize[13,10;]"..
+ "label[0,0;Mithril Locked Chest]"..
+ "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("owner", "")
local inv = meta:get_inventory()
minetest.register_craft({
- output = 'technic:silver_chest 1',
+ output = 'technic:silver_chest',
recipe = {
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
{'moreores:silver_ingot','technic:copper_chest','moreores:silver_ingot'},
})
minetest.register_craft({
- output = 'technic:silver_locked_chest 1',
+ output = 'technic:silver_locked_chest',
recipe = {
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
{'moreores:silver_ingot','technic:copper_locked_chest','moreores:silver_ingot'},
})
minetest.register_craft({
- output = 'technic:silver_locked_chest 1',
+ output = 'technic:silver_locked_chest',
recipe = {
{'default:steel_ingot'},
{'technic:silver_chest'},
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", {
description = "Silver Chest",
tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png",
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
- "invsize[11,9;]"..
- "list[current_name;main;0,0;11,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ silver_chest_formspec..
+ "label[0,0;Silver Chest]"..
+ "image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]")
meta:set_string("infotext", "Silver Chest")
local inv = meta:get_inventory()
inv:set_size("main", 11*4)
end,
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)
- local meta = minetest.env:get_meta(pos);
- fields.text = fields.text or ""
- meta:set_string("text", fields.text)
- meta:set_string("infotext", '"'..fields.text..'"')
-
- meta:set_string("formspec",
- "invsize[11,9;]"..
- "list[current_name;main;0,0;11,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ local meta = minetest.env:get_meta(pos)
+ local page="main"
+ if fields.edit_infotext then
+ page="edit_infotext"
+ end
+ if fields.save_infotext then
+ meta:set_string("infotext",fields.infotext_box)
+ end
+ 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,
on_metadata_inventory_move = def_on_metadata_inventory_move,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
- "invsize[11,9;]"..
- "list[current_name;main;0,0;11,4;]"..
- "list[current_player;main;0,5;8,4;]")
- meta:set_string("infotext", "Silver Locked Chest")
+ silver_chest_formspec..
+ "label[0,0;Silver Locked Chest]"..
+ "image_button[3.5,.1;.6,.6;pencil_icon.png;edit_infotext;]")
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", 11*4)
end,
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)
- local meta = minetest.env:get_meta(pos);
- fields.text = fields.text or ""
- meta:set_string("text", fields.text)
- meta:set_string("infotext", '"'..fields.text..'"')
-
- meta:set_string("formspec",
- "invsize[11,9;]"..
- "list[current_name;main;0,0;11,4;]"..
- "list[current_player;main;0,5;8,4;]")
+ local meta = minetest.env:get_meta(pos)
+ local page="main"
+ if fields.edit_infotext then
+ page="edit_infotext"
+ end
+ if fields.save_infotext then
+ meta:set_string("infotext",fields.infotext_box)
+ end
+ 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,
-
allow_metadata_inventory_move = def_allow_metadata_inventory_move,
allow_metadata_inventory_put = def_allow_metadata_inventory_put,
allow_metadata_inventory_take = def_allow_metadata_inventory_take,
inventory_image = "technic_stainless_steel_ingot.png",
})
-minetest.register_craftitem( ":technic:brass_ingot", {
+minetest.register_craftitem( ":group:brass_ingot", {
description = "Brass Ingot",
inventory_image = "technic_brass_ingot.png",
- groups = {brass_ingot=1}
})
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"},
{"group:brass_ingot", "group:brass_ingot", "group:brass_ingot"},
{"group:brass_ingot", "group:brass_ingot", "group:brass_ingot"}}
})
minetest.register_craft({
- output = "craft technic:brass_ingot 9",
+ output = "craft group:brass_ingot 9",
recipe = {{"group:brass_block"}}
})