Add mods: technic, moreores, paintings, Nyancat (Pbj_pup). Small fix: sandwiches

This commit is contained in:
N-Nachtigal 2025-06-05 16:15:56 +02:00
parent 15e8e696a2
commit fb09deddc1
1404 changed files with 156555 additions and 211 deletions

View file

@ -0,0 +1,131 @@
local S = technic.getter
local desc = S("Administrative World Anchor")
local function compute_forceload_positions(pos, meta)
local radius = meta:get_int("radius")
local minpos = vector.subtract(pos, vector.new(radius, radius, radius))
local maxpos = vector.add(pos, vector.new(radius, radius, radius))
local minbpos = {}
local maxbpos = {}
for _, coord in ipairs({"x","y","z"}) do
minbpos[coord] = math.floor(minpos[coord] / 16) * 16
maxbpos[coord] = math.floor(maxpos[coord] / 16) * 16
end
local flposes = {}
for x = minbpos.x, maxbpos.x, 16 do
for y = minbpos.y, maxbpos.y, 16 do
for z = minbpos.z, maxbpos.z, 16 do
table.insert(flposes, vector.new(x, y, z))
end
end
end
return flposes
end
local function currently_forceloaded_positions(meta)
local ser = meta:get_string("forceloaded")
return ser == "" and {} or minetest.deserialize(ser)
end
local function forceload_off(meta)
local flposes = currently_forceloaded_positions(meta)
meta:set_string("forceloaded", "")
for _, p in ipairs(flposes) do
minetest.forceload_free_block(p)
end
end
local function forceload_on(pos, meta)
local want_flposes = compute_forceload_positions(pos, meta)
local have_flposes = {}
for _, p in ipairs(want_flposes) do
if minetest.forceload_block(p) then
table.insert(have_flposes, p)
end
end
meta:set_string("forceloaded", #have_flposes == 0 and "" or minetest.serialize(have_flposes))
end
local function set_display(pos, meta)
meta:set_string("infotext", S(meta:get_int("enabled") ~= 0 and "@1 Enabled" or "@1 Disabled", desc))
meta:set_string("formspec",
"size[5,3.5]"..
"item_image[0,0;1,1;technic:admin_anchor]"..
"label[1,0;"..desc.."]"..
"label[0,1;"..S("Owner: @1", meta:get_string("owner")).."]"..
(meta:get_int("locked") == 0 and
"button[3,1;2,1;lock;"..S("Unlocked").."]" or
"button[3,1;2,1;unlock;"..S("Locked").."]")..
"field[0.25,2.3;1,1;radius;"..S("Radius")..";${radius}]"..
(meta:get_int("enabled") == 0 and
"button[3,2;2,1;enable;"..S("Disabled").."]" or
"button[3,2;2,1;disable;"..S("Enabled").."]")..
"label[0,3;"..S("Keeping @1/@2 map blocks loaded",
#currently_forceloaded_positions(meta), #compute_forceload_positions(pos, meta)).."]")
end
minetest.register_node("technic:admin_anchor", {
description = desc,
drawtype = "normal",
tiles = {"technic_admin_anchor.png"},
is_ground_content = false,
groups = {cracky=3, not_in_creative_inventory=1, pickaxey=1},
_mcl_blast_resistance = 1,
_mcl_hardness = 0.8,
sounds = technic.sounds.node_sound_stone_defaults(),
after_place_node = function (pos, placer)
local meta = minetest.get_meta(pos)
if placer and placer:is_player() then
meta:set_string("owner", placer:get_player_name())
end
set_display(pos, meta)
end,
can_dig = function (pos, player)
local meta = minetest.get_meta(pos)
return meta:get_int("locked") == 0 or (player and player:is_player()
and player:get_player_name() == meta:get_string("owner"))
end,
on_destruct = function (pos)
local meta = minetest.get_meta(pos)
forceload_off(meta)
end,
on_receive_fields = function (pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
if (meta:get_int("locked") ~= 0 or fields.lock) and
not (sender and sender:is_player() and
sender:get_player_name() == meta:get_string("owner")) then
return
end
if fields.unlock then meta:set_int("locked", 0) end
if fields.lock then meta:set_int("locked", 1) end
if fields.disable or fields.enable or fields.radius then
forceload_off(meta)
if fields.disable then meta:set_int("enabled", 0) end
if fields.enable then meta:set_int("enabled", 1) end
if fields.radius and string.find(fields.radius, "^[0-9]+$") and tonumber(fields.radius) < 256 then
meta:set_int("radius", fields.radius)
end
if meta:get_int("enabled") ~= 0 then
forceload_on(pos, meta)
end
end
set_display(pos, meta)
end,
mesecons = {
effector = {
action_on = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("enabled", 1)
forceload_on(pos, meta)
set_display(pos, meta)
end,
action_off = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("enabled", 0)
forceload_off(meta)
set_display(pos, meta)
end
}
}
})

View file

@ -0,0 +1,206 @@
-- Fuel driven alloy furnace. This uses no EUs:
local S = technic.getter
local mat = technic.materials
minetest.register_craft({
output = 'technic:coal_alloy_furnace',
recipe = {
{mat.brick, mat.brick, mat.brick},
{mat.brick, '', mat.brick},
{mat.brick, mat.brick, mat.brick},
}
})
local machine_name = S("Fuel-Fired Alloy Furnace")
local size = minetest.get_modpath("mcl_formspec") and "size[9,9]" or "size[8,9]"
local formspec =
size..
"label[0,0;"..machine_name.."]"..
"image[2,2;1,1;default_furnace_fire_bg.png]"..
"list[context;fuel;2,3;1,1;]"..
"list[context;src;2,1;2,1;]"..
"list[context;dst;5,1;2,2;]"
if minetest.get_modpath("mcl_formspec") then
formspec = formspec..
mcl_formspec.get_itemslot_bg(2,3,1,1)..
mcl_formspec.get_itemslot_bg(2,1,2,1)..
mcl_formspec.get_itemslot_bg(5,1,2,2)..
-- player inventory
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)
else
formspec = formspec..
"list[current_player;main;0,5;8,4;]"
end
-- listrings
formspec = formspec..
"listring[context;dst]"..
"listring[current_player;main]"..
"listring[context;src]"..
"listring[current_player;main]"..
"listring[context;fuel]"..
"listring[current_player;main]"
minetest.register_node("technic:coal_alloy_furnace", {
description = machine_name,
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png",
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png",
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2, pickaxey=2},
is_ground_content = false,
_mcl_blast_resistance = 1,
_mcl_hardness = 0.8,
legacy_facedir_simple = true,
sounds = technic.sounds.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", formspec)
meta:set_string("infotext", machine_name)
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("src", 2)
inv:set_size("dst", 4)
end,
can_dig = technic.machine_can_dig,
allow_metadata_inventory_put = technic.machine_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
on_metadata_inventory_move = technic.machine_on_inventory_move,
on_metadata_inventory_put = technic.machine_on_inventory_put,
on_metadata_inventory_take = technic.machine_on_inventory_take,
})
minetest.register_node("technic:coal_alloy_furnace_active", {
description = machine_name,
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png",
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png",
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "technic:coal_alloy_furnace",
groups = {cracky=2, not_in_creative_inventory=1, pickaxey=2},
is_ground_content = false,
_mcl_blast_resistance = 1,
_mcl_hardness = 0.8,
legacy_facedir_simple = true,
sounds = technic.sounds.node_sound_stone_defaults(),
can_dig = technic.machine_can_dig,
allow_metadata_inventory_put = technic.machine_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
on_metadata_inventory_move = technic.machine_on_inventory_move,
on_metadata_inventory_put = technic.machine_on_inventory_put,
on_metadata_inventory_take = technic.machine_on_inventory_take,
})
minetest.register_abm({
label = "Machines: run coal alloy furnace",
nodenames = {"technic:coal_alloy_furnace", "technic:coal_alloy_furnace_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local src_list = inv:get_list("src")
if not src_list then
return
end
for i, name in pairs({
"fuel_totaltime",
"fuel_time",
"src_totaltime",
"src_time"}) do
if not meta:get_float(name) then
meta:set_float(name, 0.0)
end
end
-- Get what to cook if anything
local recipe = technic.get_recipe("alloy", src_list)
local was_active = false
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
was_active = true
meta:set_int("fuel_time", meta:get_int("fuel_time") + 1)
if recipe then
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= recipe.time then
meta:set_int("src_time", 0)
technic.process_recipe(recipe, inv)
end
else
meta:set_int("src_time", 0)
end
end
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext", S("@1 Active", machine_name).." ("..percent.."%)")
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
meta:set_string("formspec",
size..
"label[0,0;"..machine_name.."]"..
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
(100 - percent)..":default_furnace_fire_fg.png]"..
"list[context;fuel;2,3;1,1;]"..
"list[context;src;2,1;2,1;]"..
"list[context;dst;5,1;2,2;]"..
(minetest.get_modpath("mcl_formspec") and
mcl_formspec.get_itemslot_bg(2,3,1,1)..
mcl_formspec.get_itemslot_bg(2,1,2,1)..
mcl_formspec.get_itemslot_bg(5,1,2,2)..
-- player inventory
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)
or "list[current_player;main;0,5;8,4;]")..
-- listrings
"listring[context;dst]"..
"listring[current_player;main]"..
"listring[context;src]"..
"listring[current_player;main]"..
"listring[context;fuel]"..
"listring[current_player;main]")
return
end
if not technic.get_recipe("alloy", inv:get_list("src")) then
if was_active then
meta:set_string("infotext", S("@1 is empty", machine_name))
technic.swap_node(pos, "technic:coal_alloy_furnace")
meta:set_string("formspec", formspec)
end
return
end
-- Next take a hard look at the fuel situation
local fuellist = inv:get_list("fuel")
local fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
if fuel.time <= 0 then
meta:set_string("infotext", S("@1 Out Of Fuel", machine_name))
technic.swap_node(pos, "technic:coal_alloy_furnace")
meta:set_string("formspec", formspec)
return
end
meta:set_string("fuel_totaltime", fuel.time)
meta:set_string("fuel_time", 0)
inv:set_stack("fuel", 1, afterfuel.items[1])
end,
})

View file

@ -0,0 +1,7 @@
local S = technic.getter
local default_furnace = minetest.registered_nodes["default:furnace"]
if default_furnace and default_furnace.description == "Furnace" then
minetest.override_item("default:furnace", { description = S("Fuel-Fired Furnace") })
end

View file

@ -0,0 +1,246 @@
local S = technic.getter
local function deploy_node(inv, slot_name, pos, node, machine_node)
if node.param2 > 3 then return end
if node.name ~= "air" then
if node.name == "ignore" or
node.name == "default:chest_open" or
node.name == "default:chest_locked_open" or
node.name == "default:lava_source" or
node.name == "default:lava_flowing" or
node.name == "default:water_source" or
node.name == "default:water_flowing" then
return
end
local drops = minetest.get_node_drops(node.name, "")
local remove_to = false
for i, item in ipairs(drops) do
if not inv:room_for_item(slot_name, item) then
remove_to = i - 1
break
end
inv:add_item(slot_name, item)
end
if remove_to then
for i = 1, remove_to do
inv:remove_item(slot_name, drops[i])
end
else
minetest.remove_node(pos)
end
return
end
if not inv:is_empty(slot_name) then
local stack = inv:get_list(slot_name)[1]
local def = stack:get_definition()
if def.type == "node" then
minetest.set_node(pos, {
name = stack:get_name(),
param2 = machine_node.param2
})
stack:take_item()
inv:set_stack(slot_name, 1, stack)
elseif def.type == "craft" then
if def.on_place then
-- Use pcall to avoid nil placer errors.
-- TODO: Do without pcall.
local ok, stk = pcall(def.on_place, stack, nil, {
-- Fake pointed_thing
type = "node",
above = pos,
under = {x=pos.x, y=pos.y-1, z=pos.z},
})
if ok then
inv:set_stack(slot_name, 1, stk or stack)
return
end
end
minetest.item_place_object(stack, nil, {
-- Fake pointed_thing
type = "node",
above = pos,
under = pos,
})
inv:set_stack(slot_name, 1, nil)
end
end
end
minetest.register_craft({
type = "shapeless",
output = 'technic:constructor_mk1_off 1',
recipe = {'technic:nodebreaker_off', 'technic:deployer_off'},
})
minetest.register_craft({
type = "shapeless",
output = 'technic:constructor_mk2_off 1',
recipe = {'technic:constructor_mk1_off', 'technic:constructor_mk1_off'},
})
minetest.register_craft({
type = "shapeless",
output = 'technic:constructor_mk3_off 1',
recipe = {'technic:constructor_mk2_off', 'technic:constructor_mk2_off'},
})
local function make_on(mark, length)
return function(pos, node)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
local dir = vector.new()
if node.param2 == 3 then dir.x = 1 end
if node.param2 == 2 then dir.z = 1 end
if node.param2 == 1 then dir.x = -1 end
if node.param2 == 0 then dir.z = -1 end
local place_pos = vector.new(pos)
if node.name == "technic:constructor_mk"..mark.."_off" then
technic.swap_node(pos, "technic:constructor_mk"..mark.."_on")
minetest.check_for_falling(pos)
for i = 1, length do
place_pos = vector.add(place_pos, dir)
if owner ~= "" and minetest.is_protected(place_pos, owner) then
return
end
local place_node = minetest.get_node(place_pos)
deploy_node(inv, "slot"..i, place_pos, place_node, node)
end
end
end
end
local function make_off(mark)
return function(pos, node)
if node.name == "technic:constructor_mk"..mark.."_on" then
technic.swap_node(pos,"technic:constructor_mk"..mark.."_off")
minetest.check_for_falling(pos)
end
end
end
local function allow_inventory_put(pos, listname, index, stack, player)
if stack and minetest.get_item_group(stack:get_name(), "technic_constructor") == 1 then
return 0
end
return technic.machine_inventory_put(pos, listname, index, stack, player)
end
local function make_constructor(mark, length)
minetest.register_node("technic:constructor_mk"..mark.."_off", {
description = S("Constructor Mk@1", mark),
tiles = {"technic_constructor_mk"..mark.."_top_off.png",
"technic_constructor_mk"..mark.."_bottom_off.png",
"technic_constructor_mk"..mark.."_side2_off.png",
"technic_constructor_mk"..mark.."_side1_off.png",
"technic_constructor_back.png",
"technic_constructor_front_off.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
mesecon = 2, technic_constructor = 1, axey=2, handy=1},
is_ground_content = false,
_mcl_blast_resistance = 1,
_mcl_hardness = 0.8,
mesecons = {effector = {action_on = make_on(mark, length)}},
sounds = technic.sounds.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local size = minetest.get_modpath("mcl_formspec") and "size[9,9]" or "size[8,9]"
local formspec = size..
"label[0,0;"..S("Constructor Mk@1", mark).."]"
for i = 1, length do
formspec = formspec..
"label[5,"..(i - 1)..";"..S("Slot @1", i).."]"..
"list[context;slot"..i..";6,"..(i - 1)..";1,1;]"
end
if minetest.get_modpath("mcl_formspec") then
for i = 1, length do
formspec = formspec..
mcl_formspec.get_itemslot_bg(6,i-1,1,1)
end
formspec = formspec..
-- player inventory
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)
else
formspec = formspec..
"list[current_player;main;0,5;8,4;]"
end
-- listrings
for i = 1, length do
formspec = formspec..
"listring[current_player;main]"..
"listring[context;slot"..i.."]"
end
meta:set_string("formspec", formspec)
meta:set_string("infotext", S("Constructor Mk@1", mark))
local inv = meta:get_inventory()
for i = 1, length do
inv:set_size("slot"..i, 1)
end
meta:set_string("owner", "?")
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", (placer and placer:get_player_name() or "?"))
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for i = 1, length do
if not inv:is_empty("slot"..i) then
return false
end
end
return true
end,
allow_metadata_inventory_put = allow_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
on_metadata_inventory_move = technic.machine_on_inventory_move,
on_metadata_inventory_put = technic.machine_on_inventory_put,
on_metadata_inventory_take = technic.machine_on_inventory_take,
on_rotate = function(pos, node, user, mode, new_param2)
if mode ~= 1 then
return false
end
end,
})
minetest.register_node("technic:constructor_mk"..mark.."_on", {
tiles = {"technic_constructor_mk"..mark.."_top_on.png",
"technic_constructor_mk"..mark.."_bottom_on.png",
"technic_constructor_mk"..mark.."_side2_on.png",
"technic_constructor_mk"..mark.."_side1_on.png",
"technic_constructor_back.png",
"technic_constructor_front_on.png"},
paramtype2 = "facedir",
drop = "technic:constructor_mk"..mark.."_off",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
mesecon=2, not_in_creative_inventory=1, technic_constructor=1, axey=2, handy=1},
is_ground_content = false,
_mcl_blast_resistance = 1,
_mcl_hardness = 0.8,
mesecons= {effector = {action_off = make_off(mark)}},
sounds = technic.sounds.node_sound_stone_defaults(),
allow_metadata_inventory_put = allow_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
on_metadata_inventory_move = technic.machine_on_inventory_move,
on_metadata_inventory_put = technic.machine_on_inventory_put,
on_metadata_inventory_take = technic.machine_on_inventory_take,
on_rotate = false
})
end
make_constructor(1, 1)
make_constructor(2, 2)
make_constructor(3, 4)

