Tip on Lua controlled Tube (use for sorting)

When playing minetest, I like to have an automatic sorter:
I've seen similar setups by other players. However, most of the other players just used the "Sorting Pneumatic Tube Segment". I use them, too. But I also use "Lua controlled Tube". And here is how:
The tubes are event driven, so I need to react to events. Here is an example of my first Lua controlled tube after my incoming chest:
The Lua controlled tubes have colored connections, and you simply return the color of where you want the specific item to end up.
The second Lua controlled tube is done like this:
Here you already see the use of
Substrings can also be used to have chests that get items from a whole mod. With normal pneumatic sorter tubes this is almost impossible, they only can select by 6 items. But to check if an item is from a mod is a single instruction in Lua:
- * I put all my mined thing into a chest
* a stackwise Filter-Injector pulls them out, powered by a blinky plant
* then things go into a sorter network
* exits are of course grinder, furnace, centrifuge, battery box (to recharge), workshop
* and of course lots of chests
I've seen similar setups by other players. However, most of the other players just used the "Sorting Pneumatic Tube Segment". I use them, too. But I also use "Lua controlled Tube". And here is how:
The tubes are event driven, so I need to react to events. Here is an example of my first Lua controlled tube after my incoming chest:
- Code: Select all
if event.type == "item" then
local s = event.item.name
-- grinder
if s == "default:copper_lump" or
s == "default:gold_lump" or
s == "default:iron_lump" or
s == "forge:slag" or
s == "moreores:mithril_lump" or
s == "moreores:silver_lump" or
s == "moreores:tin_lump" or
s == "technic:chromium_lump" or
s == "technic:uranium_lump" or
s == "technic:zinc_lump" or
s == "technic_aluminum:alumina_lump" then
return "green"
end
-- furnace
if s == "forge:slag" or
s == "mobs:rotten_flesh" or
s == "technic:chromium_dust" or
s == "technic:copper_dust" or
s == "technic:gold_dust" or
s == "technic:mithril_dust" or
s == "technic:silver_dust" or
s == "technic:tin_dust" or
s == "technic:wrought_iron_dust" or
s == "technic:zinc_dust" or
s == "technic_aluminum:aluminum_dust" or
s == "technic_aluminum:bauxite_lump" then
return "black"
end
-- small centrifuge
if s == "technic_aluminum:alumina_dust" then
return "yellow"
end
return "red"
end
The Lua controlled tubes have colored connections, and you simply return the color of where you want the specific item to end up.
The second Lua controlled tube is done like this:
- Code: Select all
if event.type == "item" then
local s = event.item.name
-- workshop
if s == "bones:bone_scythe" or
s == "cottages:hammer" or
s == "default:axe_diamond" or
s == "default:axe_mese" or
s == "default:pick_diamond" or
s == "default:pick_mese" or
s == "default:axe_diamond" or
s == "default:axe_mese" or
s == "default:hoe_diamond" or
s == "default:hoe_mese" or
s == "default:shovel_diamond" or
s == "default:shovel_mese" or
s == "default:sword_diamond" or
s == "default:sword_mese" or
s == "technic:treetap" or
s == "technic_aluminum:sword_aluminum" or
s == "screwdriver:screwdriver" or
s:sub(1,8) == "3d_armor" or
s:sub(1,6) == "shield" or
s:sub(1,9) == "stairpick" then
return "black"
end
-- charger
if s == "technic:chainsaw" or
s == "technic:prospector" or
s == "technic:sonic_screwdriver" or
s == "teletool:teletool_technic" or
s:sub(1,13) == "technic:laser" or
s:sub(1,20) == "technic:mining_drill" then
return "yellow"
end
-- go-box
if s == "bridgetool:bridge_tool" or
s == "carts:cart" or
s == "default:torch" or
s == "default:ladder_wood" or
s == "farming:corn" or
s == "landrush:landclaim" or
s == "more_chests:wifi" or
s == "protector:protect" or
s == "travelnet:elevator" or
s:sub(1,11) == "bridgetool:" then
return "white"
end
--- sort1
return "red"
end
Here you already see the use of
- Code: Select all
s:sub(start,end)
Substrings can also be used to have chests that get items from a whole mod. With normal pneumatic sorter tubes this is almost impossible, they only can select by 6 items. But to check if an item is from a mod is a single instruction in Lua:
- Code: Select all
if event.type == "item" then
local s = event.item.name
if s:sub(1,7) == "technic" then
return "black"
end
return "red"
end