Add copper, and the beginnings of a machine system.

This commit is contained in:
Signal 2025-12-29 16:53:50 -05:00
parent 30ba6e5385
commit 1e897665bb
69 changed files with 976 additions and 135 deletions

View file

@ -0,0 +1,2 @@
name = rgt_alloy_furnace
depends = rgt_machines

View file

@ -5,8 +5,9 @@ local function can_work(node, m, inv)
if input:get_count() > 0 then
-- Would melting this item exceed our fluid capacity?
local fluid = m:get_float "fluid"
local capacity = m:get_int "fluid_capacity"
if capacity -fluid >= 1 then
local fluid_type = m:get "fluid_type"
local capacity = m:get_float "fluid_capacity"
if capacity -fluid >= 1 and (fluid == 0 or input:get_definition().material == fluid_type) then
return true
end
end
@ -16,7 +17,7 @@ end
local function update_formspec(m, progress)
progress = progress or m:get_int "progress"
local fluid = m:get_float "fluid"
local capacity = m:get_int "fluid_capacity"
local capacity = m:get_float "fluid_capacity"
local progressbar = progress == 0 and "rgt_progress_bg.png^[transformR270" or "rgt_progress_bg.png^[lowpart:"..progress..":rgt_progress_bg_active.png^[transformR270"
local fluidcontainer = fluid == 0 and "rgt_fluid_container_bg.png" or "rgt_fluid_container_bg.png^[lowpart:"..(fluid /capacity *100)..":rgt_fluid_container_bg_filled.png"
local fs = {"\
@ -57,11 +58,14 @@ local function update(pos, elapsed)
minetest.swap_node(pos, node)
end
local progress = m:get_int("progress") +20
local progress = m:get_int("progress") +50
if progress >= 100 then
local fluid = m:get_float "fluid"
fluid = fluid +1
if fluid >= 2 then
fluid = fluid -rgt_machines.push_fluid(pos, m:get "fluid_type", fluid)
end
m:set_float("fluid", fluid)
-- Consume an item.
@ -69,6 +73,8 @@ local function update(pos, elapsed)
s:take_item()
inv:set_stack("input", 1, s)
m:set_string("fluid_type", s:get_definition().material)
progress = 0
end
m:set_int("progress", progress)
@ -90,7 +96,7 @@ rgt_machines.register_machine("arc_furnace", {
},
active = {
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_arc_furnace_front_active.png"},
drop = "arc_furnace_idle"
drop = "arc_furnace_idle",
}
},
paramtype2 = "4dir",
@ -100,7 +106,7 @@ rgt_machines.register_machine("arc_furnace", {
local inv = m:get_inventory()
inv:set_size("input", 1)
m:set_int("fluid_capacity", 10)
m:set_float("fluid_capacity", 10)
m:set_string("active", "false")
update_formspec(m)

View file

@ -1,2 +1,2 @@
name = rgt_arc_furnace
depends = rgt_machines_core
depends = rgt_machines

View file

@ -0,0 +1,167 @@
local ns = rgt_machines
ns.casting_recipes = {
{
name = "plate",
label = "Plate"
},
{
name = "rod",
label = "Rod"
},
{
name = "gear",
label = "Gear"
},
}
local function can_work(node, m, inv)
-- Do we have an input item?
local fluid = m:get_float "fluid"
if m:contains "recipe" and m:contains "fluid_type" and fluid > 0 and inv:get_stack("output", 1):get_free_space() > 0 then
return true
end
return false
end
local function update_formspec(m, progress)
progress = progress or m:get_int "progress"
local fluid_type = m:get_string "fluid_type"
local fluid = m:get_float "fluid"
local capacity = m:get_int "fluid_capacity"
local progressbar = progress == 0 and "rgt_progress_bg.png^[transformR270" or "rgt_progress_bg.png^[lowpart:"..progress..":rgt_progress_bg_active.png^[transformR270"
local fluidcontainer = fluid == 0 and "rgt_fluid_container_bg.png" or "rgt_fluid_container_bg.png^[lowpart:"..(fluid /capacity *100)..":rgt_fluid_container_bg_filled.png"
local fs = {"\
formspec_version[10]\
size[12,12]\
image[3.5,2;1,1;", progressbar, "]\
image[2,1;1,3;", minetest.formspec_escape(fluidcontainer), "]\
label[0.5,0.5;", fluid, " / ", capacity, "]\
", ui.list("context", "output", 5, 2, 1, 1), "\
"}
fs[#fs +1] = ui.list("current_player", "main", 1.125, 6.5, 8, 4)
fs[#fs +1] = "\
listring[]"
local recipe = m:get "recipe"
local x = 0
local y = 0
for _, r in ipairs(ns.casting_recipes) do
if r.name == recipe then
fs[#fs +1] = "style[select_recipe_"..r.name..";bgimg=rgt_other_button_bg.png]"
end
fs[#fs +1] = "image_button["..(x *1.1 +7)..","..(y +1.5)..";1,1;rgt_cast_"..r.name..".png;select_recipe_"..r.name..";]\
tooltip[select_recipe_"..r.name..";"..(r.label or r.name).."]\
"
x = x +1
end
m:set_string("formspec", table.concat(fs))
end
local function activate(pos, node, m)
m:set_string("active", "true")
node.name = "casting_basin_active"
minetest.swap_node(pos, node)
end
local function deactivate(pos, node, m)
m:set_string("active", "false")
m:set_int("progress", 0)
update_formspec(m)
node.name = "casting_basin_idle"
minetest.swap_node(pos, node)
end
local function update(pos, elapsed)
local node = minetest.get_node(pos)
local m = minetest.get_meta(pos)
local inv = m:get_inventory()
local active = m:get_string("active") == "true"
if can_work(node, m, inv) then
if not active then
active = true
activate(pos, node, m)
end
local progress = m:get_int("progress") +20
if progress >= 100 then
local fluid = m:get_float "fluid"
fluid = fluid -1
m:set_float("fluid", fluid)
local s = inv:get_stack("output", 1)
if s and s:get_count() > 0 then
s:set_count(s:get_count() +1)
else
s = ItemStack(m:get_string("fluid_type").."_"..m:get_string("recipe"))
end
inv:set_stack("output", 1, s)
progress = 0
end
m:set_int("progress", progress)
update_formspec(m, progress)
elseif active then
active = false
deactivate(pos, node, m)
end
return true
end
rgt_machines.register_machine("casting_basin", {
states = {
idle = {
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_casting_basin_front.png"}
},
active = {
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_casting_basin_front_active.png"},
drop = "casting_basin_idle",
}
},
paramtype2 = "4dir",
groups = {dig_immediate = 3, fluid_sink = 1},
on_construct = function(pos)
local m = minetest.get_meta(pos)
local inv = m:get_inventory()
inv:set_size("output", 1)
m:set_int("fluid_capacity", 10)
m:set_string("active", "false")
update_formspec(m)
minetest.get_node_timer(pos):start(1)
end,
on_destruct = function(pos)
local m = minetest.get_meta(pos)
local inv = m:get_inventory()
for i = 1, inv:get_size("input") do
local item = minetest.add_item(pos, inv:get_stack("input", i))
if item then
item:set_velocity(vector.random_direction() *math.random(2, 3))
end
end
end,
allow_metadata_inventory_put = function(pos, list, idx, s, p)
return 0
end,
on_receive_fields = function(pos, form, data, p)
for k, v in pairs(data) do
if k:find "^select_recipe_" then
local m = minetest.get_meta(pos)
local recipe = k:match "^select_recipe_(.*)"
m:set_string("recipe", recipe)
update_formspec(m)
end
end
end,
on_timer = update
})

View file

@ -0,0 +1,2 @@
name = rgt_casting_basin
depends = rgt_machines

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

View file

@ -33,7 +33,7 @@ rgt_machines.register_machine("fuel_furnace", {
local inv = m:get_inventory()
inv:set_size("input", 1)
inv:set_size("output", 1)
-- Dummy list handle Shift-adding properly.
-- Dummy list to handle Shift-adding properly.
inv:set_size("sort", 1)
inv:set_size("fuel", 1)

View file

@ -1,2 +1,2 @@
name = rgt_furnace
depends = rgt_machines_core
depends = rgt_machines

View file

@ -0,0 +1,38 @@
local ns = rgt_machines
local nodebox = {
type = "connected",
disconnected = {1/8, 1/8, 1/8, -1/8, -1/8, -1/8},
connect_top = {1/8, 1/2, 1/8, -1/8, -1/8, -1/8},
connect_bottom = {1/8, 1/8, 1/8, -1/8, -1/2, -1/8},
connect_front = {1/8, 1/8, 1/8, -1/8, -1/8, -1/2},
connect_left = {1/8, 1/8, 1/8, -1/2, -1/8, -1/8},
connect_back = {1/8, 1/8, 1/2, -1/8, -1/8, -1/8},
connect_right = {1/2, 1/8, 1/8, -1/8, -1/8, -1/8}
}
function ns.register_cable(type, def)
rgt.register_node("cable_"..type, {
drawtype = "nodebox",
node_box = nodebox,
connects_to = {"group:cable", "group:machine"},
tiles = {"rgt_cable_"..type..".png"},
groups = {cable = 1, dig_immediate = 3, network_component = 1},
paramtype = "light",
sunlight_propagates = true,
on_construct = function(pos)
ns.update_network(pos)
end,
after_destruct = function(pos)
ns.update_network(pos)
end,
cable_def = def
})
end
ns.register_cable("copper", {
resistance = 0,
max_transference = 200
})
-- //lua say(dump(minetest.get_meta(rgt.players.singleplayer.pos:round()):to_table()))

View file

@ -0,0 +1,74 @@
local ns = rgt_machines
-- The recursive funtion that executes a request to push fluid to a network.
local function push_fluid(pos, node, ctx)
-- Indicate that this node has now been checked.
ctx.ignore[minetest.hash_node_position(pos)] = true
-- If the node is a sink, add as much fluid to it as we can.
if minetest.get_item_group(node, "fluid_sink") > 0 then
local m = minetest.get_meta(pos)
local fluid = m:get_float "fluid"
local fluid_type = m:get "fluid_type"
local space = m:get_float "fluid_capacity" -fluid
-- If possible, cast the type of an empty tank to that of the fluid we're pushing; if, however, the tank already contains some amount of a different fluid type, we should not push anything.
if ctx.type ~= fluid_type then
if not fluid_type or fluid == 0 then
m:set_string("fluid_type", ctx.type)
else
return
end
end
-- Push as much fluid into the receiver's tank as we can, and decrement the amount awaiting transfer appropriately.
if space >= ctx.amount then
m:set_float("fluid", fluid +ctx.amount)
ctx.amount = 0
else
m:set_float("fluid", fluid +space)
ctx.amount = ctx.amount -space
end
-- If the node is a pipe, continue pushing to its neighbors.
elseif minetest.get_item_group(node, "pipe") > 0 then
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
-- If we've no fluid left to push, we can just stop.
if ctx.amount <= 0 then break end
if not ctx.ignore[minetest.hash_node_position(pos +x)] then
push_fluid(pos +x, node, ctx)
end
end
end
end
-- Pushes fluid from `pos` to any connected fluid network.
-- Returns the amount of fluid that was successfully pushed.
function ns.push_fluid(pos, type, amount)
-- Create a master storage table for this push request.
local ctx = {
ignore = {minetest.hash_node_position(pos)}, -- Nodes we have already checked.
type = type, -- The type of the fluid we are sending.
amount = amount -- How much fluid remains to be sent.
}
-- Recursively dispatch the request to all neighbors in sequence.
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
if ctx.amount > 0 and not ctx.ignore[minetest.hash_node_position(pos +x)] then
push_fluid(pos +x, minetest.get_node(pos +x).name, ctx)
end
end
-- Return the amount we were able to transfer (amount requested minus amount left).
return amount -ctx.amount
end
-- Pulls fluid into `pos` from any connected fluid network.
-- Returns false if no fluid could be pulled, and the amount pulled otherwise.
function ns.pull_fluid(pos)
end
function ns.register_fluid_tank(name, def)
rgt.register_node("fluid_tank_"..name, {
})
end

View file

@ -0,0 +1,171 @@
--[[
List of machines:
- Arc furnace: Melts materials into their liquid form
--]]
rgt_machines = {
registered_machines = {},
networks = {}
}
local ns = rgt_machines
local db = minetest.get_mod_storage()
function ns.get_network(id)
return minetest.deserialize(db:get(id) or "return nil") or {supply = 0, demand = 0}
end
-- This abstracts away the use of multiple nodes for visual state feedback by
-- copying all node callbacks into each node, so that by default the machine
-- behaves exactly the same regardless of the underlying node type.
--[[
{
states = { ... }, -- Alternate visual states for this node. All properties of the resultant node may be overriden.
...
}
--]]
function ns.register_machine(name, def)
if not def.groups then
def.groups = {}
end
def.groups.machine = 1
def.groups.network_component = 1
def.groups.run_on_activate = 1
def.groups[name] = 1
-- Ensure that we update the network when a machine is placed or removed.
local _on_construct = def.on_construct
def.on_construct = function(pos)
ns.update_network(pos)
if _on_construct then _on_construct(pos) end
end
local _after_destruct = def.after_destruct
def.after_destruct = function(pos)
ns.update_network(pos)
if _after_destruct then _after_destruct(pos) end
end
ns.registered_machines[name] = def
for state, x in pairs(def.states) do
rgt.register_node(name.."_"..state, extend(table.copy(def), x))
end
end
-- Recursively propagate a network reassignment to all connected nodes (ignoring positions in `ignore`).
local function propagate_network_update(pos, net, ignore)
ignore[minetest.hash_node_position(pos)] = true
-- Store the network to the target node.
minetest.get_meta(pos):set_string("network", net)
-- Check each neighboring node for further propagation.
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
-- If we already checked this node, we shouldn't consider it to avoid infinite recursion.
if not ignore[minetest.hash_node_position(pos +x)] then
local cid = minetest.get_node_raw(pos.x +x.x, pos.y +x.y, pos.z +x.z)
-- Ensure that this node can belong to a network and thus is a valid propagation target.
if minetest.get_item_group(rgt.content_ids_to_nodes[cid], "network_component") > 0 then
propagate_network_update(pos +x, net, ignore)
end
end
end
end
-- Called when a pos is added to or removed from a network.
-- Whether an addition or deletion is being performed depends on whether the node at `pos` belongs to the `network_component` group.
function ns.update_network(pos)
-- We're adding a node.
if minetest.get_item_group(minetest.get_node(pos).name, "network_component") > 0 then
-- Find all adjacent networks.
local net
local nets = {}
local num_nets = 0
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
-- Ensure that this is a node that should have a network field.
if minetest.get_item_group(minetest.get_node(pos +x).name, "network_component") > 0 then
local n = minetest.get_meta(pos +x):get("network")
-- If the node doesn't have a network for some reason, we should give it one.
if not n or table.indexof(nets, n) == -1 then
-- Set our network to the first one we find.
if not net then
net = n
-- Store the positions of any other adjacent networks, so we can merge them with ours.
elseif net ~= n then
nets[#nets +1] = x
end
num_nets = num_nets +1
end
end
end
-- Propagate our chosen network to adjacent networks with different IDs.
-- If we didn't find any adjacent networks, this will just do nothing.
local ignore = {[minetest.hash_node_position(pos)] = true}
for _, x in ipairs(nets) do
propagate_network_update(pos +x, net, ignore)
end
-- Create a new unique network ID if none of our neighbors have one.
if not net then
net = string.format("net_%d_%06d", minetest.get_us_time(), math.random(100000, 999999))
end
-- Save our chosen network ID.
minetest.get_meta(pos):set_string("network", net)
-- We're removing a node.
else
-- Find all adjacent networks.
local net
local nets = {}
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
-- Ensure that this is a node that should have a network field.
if minetest.get_item_group(minetest.get_node(pos +x).name, "network_component") > 0 then
local n = minetest.get_meta(pos +x):get("network")
nets[#nets +1] = x
end
end
-- We only need to ensure that these networks are unique, thus one of them can keep its original ID.
if #nets > 1 then table.remove(nets, 1) end
-- Create a new ID for each network and propagate it.
local pos_hash = minetest.hash_node_position(pos)
for _, x in ipairs(nets) do
net = string.format("net_%d_%06d", minetest.get_us_time(), math.random(100000, 999999))
-- Provide a different ignore table each time, to ensure that when the same network abuts this node on multiple edges, all touching nodes get the same network in the end.
propagate_network_update(pos +x, net, {[pos_hash] = true})
end
end
return true
end
function ns.add_network_supply(id, amount)
local net = ns.get_network(id)
net.supply = net.supply +amount
db:set_string(id, minetest.serialize(net))
end
function ns.remove_network_supply(id, amount)
ns.add_network_supply(id, -amount)
end
function ns.change_network_supply(id, from, to)
ns.add_network_supply(id, to -from)
end
function ns.add_network_demand(id, amount)
local net = ns.get_network(id)
net.demand = net.demand +amount
db:set_string(id, minetest.serialize(net))
end
function ns.remove_network_demand(id, amount)
ns.add_network_demand(id, -amount)
end
function ns.change_network_demand(id, from, to)
ns.add_network_demand(id, to -from)
end
include "fluids.lua"
include "cables.lua"
include "pipes.lua"

View file

@ -0,0 +1,2 @@
name = rgt_machines
depends = rgt_world, rgt_player

View file

@ -6,7 +6,7 @@ local function update_pipe(pos, leaf)
local dir
local pipe
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
for _, offset in ipairs(rgt.adjacent_neighbor_offests) do
pipe = minetest.get_node(pos +offset)
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
neighbors[#neighbors +1] = offset
@ -48,7 +48,7 @@ rgt.register_node("pipe_straight", {
update_pipe(pos)
end,
after_destruct = function(pos)
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
for _, offset in ipairs(rgt.adjacent_neighbor_offests) do
pipe = minetest.get_node(pos +offset)
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
update_pipe(pos +offset, true)
@ -70,7 +70,7 @@ rgt.register_node("pipe_straight_single_cap", {
update_pipe(pos)
end,
after_destruct = function(pos)
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
for _, offset in ipairs(rgt.adjacent_neighbor_offests) do
pipe = minetest.get_node(pos +offset)
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
update_pipe(pos +offset, true)
@ -92,7 +92,7 @@ rgt.register_node("pipe_straight_double_cap", {
update_pipe(pos)
end,
after_destruct = function(pos)
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
for _, offset in ipairs(rgt.adjacent_neighbor_offests) do
pipe = minetest.get_node(pos +offset)
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
update_pipe(pos +offset, true)

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

View file

Before

Width:  |  Height:  |  Size: 896 B

After

Width:  |  Height:  |  Size: 896 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

Before After
Before After

View file

@ -1,11 +0,0 @@
local ns = rgt_machines
function ns.create_fluid_tank(m)
end
function ns.make_fluid_display(x, y, fliud, max, amount)
local fs = {}
return table.concat(fs)
end

View file

@ -1,36 +0,0 @@
--[[
List of machines:
- Arc furnace: Melts materials into their liquid form
--]]
rgt_machines = {
registered_machines = {}
}
local ns = rgt_machines
-- This abstracts away the use of multiple nodes for visual state feedback by
-- copying all node callbacks into each node, so that by default the machine
-- behaves exactly the same regardless of the underlying node type.
--[[
{
states = { ... }, -- Alternate visual states for this node. All properties of the resultant node may be overriden.
...
}
--]]
function ns.register_machine(name, def)
if not def.groups then
def.groups = {}
end
def.groups.rgt_machine = 1
def.groups.run_on_activate = 1
def.groups[name] = 1
ns.registered_machines[name] = def
for state, x in pairs(def.states) do
rgt.register_node(name.."_"..state, extend(table.copy(def), x))
end
end
include "fluids.lua"
include "pipes.lua"

View file

@ -1,2 +0,0 @@
name = rgt_machines_core
depends = rgt_world, rgt_player

View file

@ -0,0 +1,132 @@
local function can_work(node, m, inv)
-- Do we have an input item?
local input = inv:get_stack("input", 1)
if input:get_count() > 0 then
return true
end
return false
end
local function update_formspec(m, progress)
progress = progress or m:get_int "progress"
local fluid = m:get_float "fluid"
local capacity = m:get_int "fluid_capacity"
local progressbar = progress == 0 and "rgt_progress_bg.png^[transformR270" or "rgt_progress_bg.png^[lowpart:"..progress..":rgt_progress_bg_active.png^[transformR270"
local fluidcontainer = fluid == 0 and "rgt_fluid_container_bg.png" or "rgt_fluid_container_bg.png^[lowpart:"..(fluid /capacity *100)..":rgt_fluid_container_bg_filled.png"
local fs = {"\
formspec_version[10]\
size[12,12]\
", ui.list("context", "input", 2, 2, 1, 1), "\
image[4,2;1,1;", progressbar, "]\
image[7,1;1,3;", minetest.formspec_escape(fluidcontainer), "]\
label[0.5,0.5;", fluid, " / ", capacity, "]\
"}
fs[#fs +1] = ui.list("current_player", "main", 1.125, 6.5, 8, 4)
fs[#fs +1] = "\
listring[]"
m:set_string("formspec", table.concat(fs))
end
local function activate(pos, node, m)
m:set_string("active", "true")
node.name = "steam_generator_active"
minetest.swap_node(pos, node)
end
local function deactivate(pos, node, m)
m:set_string("active", "false")
m:set_int("progress", 0)
update_formspec(m)
node.name = "steam_generator_idle"
minetest.swap_node(pos, node)
end
local function update(pos, elapsed)
local node = minetest.get_node(pos)
local m = minetest.get_meta(pos)
local inv = m:get_inventory()
local active = m:get_string("active") == "true"
if can_work(node, m, inv) then
if not active then
active = true
activate(pos, node, m)
end
local progress = m:get_int("progress") +20
if progress >= 100 then
local fluid = m:get_float "fluid"
fluid = fluid +1
m:set_float("fluid", fluid)
-- Consume an item.
local s = inv:get_stack("input", 1)
s:take_item()
inv:set_stack("input", 1, s)
progress = 0
end
m:set_int("progress", progress)
update_formspec(m, progress)
elseif active then
active = false
deactivate(pos, node, m)
end
return true
end
rgt_machines.register_machine("steam_generator", {
states = {
idle = {
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_steam_generator_front.png"}
},
active = {
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_steam_generator_front_active.png"},
drop = "steam_generator_idle",
}
},
paramtype2 = "4dir",
groups = {dig_immediate = 3},
on_construct = function(pos)
local m = minetest.get_meta(pos)
local inv = m:get_inventory()
inv:set_size("input", 1)
m:set_int("fluid_capacity", 10)
m:set_string("active", "false")
update_formspec(m)
minetest.get_node_timer(pos):start(1)
end,
on_destruct = function(pos)
local m = minetest.get_meta(pos)
local inv = m:get_inventory()
for i = 1, inv:get_size("input") do
local item = minetest.add_item(pos, inv:get_stack("input", i))
if item then
item:set_velocity(vector.random_direction() *math.random(2, 3))
end
end
end,
allow_metadata_inventory_put = function(pos, list, idx, s, p)
local inv = minetest.get_meta(pos):get_inventory()
local meltable = minetest.registered_items[s:get_name()].groups.arc_furnace_meltable
if meltable then
if inv:room_for_item("input", s) then
return s:get_count()
elseif inv:room_for_item("input", s:take_item()) then
return s:get_stack_max() -inv:get_stack("input", 1):get_count()
end
end
return 0
end,
on_timer = update
})

View file

@ -0,0 +1,2 @@
name = rgt_steam_generator
depends = rgt_machines

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B