View file

@ -0,0 +1,12 @@
local path = technic.modpath.."/machines/other"
-- Mesecons and tubes related
dofile(path.."/injector.lua")
dofile(path.."/constructor.lua")
-- Coal-powered machines
dofile(path.."/coal_alloy_furnace.lua")
dofile(path.."/coal_furnace.lua")
-- Force-loading
dofile(path.."/anchor.lua")

View file

@ -0,0 +1,180 @@
local S = technic.getter
local fs_helpers = pipeworks.fs_helpers
local tube_entry = "^pipeworks_tube_connection_metallic.png"
local mat = technic.materials
local param2_to_under = {
[0] = {x= 0,y=-1,z= 0}, [1] = {x= 0,y= 0,z=-1},
[2] = {x= 0,y= 0,z= 1}, [3] = {x=-1,y= 0,z= 0},
[4] = {x= 1,y= 0,z= 0}, [5] = {x= 0,y= 1,z= 0}
}
local size = minetest.get_modpath("mcl_formspec") and "size[9,10]" or "size[8,9]"
local base_formspec = size..
"label[0,0;"..S("Self-Contained Injector").."]"..
"list[context;main;0,2;8,2;]"..
"listring[context;main]"
if minetest.get_modpath("mcl_formspec") then
base_formspec = base_formspec..
mcl_formspec.get_itemslot_bg(0,2,8,2)..
-- player inventory
"list[current_player;main;0,5.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,5.5,9,3)..
"list[current_player;main;0,8.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,8.74,9,1)..
"listring[current_player;main]"
else
base_formspec = base_formspec..
"list[current_player;main;0,5;8,4;]"..
"listring[current_player;main]"
end
local function set_injector_formspec(pos)
local meta = minetest.get_meta(pos)
local formspec = base_formspec..
fs_helpers.cycling_button(
meta,
pipeworks.button_base,
"splitstacks",
{
pipeworks.button_off,
pipeworks.button_on
}
)..pipeworks.button_label
if meta:get_string("mode") == "whole stacks" then
formspec = formspec.."button[0,1;4,1;mode_item;"..S("Stackwise").."]"
else
formspec = formspec.."button[0,1;4,1;mode_stack;"..S("Itemwise").."]"
end
if minetest.get_node_timer(pos):is_started() then
formspec = formspec.."button[4,1;4,1;disable;"..S("Enabled").."]"
else
formspec = formspec.."button[4,1;4,1;enable;"..S("Disabled").."]"
end
meta:set_string("formspec", formspec)
end
minetest.register_node("technic:injector", {
description = S("Self-Contained Injector"),
tiles = {
"technic_injector_top.png"..tube_entry,
"technic_injector_bottom.png",
"technic_injector_side.png"..tube_entry,
"technic_injector_side.png"..tube_entry,
"technic_injector_side.png"..tube_entry,
"technic_injector_side.png"
},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice=1, tubedevice_receiver=1, axey=2, handy=1},
is_ground_content = false,
_mcl_blast_resistance = 1,
_mcl_hardness = 0.8,
tube = {
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
if meta:get_int("splitstacks") == 1 then
stack = stack:peek_item(1)
end
return meta:get_inventory():room_for_item("main", stack)
end,
insert_object = function(pos, node, stack, direction)
return minetest.get_meta(pos):get_inventory():add_item("main", stack)
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
},
sounds = technic.sounds.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", S("Self-Contained Injector"))
meta:set_string("mode", "single items")
meta:get_inventory():set_size("main", 16)
minetest.get_node_timer(pos):start(1)
set_injector_formspec(pos)
end,
can_dig = function(pos, player)
return minetest.get_meta(pos):get_inventory():is_empty("main")
end,
on_receive_fields = function(pos, formanme, fields, sender)
if fields.quit or not pipeworks.may_configure(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
if fields.mode_item then
meta:set_string("mode", "single items")
elseif fields.mode_stack then
meta:set_string("mode", "whole stacks")
elseif fields.disable then
minetest.get_node_timer(pos):stop()
elseif fields.enable then
minetest.get_node_timer(pos):start(1)
end
fs_helpers.on_receive_fields(pos, fields)
set_injector_formspec(pos)
end,
on_timer = function(pos, elapsed)
local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
local dir = param2_to_under[math.floor(node.param2 / 4)]
local node_under = minetest.get_node(vector.add(pos, dir))
if minetest.get_item_group(node_under.name, "tubedevice") > 0 then
local inv = meta:get_inventory()
local list = inv:get_list("main")
if not list then
return true
end
local stackwise = meta:get_string("mode") == "whole stacks"
for i,stack in ipairs(list) do
if not stack:is_empty() then
if stackwise then
technic.tube_inject_item(pos, pos, dir, stack:to_table())
stack:clear()
else
technic.tube_inject_item(pos, pos, dir, stack:take_item(1):to_table())
end
inv:set_stack("main", i, stack)
break
end
end
end
return true
end,
on_rotate = function(pos, node, user, mode, new_param2)
node.param2 = new_param2
minetest.swap_node(pos, node)
pipeworks.scan_for_tube_objects(pos)
return true
end,
allow_metadata_inventory_put = technic.machine_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
on_metadata_inventory_move = technic.machine_on_inventory_move,
on_metadata_inventory_put = technic.machine_on_inventory_put,
on_metadata_inventory_take = technic.machine_on_inventory_take,
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig
})
minetest.register_craft({
output = "technic:injector 1",
recipe = {
{"", "technic:control_logic_unit",""},
{"", mat.chest,""},
{"", "pipeworks:tube_1",""},
}
})
minetest.register_lbm({
label = "Old injector conversion",
name = "technic:old_injector_conversion",
nodenames = {"technic:injector"},
run_at_every_load = false,
action = function(pos, node)
minetest.get_node_timer(pos):start(1)
set_injector_formspec(pos)
end
})