Simple importer
This commit is contained in:
parent
98833290b3
commit
cd2e72c307
@ -15,6 +15,9 @@ dofile(storagetest.modpath.."/nodes/disk_drive.lua")
|
|||||||
-- Grids
|
-- Grids
|
||||||
dofile(storagetest.modpath.."/nodes/grid.lua")
|
dofile(storagetest.modpath.."/nodes/grid.lua")
|
||||||
|
|
||||||
|
-- Buses
|
||||||
|
dofile(storagetest.modpath.."/nodes/bus.lua")
|
||||||
|
|
||||||
-- Start the network
|
-- Start the network
|
||||||
storagetest.network.register_abm_controller("storagetest:controller_active")
|
storagetest.network.register_abm_controller("storagetest:controller_active")
|
||||||
storagetest.network.register_abm_nodes()
|
storagetest.network.register_abm_nodes()
|
||||||
|
52
nodes/bus.lua
Normal file
52
nodes/bus.lua
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
-- Storagetest cabling
|
||||||
|
|
||||||
|
minetest.register_node("storagetest:import_bus", {
|
||||||
|
description = "Import Bus",
|
||||||
|
tiles = {
|
||||||
|
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png",
|
||||||
|
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_import.png",
|
||||||
|
},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {
|
||||||
|
storagetest_distributor = 1,
|
||||||
|
storagetest_device = 1,
|
||||||
|
cracky = 2,
|
||||||
|
oddly_breakable_by_hand = 2
|
||||||
|
},
|
||||||
|
on_construct = function (pos)
|
||||||
|
storagetest.network.clear_networks(pos)
|
||||||
|
end,
|
||||||
|
on_destruct = storagetest.network.clear_networks,
|
||||||
|
storagetest_run = function (pos, _, controller)
|
||||||
|
local network = minetest.hash_node_position(controller)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local front = storagetest.front(pos, node.param2)
|
||||||
|
|
||||||
|
local front_node = minetest.get_node(front)
|
||||||
|
if front_node.name ~= "air" then
|
||||||
|
local front_meta = minetest.get_meta(front)
|
||||||
|
local front_inv = front_meta:get_inventory()
|
||||||
|
local front_def = minetest.registered_nodes[front_node.name]
|
||||||
|
if front_inv:get_list("main") then
|
||||||
|
local list = front_inv:get_list("main")
|
||||||
|
for index, stack in pairs(list) do
|
||||||
|
if not stack:is_empty() then
|
||||||
|
local allow_count = 0
|
||||||
|
local copystack = front_inv:get_stack("main", index)
|
||||||
|
copystack:set_count(1)
|
||||||
|
local success, outst = storagetest.network.insert_item(network, copystack)
|
||||||
|
if success then
|
||||||
|
stack:set_count(stack:get_count() - 1)
|
||||||
|
front_inv:set_stack("main", index, stack)
|
||||||
|
break -- Don't take more than one per cycle
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
front_inv:set_list("main", list)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
storagetest.devices["storagetest:import_bus"] = true
|
@ -28,3 +28,11 @@ function storagetest.helpers.grid_refresh(pos, n, controller)
|
|||||||
storagetest.helpers.swap_node(pos, node)
|
storagetest.helpers.swap_node(pos, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function storagetest.front(pos, fd)
|
||||||
|
local front = minetest.facedir_to_dir(fd)
|
||||||
|
front.x = front.x * -1 + pos.x
|
||||||
|
front.y = front.y * -1 + pos.y
|
||||||
|
front.z = front.z * -1 + pos.z
|
||||||
|
return front
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user