2018-04-06 14:04:21 +00:00
|
|
|
-- Melts metals using lava as a heat source.
|
2018-04-02 10:39:41 +00:00
|
|
|
|
2018-04-06 14:04:21 +00:00
|
|
|
-- Max lava that can be held by the melter.
|
2018-04-02 10:39:41 +00:00
|
|
|
metal_melter.max_fuel = 8000
|
2018-04-04 17:44:59 +00:00
|
|
|
|
2018-04-06 14:04:21 +00:00
|
|
|
-- Spec divided by this number is the lava usage.
|
2018-04-06 17:53:30 +00:00
|
|
|
metal_melter.lava_usage = 9
|
2018-04-06 14:04:21 +00:00
|
|
|
|
|
|
|
-- Max metal that can be held by the melter.
|
2018-04-02 10:39:41 +00:00
|
|
|
metal_melter.max_metal = 16000
|
2018-04-04 17:44:59 +00:00
|
|
|
|
2018-04-06 14:04:21 +00:00
|
|
|
-- How much metal is given for melting a typename (in millibuckets).
|
2018-04-02 10:39:41 +00:00
|
|
|
metal_melter.spec = {
|
2019-02-08 21:05:19 +00:00
|
|
|
ingot = 144,
|
2018-04-02 10:39:41 +00:00
|
|
|
crystal = 144,
|
2019-02-08 21:05:19 +00:00
|
|
|
block = 1296,
|
|
|
|
lump = 288,
|
|
|
|
cast = 288,
|
|
|
|
ore = 288,
|
2018-04-02 10:39:41 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 17:19:33 +00:00
|
|
|
local function in_table(t, n)
|
|
|
|
local found = nil
|
|
|
|
|
|
|
|
for _, v in pairs(t) do
|
|
|
|
if v == n then
|
|
|
|
found = v
|
2018-04-02 10:39:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-04 17:19:33 +00:00
|
|
|
return found
|
|
|
|
end
|
2018-04-02 10:39:41 +00:00
|
|
|
|
2018-04-04 17:19:33 +00:00
|
|
|
function metal_melter.get_metal_from_stack(stack)
|
|
|
|
local metal = nil
|
|
|
|
local metal_type = nil
|
|
|
|
|
2019-03-09 11:49:50 +00:00
|
|
|
for mt, types in pairs(fluidity.melts) do
|
2018-04-04 17:19:33 +00:00
|
|
|
if metal then break end
|
|
|
|
for tp,items in pairs(types) do
|
|
|
|
if in_table(items, stack) then
|
|
|
|
metal = mt
|
|
|
|
metal_type = tp
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2018-04-02 10:39:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return metal, metal_type
|
|
|
|
end
|
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
function metal_melter.get_metal_melter_formspec(lava, metal)
|
2018-12-17 16:43:13 +00:00
|
|
|
local metal_formspec = "tooltip[6.68,0;0.8,2.45;No Molten Metal]"
|
2018-04-02 10:39:41 +00:00
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal ~= nil then
|
2018-12-17 16:43:13 +00:00
|
|
|
metal_formspec = "tooltip[6.68,0;0.8,2.45;"..fluid_lib.buffer_to_string(metal).."]"
|
2018-04-02 10:39:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return "size[8,8.5]"..
|
|
|
|
default.gui_bg..
|
|
|
|
default.gui_bg_img..
|
|
|
|
default.gui_slots..
|
2018-12-17 16:43:13 +00:00
|
|
|
"image[2.25,0.2;1,1;metal_melter_gui_lump.png]"..
|
2018-04-02 10:39:41 +00:00
|
|
|
"list[context;input;2.25,0.2;1,1;]"..
|
2018-12-17 16:43:13 +00:00
|
|
|
"image[2.25,1.4;1,1;metal_melter_gui_bucket.png]"..
|
2018-04-02 10:39:41 +00:00
|
|
|
"list[context;heat;2.25,1.4;1,1;]"..
|
|
|
|
"image[1.3,1.4;1,1;gui_furnace_arrow_bg.png^[transformR90]"..
|
2018-07-28 16:15:16 +00:00
|
|
|
metal_melter.fluid_bar(0.08, 0, lava)..
|
2018-12-17 16:43:13 +00:00
|
|
|
"tooltip[0.08,0;0.8,2.45;".. fluid_lib.buffer_to_string(lava) .."]"..
|
2018-07-28 16:15:16 +00:00
|
|
|
metal_melter.fluid_bar(6.68, 0, metal)..
|
2018-04-02 10:39:41 +00:00
|
|
|
metal_formspec..
|
2018-12-17 16:43:13 +00:00
|
|
|
"image[4.7,0.2;1,1;metal_melter_gui_bucket.png]"..
|
|
|
|
"image[4.7,1.4;1,1;metal_melter_gui_bucket.png]"..
|
2018-04-07 07:07:31 +00:00
|
|
|
"list[context;bucket_in;4.7,0.2;1,1;]"..
|
|
|
|
"list[context;bucket_out;4.7,1.4;1,1;]"..
|
|
|
|
"image[5.7,0.2;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
|
|
|
"image[5.7,1.4;1,1;gui_furnace_arrow_bg.png^[transformR90]"..
|
2018-04-05 06:21:15 +00:00
|
|
|
"button[6.68,2.48;1.33,1;dump;Dump]"..
|
2018-04-02 10:39:41 +00:00
|
|
|
"list[current_player;main;0,4.25;8,1;]"..
|
|
|
|
"list[current_player;main;0,5.5;8,3;8]"..
|
|
|
|
"listring[context;heat]"..
|
|
|
|
"listring[current_player;main]"..
|
|
|
|
"listring[context;input]"..
|
|
|
|
"listring[current_player;main]"..
|
|
|
|
"listring[context;bucket_in]"..
|
|
|
|
"listring[current_player;main]"..
|
|
|
|
"listring[context;bucket_out]"..
|
|
|
|
"listring[current_player;main]"..
|
|
|
|
default.get_hotbar_bg(0, 4.25)
|
|
|
|
end
|
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
local function get_bucket_for_fluid(src)
|
|
|
|
local bucket = bucket.liquids[src]
|
|
|
|
if not bucket then return nil end
|
|
|
|
return bucket.itemname
|
|
|
|
end
|
|
|
|
|
2018-04-02 10:39:41 +00:00
|
|
|
local function allow_metadata_inventory_put (pos, listname, index, stack, player)
|
|
|
|
if minetest.is_protected(pos, player:get_player_name()) then
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if listname == "bucket_out" then
|
2018-04-06 12:05:04 +00:00
|
|
|
if stack:get_name() ~= "bucket:bucket_empty" and not fluidity.florbs.get_is_florb(stack) then
|
2018-04-02 10:39:41 +00:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if listname == "heat" then
|
|
|
|
if stack:get_name() ~= "bucket:bucket_lava" then
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return stack:get_count()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function allow_metadata_inventory_move (pos, from_list, from_index, to_list, to_index, count, player)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
local stack = inv:get_stack(from_list, from_index)
|
|
|
|
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function allow_metadata_inventory_take (pos, listname, index, stack, player)
|
|
|
|
if minetest.is_protected(pos, player:get_player_name()) then
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
return stack:get_count()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function take_from_stack(stack, count)
|
|
|
|
-- Take count from stack, return nil if the item count reaches 0
|
|
|
|
local newcount = stack:get_count() - count
|
|
|
|
if newcount <= 0 then
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
stack:set_count(newcount)
|
|
|
|
return stack
|
|
|
|
end
|
|
|
|
|
|
|
|
local function swap_node(pos, name)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if node.name == name then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
node.name = name
|
|
|
|
minetest.swap_node(pos, node)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function melter_node_timer(pos, elapsed)
|
|
|
|
local refresh = false
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
|
|
|
|
-- Current amount of lava in the block
|
2018-07-28 16:15:16 +00:00
|
|
|
local lava = fluid_lib.get_buffer_data(pos, "lava")
|
2018-04-02 10:39:41 +00:00
|
|
|
|
|
|
|
-- Current metal used
|
2018-07-28 16:15:16 +00:00
|
|
|
local metal = fluid_lib.get_buffer_data(pos, "metal")
|
2018-04-02 10:39:41 +00:00
|
|
|
|
2018-04-05 06:21:15 +00:00
|
|
|
local dumping = meta:get_int("dump")
|
2019-02-08 21:05:19 +00:00
|
|
|
if dumping == 1 then
|
2018-07-28 16:15:16 +00:00
|
|
|
metal.amount = 0
|
|
|
|
metal.fluid = ""
|
2018-04-05 06:21:15 +00:00
|
|
|
refresh = true
|
|
|
|
meta:set_int("dump", 0)
|
|
|
|
end
|
|
|
|
|
2018-04-02 10:39:41 +00:00
|
|
|
-- Insert lava bucket into tank, return empty bucket
|
|
|
|
if inv:get_stack("heat", 1):get_name() == "bucket:bucket_lava" then
|
2018-07-28 16:15:16 +00:00
|
|
|
if lava.amount + 1000 <= metal_melter.max_fuel then
|
|
|
|
lava.amount = lava.amount + 1000
|
2018-04-02 10:39:41 +00:00
|
|
|
inv:set_list("heat", {"bucket:bucket_empty"})
|
|
|
|
refresh = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Handle input bucket, only allow a molten metal
|
2018-04-06 12:05:04 +00:00
|
|
|
local bucket_in = inv:get_stack("bucket_in", 1)
|
|
|
|
local bucket_name = bucket_in:get_name()
|
2018-07-28 16:28:43 +00:00
|
|
|
if (bucket_name:find("bucket") and bucket_name ~= "bucket:bucket_empty") or (not fluidity.florbs.get_is_empty_florb(bucket_in) and
|
|
|
|
fluidity.florbs.get_is_florb(bucket_in)) then
|
2018-04-06 12:05:04 +00:00
|
|
|
local is_florb = fluidity.florbs.get_is_florb(bucket_in)
|
|
|
|
if is_florb then
|
|
|
|
local contents, fluid_name, capacity = fluidity.florbs.get_florb_contents(bucket_in)
|
|
|
|
local fluid_metal = fluidity.get_metal_for_fluid(fluid_name)
|
2018-07-28 16:15:16 +00:00
|
|
|
if fluid_metal and (fluid_name == metal.fluid or metal.fluid == "") then
|
2018-04-06 12:05:04 +00:00
|
|
|
local take = 1000
|
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal.amount + take > metal_melter.max_metal then
|
|
|
|
take = metal_melter.max_metal - metal.amount
|
2018-04-06 12:05:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Attempt to take 1000 millibuckets from the florb
|
|
|
|
local stack,res = fluidity.florbs.take_fluid(bucket_in, take)
|
|
|
|
if res > 0 then
|
|
|
|
take = take - res
|
|
|
|
end
|
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
metal.fluid = fluid_name
|
|
|
|
metal.amount = metal.amount + take
|
2018-04-06 12:05:04 +00:00
|
|
|
inv:set_list("bucket_in", {stack})
|
|
|
|
refresh = true
|
|
|
|
end
|
|
|
|
else
|
2018-07-28 16:15:16 +00:00
|
|
|
local bucket_fluid = bucket.get_liquid_for_bucket(bucket_name)
|
2018-04-06 12:05:04 +00:00
|
|
|
local fluid_is_metal = fluidity.get_metal_for_fluid(bucket_fluid) ~= nil
|
|
|
|
local empty_bucket = false
|
|
|
|
|
|
|
|
if fluid_is_metal then
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal.fluid ~= "" and metal.fluid == bucket_fluid then
|
|
|
|
if metal.amount + 1000 <= metal_melter.max_metal then
|
|
|
|
metal.amount = metal.amount + 1000
|
2018-04-06 12:05:04 +00:00
|
|
|
empty_bucket = true
|
|
|
|
end
|
2018-07-28 16:15:16 +00:00
|
|
|
elseif metal.fluid == "" then
|
|
|
|
metal.amount = 1000
|
|
|
|
metal.fluid = bucket_fluid
|
2018-04-02 10:39:41 +00:00
|
|
|
empty_bucket = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-06 12:05:04 +00:00
|
|
|
if empty_bucket then
|
|
|
|
inv:set_list("bucket_in", {"bucket:bucket_empty"})
|
|
|
|
refresh = true
|
|
|
|
end
|
2018-04-02 10:39:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Handle bucket output, only allow empty buckets in this slot
|
2018-04-06 12:05:04 +00:00
|
|
|
local bucket_out = inv:get_stack("bucket_out", 1)
|
|
|
|
bucket_name = bucket_out:get_name()
|
2018-07-28 16:15:16 +00:00
|
|
|
if (bucket_name == "bucket:bucket_empty" or fluidity.florbs.get_is_florb(bucket_out)) and metal.fluid ~= "" and bucket_out:get_count() == 1 then
|
2018-04-06 12:05:04 +00:00
|
|
|
local is_florb = fluidity.florbs.get_is_florb(bucket_out)
|
|
|
|
if is_florb then
|
|
|
|
local contents, fluid_name, capacity = fluidity.florbs.get_florb_contents(bucket_out)
|
|
|
|
local fluid_metal = fluidity.get_metal_for_fluid(fluid_name)
|
2018-07-28 16:15:16 +00:00
|
|
|
if not fluid_name or fluid_name == metal.fluid then
|
2018-04-06 12:05:04 +00:00
|
|
|
local take = 1000
|
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal.amount < take then
|
|
|
|
take = metal.amount
|
2018-04-06 12:05:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Attempt to put 1000 millibuckets into the florb
|
2018-07-28 16:15:16 +00:00
|
|
|
local stack,res = fluidity.florbs.add_fluid(bucket_out, metal.fluid, take)
|
2018-04-06 12:05:04 +00:00
|
|
|
if res > 0 then
|
|
|
|
take = take - res
|
|
|
|
end
|
2018-04-02 10:39:41 +00:00
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
metal.amount = metal.amount - take
|
2018-04-06 12:05:04 +00:00
|
|
|
inv:set_list("bucket_out", {stack})
|
|
|
|
refresh = true
|
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal.amount == 0 then
|
|
|
|
metal.fluid = ""
|
2018-04-06 12:05:04 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2018-07-28 16:15:16 +00:00
|
|
|
local bucket = get_bucket_for_fluid(metal.fluid)
|
|
|
|
if bucket and metal.amount >= 1000 then
|
|
|
|
metal.amount = metal.amount - 1000
|
2018-04-06 12:05:04 +00:00
|
|
|
inv:set_list("bucket_out", {bucket})
|
|
|
|
refresh = true
|
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal.amount == 0 then
|
|
|
|
metal.fluid = ""
|
2018-04-06 12:05:04 +00:00
|
|
|
end
|
2018-04-02 10:39:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Handle metal input. Must be a: ingot, lump, block or ore.
|
|
|
|
local input = inv:get_stack("input", 1):get_name()
|
|
|
|
if input ~= "" then
|
|
|
|
local mt, t = metal_melter.get_metal_from_stack(input)
|
|
|
|
if mt then
|
2018-04-04 17:44:59 +00:00
|
|
|
local metal_name = fluidity.molten_metals[mt]
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal_name and (metal.fluid == "" or metal.fluid == metal_name) then
|
2018-04-04 17:44:59 +00:00
|
|
|
local cnt = metal_melter.spec[t]
|
2018-04-06 14:04:21 +00:00
|
|
|
local heat_consume = math.floor(cnt / metal_melter.lava_usage)
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal.amount + cnt <= metal_melter.max_metal and lava.amount >= heat_consume then
|
|
|
|
metal.fluid = metal_name
|
|
|
|
metal.amount = metal.amount + cnt
|
|
|
|
lava.amount = lava.amount - heat_consume
|
2018-04-04 17:44:59 +00:00
|
|
|
inv:set_stack("input", 1, take_from_stack(inv:get_stack("input", 1), 1))
|
|
|
|
refresh = true
|
|
|
|
end
|
2018-04-02 10:39:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Refresh metadata and formspec
|
2018-07-28 16:15:16 +00:00
|
|
|
meta:set_int("lava_fluid_storage", lava.amount)
|
|
|
|
meta:set_int("metal_fluid_storage", metal.amount)
|
|
|
|
meta:set_string("metal_fluid", metal.fluid)
|
|
|
|
meta:set_string("lava_fluid", "default:lava_source")
|
2018-06-18 18:26:56 +00:00
|
|
|
|
|
|
|
local infotext = "Metal Melter\n"
|
2018-07-28 16:15:16 +00:00
|
|
|
infotext = infotext .. fluid_lib.buffer_to_string(lava) .. "\n"
|
2018-06-18 18:26:56 +00:00
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
if metal and metal.fluid ~= "" then
|
|
|
|
infotext = fluid_lib.buffer_to_string(metal)
|
2018-06-18 18:26:56 +00:00
|
|
|
else
|
2018-07-28 16:15:16 +00:00
|
|
|
infotext = infotext .. "No Molten Metal"
|
2018-06-18 18:26:56 +00:00
|
|
|
end
|
2018-04-02 10:39:41 +00:00
|
|
|
|
2018-07-28 16:15:16 +00:00
|
|
|
if lava.amount > 144 then
|
2018-06-18 18:26:56 +00:00
|
|
|
swap_node(pos, "metal_melter:metal_melter_filled")
|
|
|
|
else
|
|
|
|
swap_node(pos, "metal_melter:metal_melter")
|
2018-04-02 10:39:41 +00:00
|
|
|
end
|
|
|
|
|
2018-06-18 18:26:56 +00:00
|
|
|
meta:set_string("infotext", infotext)
|
2018-07-28 16:15:16 +00:00
|
|
|
meta:set_string("formspec", metal_melter.get_metal_melter_formspec(lava, metal))
|
2018-06-18 18:26:56 +00:00
|
|
|
|
2018-04-02 10:39:41 +00:00
|
|
|
-- If true, calls for another clock cycle.
|
|
|
|
return refresh
|
|
|
|
end
|
|
|
|
|
|
|
|
local function on_construct(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
2018-07-28 16:15:16 +00:00
|
|
|
meta:set_string("formspec", metal_melter.get_metal_melter_formspec())
|
2018-04-02 10:39:41 +00:00
|
|
|
|
|
|
|
-- Create inventory
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
inv:set_size('input', 1)
|
|
|
|
inv:set_size('heat', 1)
|
|
|
|
inv:set_size('bucket_in', 1)
|
|
|
|
inv:set_size('bucket_out', 1)
|
|
|
|
|
2018-07-28 16:28:43 +00:00
|
|
|
-- Lava source block
|
|
|
|
meta:set_string('lava_fluid', 'default:lava_source')
|
2018-04-02 10:39:41 +00:00
|
|
|
|
|
|
|
-- Default infotext
|
|
|
|
meta:set_string("infotext", "Metal Melter Inactive")
|
|
|
|
end
|
|
|
|
|
|
|
|
local function can_dig(pos, player)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
return inv:is_empty("input") and inv:is_empty("heat") and inv:is_empty("bucket_in") and inv:is_empty("bucket_out")
|
|
|
|
end
|
|
|
|
|
2018-04-05 06:21:15 +00:00
|
|
|
local function on_receive_fields(pos, formname, fields, sender)
|
|
|
|
if sender and minetest.is_protected(pos, sender:get_player_name()) then
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
if fields["dump"] then
|
|
|
|
meta:set_int('dump', 1)
|
|
|
|
minetest.get_node_timer(pos):start(1.0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-06 17:53:30 +00:00
|
|
|
-- Pipeworks integration
|
|
|
|
local pipeworks = {}
|
|
|
|
local tube_entry = ""
|
|
|
|
if minetest.get_modpath("pipeworks") ~= nil then
|
|
|
|
tube_entry = "^pipeworks_tube_connection_metallic.png"
|
|
|
|
|
|
|
|
local function insert_object(pos, node, stack, direction, owner)
|
|
|
|
local stack_name = stack:get_name()
|
|
|
|
local inv = minetest.get_meta(pos):get_inventory()
|
|
|
|
|
|
|
|
minetest.get_node_timer(pos):start(1.0)
|
|
|
|
|
|
|
|
if stack_name == "bucket:bucket_empty" or fluidity.florbs.get_is_empty_florb(stack) then
|
|
|
|
return inv:add_item("bucket_out", stack)
|
|
|
|
elseif stack_name == "bucket:bucket_lava" then
|
|
|
|
return inv:add_item("heat", stack)
|
|
|
|
elseif stack_name:find(":bucket_") ~= nil or fluidity.florbs.get_is_florb(stack) then
|
|
|
|
return inv:add_item("bucket_in", stack)
|
|
|
|
else
|
|
|
|
return inv:add_item("input", stack)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
pipeworks = {
|
|
|
|
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1},
|
|
|
|
insert_object = insert_object,
|
|
|
|
input_inventory = "bucket_out",
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-04-02 10:39:41 +00:00
|
|
|
minetest.register_node("metal_melter:metal_melter", {
|
|
|
|
description = "Metal Melter",
|
|
|
|
tiles = {
|
2018-04-06 17:53:30 +00:00
|
|
|
"melter_side.png"..tube_entry, "melter_side.png"..tube_entry,
|
|
|
|
"melter_side.png"..tube_entry, "melter_side.png"..tube_entry,
|
|
|
|
"melter_side.png"..tube_entry, "melter_front.png"
|
2018-04-02 10:39:41 +00:00
|
|
|
},
|
|
|
|
paramtype2 = "facedir",
|
2018-04-06 17:53:30 +00:00
|
|
|
groups = {
|
|
|
|
cracky = 2,
|
|
|
|
tubedevice = 1,
|
|
|
|
tubedevice_receiver = 1,
|
2018-06-18 18:26:56 +00:00
|
|
|
fluid_container = 1,
|
2018-04-06 17:53:30 +00:00
|
|
|
},
|
2018-04-02 10:39:41 +00:00
|
|
|
legacy_facedir_simple = true,
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
|
|
|
|
can_dig = can_dig,
|
|
|
|
on_timer = melter_node_timer,
|
|
|
|
on_construct = on_construct,
|
|
|
|
on_metadata_inventory_move = function(pos)
|
|
|
|
minetest.get_node_timer(pos):start(1.0)
|
|
|
|
end,
|
|
|
|
on_metadata_inventory_put = function(pos)
|
|
|
|
minetest.get_node_timer(pos):start(1.0)
|
|
|
|
end,
|
|
|
|
on_blast = function(pos)
|
|
|
|
local drops = {}
|
|
|
|
default.get_inventory_drops(pos, "input", drops)
|
|
|
|
default.get_inventory_drops(pos, "heat", drops)
|
|
|
|
default.get_inventory_drops(pos, "bucket_in", drops)
|
|
|
|
default.get_inventory_drops(pos, "bucket_out", drops)
|
|
|
|
drops[#drops+1] = "metal_melter:metal_melter"
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
return drops
|
|
|
|
end,
|
2018-04-05 06:21:15 +00:00
|
|
|
on_receive_fields = on_receive_fields,
|
2018-04-02 10:39:41 +00:00
|
|
|
|
|
|
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
|
|
|
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
|
|
|
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
2018-04-06 17:53:30 +00:00
|
|
|
|
2018-06-18 18:26:56 +00:00
|
|
|
fluid_buffers = {
|
|
|
|
lava = {
|
2018-06-20 16:58:58 +00:00
|
|
|
capacity = metal_melter.max_fuel,
|
|
|
|
accepts = {"default:lava_source"},
|
|
|
|
drainable = false,
|
2018-06-18 18:26:56 +00:00
|
|
|
},
|
|
|
|
metal = {
|
|
|
|
capacity = metal_melter.max_metal
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-04-06 17:53:30 +00:00
|
|
|
tube = pipeworks,
|
2018-04-02 10:39:41 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("metal_melter:metal_melter_filled", {
|
|
|
|
tiles = {
|
2018-04-06 17:53:30 +00:00
|
|
|
"melter_side.png"..tube_entry, "melter_side.png"..tube_entry,
|
|
|
|
"melter_side.png"..tube_entry, "melter_side.png"..tube_entry,
|
|
|
|
"melter_side.png"..tube_entry, "melter_front.png^melter_front_lava.png"
|
2018-04-02 10:39:41 +00:00
|
|
|
},
|
|
|
|
paramtype2 = "facedir",
|
2018-04-06 17:53:30 +00:00
|
|
|
groups = {
|
|
|
|
cracky = 2,
|
|
|
|
tubedevice = 1,
|
|
|
|
tubedevice_receiver = 1,
|
2018-06-18 18:26:56 +00:00
|
|
|
not_in_creative_inventory = 1,
|
|
|
|
fluid_container = 1,
|
2018-04-06 17:53:30 +00:00
|
|
|
},
|
2018-04-02 10:39:41 +00:00
|
|
|
legacy_facedir_simple = true,
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
|
|
|
|
drop = "metal_melter:metal_melter",
|
|
|
|
light_source = 8,
|
|
|
|
can_dig = can_dig,
|
|
|
|
on_timer = melter_node_timer,
|
|
|
|
on_construct = on_construct,
|
|
|
|
|
|
|
|
on_metadata_inventory_move = function(pos)
|
|
|
|
minetest.get_node_timer(pos):start(1.0)
|
|
|
|
end,
|
|
|
|
on_metadata_inventory_put = function(pos)
|
|
|
|
minetest.get_node_timer(pos):start(1.0)
|
|
|
|
end,
|
2018-04-05 06:21:15 +00:00
|
|
|
on_receive_fields = on_receive_fields,
|
2018-04-02 10:39:41 +00:00
|
|
|
|
|
|
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
|
|
|
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
|
|
|
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
2018-04-06 17:53:30 +00:00
|
|
|
|
2018-06-18 18:26:56 +00:00
|
|
|
fluid_buffers = {
|
|
|
|
lava = {
|
2018-06-20 16:58:58 +00:00
|
|
|
capacity = metal_melter.max_fuel,
|
|
|
|
accepts = {"default:lava_source"},
|
|
|
|
drainable = false,
|
2018-06-18 18:26:56 +00:00
|
|
|
},
|
|
|
|
metal = {
|
|
|
|
capacity = metal_melter.max_metal
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-04-06 17:53:30 +00:00
|
|
|
tube = pipeworks,
|
2018-04-02 10:39:41 +00:00
|
|
|
})
|
2018-04-04 17:44:59 +00:00
|
|
|
|
2018-09-17 13:10:09 +00:00
|
|
|
fluid_lib.register_node("metal_melter:metal_melter")
|
|
|
|
fluid_lib.register_node("metal_melter:metal_melter_filled")
|
|
|
|
|
2018-04-04 17:44:59 +00:00
|
|
|
-- Set a spec
|
2019-02-08 21:05:19 +00:00
|
|
|
function metal_melter.register_melt_value(specname, value)
|
2018-04-04 17:44:59 +00:00
|
|
|
metal_melter.spec[specname] = value
|
|
|
|
end
|