fluid things
This commit is contained in:
parent
7694798ad0
commit
ad6af0fa35
21 changed files with 608 additions and 183 deletions
|
@ -1,9 +1,13 @@
|
|||
require("inventory")
|
||||
require("pathfinding")
|
||||
require("fluids")
|
||||
sfx = require("sfx")
|
||||
|
||||
press_pos = vector.new(1,0,0)
|
||||
deployer_pos = vector.new(2,0,0)
|
||||
furnace_pos = vector.new(3,0,0)
|
||||
furnace_pos = vector.new(4,2,0)
|
||||
saw_pos = vector.new(3,1,0)
|
||||
saw_out_pos = vector.new(2,0,0)
|
||||
mill_pos = vector.new(4,0,0)
|
||||
mixer_pos = vector.new(-1,0,0)
|
||||
compactor_pos = vector.new(-2,0,0)
|
||||
|
@ -11,11 +15,34 @@ spout_pos = vector.new(-3,0,0)
|
|||
melter_pos = vector.new(-4,1,-3)
|
||||
casting_table_pos = vector.new(-3,0,-3)
|
||||
|
||||
-- fluid_tanks = {
|
||||
-- water = vector.new(0,0,-1),
|
||||
-- lava = vector.new(0,0,-1)
|
||||
-- }
|
||||
|
||||
function spout(extra_items)
|
||||
local fluid = extra_items[1]
|
||||
if not fluid then
|
||||
error("no fluid specified")
|
||||
end
|
||||
goTo(spout_pos, "south")
|
||||
insertDepot(1)
|
||||
selectFluidDevice("spout")
|
||||
connectTanks({fluid.name})
|
||||
pumpToDevices(true)
|
||||
sleep(10)
|
||||
pumpToDevices(false)
|
||||
goTo(spout_pos, "south")
|
||||
takeDepot()
|
||||
fluidInvAdd(fluid.name, -fluid.count)
|
||||
pumpToTanks(true)
|
||||
goTo(spout_pos, "south")
|
||||
while #pFront("tanks")[1].amount > 0 do
|
||||
sleep(0.5)
|
||||
end
|
||||
pumpToTanks(false)
|
||||
end
|
||||
function saw(_)
|
||||
goTo(saw_pos, "south")
|
||||
turtle.drop()
|
||||
goTo(saw_out_pos, "south")
|
||||
takeDepot()
|
||||
end
|
||||
function mill(extra_items)
|
||||
goTo(mill_pos,"south")
|
||||
item_count = 0
|
||||
|
@ -36,13 +63,13 @@ function mill(extra_items)
|
|||
takeForward(i)
|
||||
end
|
||||
end
|
||||
function deploy(extra_items, nbt)
|
||||
function deploy(extra_items)
|
||||
-- extra_items should only be one item
|
||||
goTo(deployer_pos, "south")
|
||||
insertDepot(1)
|
||||
goUp()
|
||||
goUp()
|
||||
selectItem(extra_items[1].name, nbt)
|
||||
selectItem(extra_items[1].name)
|
||||
turtle.dropUp(1)
|
||||
pFront("pullItem", "top")
|
||||
|
||||
|
@ -51,7 +78,18 @@ function deploy(extra_items, nbt)
|
|||
takeDepot()
|
||||
end
|
||||
function deploy_tool(extra_items)
|
||||
deploy(extra_items, true)
|
||||
-- extra_items should only be one item
|
||||
goTo(deployer_pos, "south")
|
||||
insertDepot(1)
|
||||
goUp()
|
||||
goUp()
|
||||
selectItem(extra_items[1].name)
|
||||
turtle.dropUp(1)
|
||||
pFront("pullItem", "top")
|
||||
|
||||
goDown()
|
||||
goDown()
|
||||
takeDepot()
|
||||
goUp()
|
||||
goUp()
|
||||
pFront("pushItem", "top")
|
||||
|
@ -82,9 +120,63 @@ function press(_)
|
|||
end
|
||||
function compact(extra_items)
|
||||
printError("unimplemented :3")
|
||||
fail()
|
||||
sfx.fail()
|
||||
end
|
||||
function mix(extra_items)
|
||||
function alloy(parts, product)
|
||||
for _, item in pairs(parts) do
|
||||
if not isFluid[item.name] then
|
||||
error(item.name .. " is not a known fluid, but was used in alloy")
|
||||
end
|
||||
end
|
||||
selectFluidDevice("mixer")
|
||||
connectTanks(parts)
|
||||
pumpToDevices(true)
|
||||
goTo(mixer_pos, "south")
|
||||
-- TODO
|
||||
--[[
|
||||
wait until at least one input fluid is used up
|
||||
if two remain, it needs to keep track of which tank gets what when draining
|
||||
]]
|
||||
|
||||
-- while true do
|
||||
|
||||
-- end
|
||||
pumpToDevices(false)
|
||||
end
|
||||
function melt(_, product, yield)
|
||||
goTo(melter_pos, "north")
|
||||
goUp()
|
||||
turtle.drop()
|
||||
selectFluidDevice("melter")
|
||||
connectTankOrAssign(product)
|
||||
pumpToTanks(true)
|
||||
goTo(melter_pos, "north")
|
||||
while #pFront("items") > 0 do
|
||||
sleep(1)
|
||||
end
|
||||
pumpToTanks(false)
|
||||
fluidInvAdd(product, yield)
|
||||
end
|
||||
function mix(extra_items, product, yield)
|
||||
-- prepare fluids
|
||||
local fluids = {}
|
||||
for index, item in pairs(extra_items) do
|
||||
if isFluid[item.name] then
|
||||
table.insert(fluids, item)
|
||||
extra_items[index] = nil
|
||||
end
|
||||
end
|
||||
if #fluids > 0 then
|
||||
print("mixing with fluids", fluids[1])
|
||||
selectFluidDevice("mixer")
|
||||
connectTanks({fluids[1].name})
|
||||
pumpToDevices(true)
|
||||
sleep(10)
|
||||
pumpToDevices(false)
|
||||
end
|
||||
-- print("aaa")
|
||||
-- read()
|
||||
-- mix
|
||||
goTo(mixer_pos, "south")
|
||||
insertForward(1, 1)
|
||||
for _, item in pairs(extra_items) do
|
||||
|
@ -98,6 +190,7 @@ function mix(extra_items)
|
|||
sleep(10)
|
||||
-- todo wait until ingredients are gone
|
||||
takeForward(10)
|
||||
-- todo empty fluids
|
||||
end
|
||||
function craft(extra_items)
|
||||
local slot = 0
|
||||
|
@ -124,5 +217,9 @@ return {
|
|||
press = press,
|
||||
compact = compact,
|
||||
mix = mix,
|
||||
craft = craft
|
||||
craft = craft,
|
||||
alloy = alloy,
|
||||
melt = melt,
|
||||
saw = saw,
|
||||
spout = spout,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue