Add things

This commit is contained in:
Signal 2025-10-27 22:05:23 -04:00
parent 4d8312b79d
commit 00e1fd985d
28 changed files with 395 additions and 31 deletions

View file

@ -0,0 +1,139 @@
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
-- 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
return true
end
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 deactivate(pos, node, m)
m:set_string("active", "false")
m:set_int("progress", 0)
update_formspec(m)
node.name = "arc_furnace_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
m:set_string("active", "true")
node.name = "arc_furnace_active"
minetest.swap_node(pos, node)
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--minetest.get_node_timer(pos):start(active and 1 or 1)
end
rgt_machines.register_machine("arc_furnace", {
states = {
idle = {
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.png"}
},
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"
}
},
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_metadata_inventory_put = function(pos, list)
end,
on_metadata_inventory_take = function(pos, list)
end,
on_timer = update
})

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

View file

@ -0,0 +1,11 @@
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,3 +1,9 @@
--[[
List of machines:
- Arc furnace: Melts materials into their liquid form
--]]
rgt_machines = {
registered_machines = {}
}
@ -25,3 +31,6 @@ function ns.register_machine(name, def)
end
end
include "fluids.lua"
include "pipes.lua"

View file

@ -0,0 +1 @@
{"asset":{"version":"2.0","generator":"Blockbench 4.12.5 glTF exporter"},"scenes":[{"nodes":[1],"name":"blockbench_export"}],"scene":0,"nodes":[{"name":"cube","mesh":0},{"children":[0]}],"bufferViews":[{"buffer":0,"byteOffset":0,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":288,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":576,"byteLength":192,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":768,"byteLength":72,"target":34963}],"buffers":[{"byteLength":840,"uri":"data:application/octet-stream;base64,AADwPwAA8D8AAKBAAADwPwAA8D8AAKDAAADwPwAA8L8AAKBAAADwPwAA8L8AAKDAAADwvwAA8D8AAKDAAADwvwAA8D8AAKBAAADwvwAA8L8AAKDAAADwvwAA8L8AAKBAAADwvwAA8D8AAKDAAADwPwAA8D8AAKDAAADwvwAA8D8AAKBAAADwPwAA8D8AAKBAAADwvwAA8L8AAKBAAADwPwAA8L8AAKBAAADwvwAA8L8AAKDAAADwPwAA8L8AAKDAAADwvwAA8D8AAKBAAADwPwAA8D8AAKBAAADwvwAA8L8AAKBAAADwPwAA8L8AAKBAAADwPwAA8D8AAKDAAADwvwAA8D8AAKDAAADwPwAA8L8AAKDAAADwvwAA8L8AAKDAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIA+AAAAAAAAAAAAAMA9AACAPgAAwD0AAAAAAADAPQAAgD4AAMA9AAAAAAAAQD4AAIA+AABAPgAAwD0AAOA+AAAAAAAA4D4AAMA9AABAPgAAAAAAAEA+AABAPgAAQD4AAMA9AABAPgAAQD4AAOA+AADAPQAA4D4AAKA+AACwPgAA0D4AALA+AACgPgAA4D4AANA+AADgPgAAoD4AAIA+AADQPgAAgD4AAKA+AACwPgAA0D4AALA+AAACAAEAAgADAAEABAAGAAUABgAHAAUACAAKAAkACgALAAkADAAOAA0ADgAPAA0AEAASABEAEgATABEAFAAWABUAFgAXABUA"}],"accessors":[{"bufferView":0,"componentType":5126,"count":24,"max":[1.875,1.875,5],"min":[-1.875,-1.875,-5],"type":"VEC3"},{"bufferView":1,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},{"bufferView":2,"componentType":5126,"count":24,"max":[0.40625,0.4375],"min":[0,0],"type":"VEC2"},{"bufferView":3,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"}],"materials":[{"pbrMetallicRoughness":{"metallicFactor":0,"roughnessFactor":1,"baseColorTexture":{"index":0}},"alphaMode":"MASK","alphaCutoff":0.05,"doubleSided":true}],"textures":[{"sampler":0,"source":0,"name":"rgt_pipe_straight"}],"samplers":[{"magFilter":9728,"minFilter":9728,"wrapS":33071,"wrapT":33071}],"images":[{"mimeType":"image/png","name":"rgt_pipe_straight.png","uri":"rgt_pipe_straight.png"}],"meshes":[{"primitives":[{"mode":4,"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}]}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"asset":{"version":"2.0","generator":"Blockbench 4.12.5 glTF exporter"},"scenes":[{"nodes":[2],"name":"blockbench_export"}],"scene":0,"nodes":[{"name":"cube","mesh":0},{"name":"cube","mesh":1},{"children":[0,1]}],"bufferViews":[{"buffer":0,"byteOffset":0,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":288,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":576,"byteLength":192,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":768,"byteLength":72,"target":34963},{"buffer":0,"byteOffset":840,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":1128,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":1416,"byteLength":192,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":1608,"byteLength":72,"target":34963}],"buffers":[{"byteLength":1680,"uri":"data:application/octet-stream;base64,AAAgQAAAIEAAAHDAAAAgQAAAIEAAAKDAAAAgQAAAIMAAAHDAAAAgQAAAIMAAAKDAAAAgwAAAIEAAAKDAAAAgwAAAIEAAAHDAAAAgwAAAIMAAAKDAAAAgwAAAIMAAAHDAAAAgwAAAIEAAAKDAAAAgQAAAIEAAAKDAAAAgwAAAIEAAAHDAAAAgQAAAIEAAAHDAAAAgwAAAIMAAAHDAAAAgQAAAIMAAAHDAAAAgwAAAIMAAAKDAAAAgQAAAIMAAAKDAAAAgwAAAIEAAAHDAAAAgQAAAIEAAAHDAAAAgwAAAIMAAAHDAAAAgQAAAIMAAAHDAAAAgQAAAIEAAAKDAAAAgwAAAIEAAAKDAAAAgQAAAIMAAAKDAAAAgwAAAIMAAAKDAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAA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AvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAPQAAAAAAAIA+AAAAAAAAAD0AAMA9AACAPgAAwD0AAAA9AADAPQAAgD4AAMA9AAAAPQAAQD4AAIA+AABAPgAAwD0AANA+AAAAAAAA0D4AAMA9AABAPgAAAAAAAEA+AABAPgAAQD4AAMA9AABAPgAAQD4AANA+AADAPQAA0D4AAKA+AACwPgAA0D4AALA+AACgPgAA4D4AANA+AADgPgAAoD4AAIA+AADQPgAAgD4AAKA+AACwPgAA0D4AALA+AAACAAEAAgADAAEABAAGAAUABgAHAAUACAAKAAkACgALAAkADAAOAA0ADgAPAA0AEAASABEAEgATABEAFAAWABUAFgAXABUA"}],"accessors":[{"bufferView":0,"componentType":5126,"count":24,"max":[2.5,2.5,-3.75],"min":[-2.5,-2.5,-5],"type":"VEC3"},{"bufferView":1,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},{"bufferView":2,"componentType":5126,"count":24,"max":[0.53125,0.3125],"min":[0.1875,0],"type":"VEC2"},{"bufferView":3,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":24,"max":[1.875,1.875,5],"min":[-1.875,-1.875,-3.75],"type":"VEC3"},{"bufferView":5,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},{"bufferView":6,"componentType":5126,"count":24,"max":[0.40625,0.4375],"min":[0,0],"type":"VEC2"},{"bufferView":7,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"}],"materials":[{"pbrMetallicRoughness":{"metallicFactor":0,"roughnessFactor":1,"baseColorTexture":{"index":0}},"alphaMode":"MASK","alphaCutoff":0.05,"doubleSided":true}],"textures":[{"sampler":0,"source":0,"name":"rgt_pipe_straight"}],"samplers":[{"magFilter":9728,"minFilter":9728,"wrapS":33071,"wrapT":33071}],"images":[{"mimeType":"image/png","name":"rgt_pipe_straight.png","uri":"rgt_pipe_straight.png"}],"meshes":[{"primitives":[{"mode":4,"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"primitives":[{"mode":4,"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}]}

View file

@ -0,0 +1,102 @@
local ns = rgt_machines
local function update_pipe(pos, leaf)
local node = minetest.get_node(pos)
local neighbors = {}
local dir
local pipe
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
pipe = minetest.get_node(pos +offset)
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
neighbors[#neighbors +1] = offset
end
end
if #neighbors == 0 then
node.name = "pipe_straight_double_cap"
minetest.swap_node(pos, node)
elseif #neighbors == 1 then
node.name = "pipe_straight_single_cap"
node.param2 = minetest.dir_to_facedir(-neighbors[1])
minetest.swap_node(pos, node)
elseif #neighbors == 2 then
node.name = "pipe_straight"
node.param2 = minetest.dir_to_facedir(neighbors[1])
minetest.swap_node(pos, node)
else
end
if not leaf then
for _, x in ipairs(neighbors) do
update_pipe(pos +x, true)
end
end
end
rgt.register_node("pipe_straight", {
drawtype = "mesh",
mesh = "rgt_pipe_straight.gltf",
tiles = {"rgt_pipe_straight.png"},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
groups = {pipe = 1, pipe_straight = 1, dig_immediate = 3},
drop = "pipe_straight",
on_construct = function(pos)
update_pipe(pos)
end,
after_destruct = function(pos)
for _, offset in ipairs(rgt.adjacent_horizontal_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)
end
end
end
})
rgt.register_node("pipe_straight_single_cap", {
drawtype = "mesh",
mesh = "rgt_pipe_straight_single_cap.gltf",
tiles = {"rgt_pipe_straight.png"},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
groups = {pipe = 1, pipe_straight = 1, dig_immediate = 3},
drop = "pipe_straight",
on_construct = function(pos)
update_pipe(pos)
end,
after_destruct = function(pos)
for _, offset in ipairs(rgt.adjacent_horizontal_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)
end
end
end
})
rgt.register_node("pipe_straight_double_cap", {
drawtype = "mesh",
mesh = "rgt_pipe_straight_double_cap.gltf",
tiles = {"rgt_pipe_straight.png"},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
groups = {pipe = 1, pipe_straight = 1, dig_immediate = 3},
drop = "pipe_straight",
on_construct = function(pos)
update_pipe(pos)
end,
after_destruct = function(pos)
for _, offset in ipairs(rgt.adjacent_horizontal_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)
end
end
end
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B