This commit is contained in:
Crispy 2025-05-26 02:36:15 +02:00
parent fe086e3a0c
commit 1ff3cea4d6
29 changed files with 3206 additions and 79 deletions

View file

@ -23,7 +23,7 @@ function spout(extra_items)
goTo(spout_pos, "south")
insertDepot(1)
selectFluidDevice("spout")
connectTanks({fluid.name})
connectTank(fluid.name)
pumpToDevices(true)
sleep(10)
pumpToDevices(false)
@ -32,7 +32,9 @@ function spout(extra_items)
fluidInvAdd(fluid.name, -fluid.count)
pumpToTanks(true)
goTo(spout_pos, "south")
while #pFront("tanks")[1].amount > 0 do
goUp()
goUp()
while pFront("tanks")[1].amount > 0 do
sleep(0.5)
end
pumpToTanks(false)
@ -83,7 +85,7 @@ function deploy_tool(extra_items)
insertDepot(1)
goUp()
goUp()
selectItem(extra_items[1].name)
selectItem(extra_items[1].name, true)
turtle.dropUp(1)
pFront("pullItem", "top")
@ -101,16 +103,19 @@ function furnace(extra_items)
if turtle.getItemCount() ~= 0 then
item_count = 1
end
insertForward(1, 1)
turtle.dropUp(1)
pFront("pullItems", "top", 1, 64, 1)
for _,item in pairs(extra_items) do
item_count = item_count + item.count
selectItem(item.name)
insertForward(1, item.count)
turtle.dropUp(item.count)
pFront("pullItems", "top", 1, 64, 1)
end
wait_time = 10 * item_count
-- TODO refuel
sleep(wait_time)
takeForward(3)
pFront("pushItems", "top", 3)
turtle.suckUp()
end
function press(_)
goTo(press_pos, "south")
@ -124,7 +129,7 @@ function compact(extra_items)
end
function make_water(_,_,yield)
selectFluidDevice("water_source")
connectTanks({"water"})
connectTank("water")
pumpToTanks(true)
print("waiting 30s for water tanks to fill")
sleep(30)
@ -138,9 +143,36 @@ function alloy(parts, product)
end
end
selectFluidDevice("mixer")
connectTanks(parts)
pumpToDevices(true)
for _, fluid in pairs(parts) do
connectTank(fluid.name)
pumpToDevices(true)
goTo(mixer_pos, "south")
-- TODO wait for 1B or tank content is in the mixer
sleep(5)
pumpToDevices(false)
end
goTo(mixer_pos, "south")
-- TODO wait for alloy to be done
sleep(10)
created_amount = 0
for _, fluid in pairs(pFront("tanks")) do
if fluid.amount > 0 then
connectTankOrAssign(stripModname(fluid.name))
pumpToTanks(true)
sleep(10)
pumpToTanks(false)
if stripModname(fluid.name) == product then
fluidInvAdd(product, fluid.amount)
created_amount = fluid.amount
end
end
end
for _, fluid in pairs(parts) do
fluidInvAdd(fluid.name, -created_amount)
end
-- for _, fluid in pairs(parts) do
-- end
-- TODO
--[[
wait until at least one input fluid is used up
@ -150,7 +182,6 @@ function alloy(parts, product)
-- while true do
-- end
pumpToDevices(false)
end
function melt(_, product, yield)
goTo(melter_pos, "north")
@ -178,13 +209,14 @@ function mix(extra_items, product, yield)
if #fluids > 0 then
print("mixing with fluids", fluids[1])
selectFluidDevice("mixer")
connectTanks({fluids[1].name})
connectTank(fluids[1].name)
pumpToDevices(true)
sleep(10)
sleep(8)
pumpToDevices(false)
end
-- print("aaa")
-- read()
if isFluid[product] then
selectFluidDevice("mixer")
end
-- mix
goTo(mixer_pos, "south")
insertForward(1, 1)
@ -192,14 +224,45 @@ function mix(extra_items, product, yield)
selectItem(item.name)
insertForward(nil, item.count)
end
goUp()
goUp()
goDown()
goDown()
sleep(10)
-- todo wait until ingredients are gone
takeForward(10)
-- todo empty fluids
-- todo update the mixer somehow?
-- wait until ingredients are gone
repeat
sleep(1)
contents = pFront("list")
inputs_remaining = false
for i = 1,9 do
if contents[i] then
inputs_remaining = true
break
end
end
until not inputs_remaining
if product == "still_milk" then
repeat
is_done = false
for _,t in pairs(pFront("tanks")) do
if stripModname(t.name) == "still_milk" then
is_done = t.amount >= yield
break
end
end
until is_done
end
for i = 10, 18 do
takeForward(i)
end
-- empty fluids
tanks = pFront("tanks")
for _,tank in pairs(tanks) do
if tank.amount > 0 then
connectTankOrAssign(stripModname(tank.name))
pumpToTanks(true)
sleep(8)
pumpToTanks(false)
end
end
fluidInvAdd(product, yield)
end
function craft(extra_items)
local slot = 0