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

@ -1,40 +1,36 @@
return {
{
connected = false,
name = "water",
amount = 13100,
},
{
connected = false,
name = "blood",
amount = 100,
},
{
connected = false,
name = "still_milk",
amount = 1000,
},
{
name = "lava",
amount = 1325,
},
{
name = "molten_copper",
amount = 0,
},
{
connected = false,
name = "molten_gold",
amount = 0,
},
{
connected = false,
name = "molten_rose_gold",
amount = 0.44444444444446,
},
{
amount = 0,
},
{
connected = false,
amount = 0,
},
{
connected = false,
amount = 0,
},
{
connected = false,
amount = 0,
},
{
connected = false,
amount = 0,
},
}

View file

@ -1,11 +1,11 @@
require("pathfinding")
pretty = require("cc.pretty")
pp = pretty.pretty_print()
pp = pretty.pretty_print
isFluid = {
water = true,
lava = true,
milk = true,
still_milk = true,
blood = true,
molten_rose_gold = true,
molten_copper = true,
@ -17,7 +17,7 @@ isFluid = {
}
fluidDevicePos = {
trash = vector.new(2, 0, -1),
trash = vector.new(1, 0, -1),
water_source = vector.new(0, 0, -1),
mixer = vector.new(-1, 0, -1),
compactor = vector.new(-2, 0, -1),
@ -84,18 +84,10 @@ function resetAllFluidDevices()
-- goTo(pos)
-- setRedRouter(false)
-- end
for x = 2, -4, -1 do
goTo(vector.new(x, 0, -1))
setRedRouter(false)
end
for x = -4, 4 do
goTo(vector.new(x, 0, -3))
setRedRouter(false)
end
_G.activeFluidDevice = nil
for i = 1, 9 do
_G.fluidTanks[i].connected = false
end
-- for x = 2, -4, -1 do
-- goTo(vector.new(x, 0, -1))
-- setRedRouter(false)
-- end
end
function selectFluidDevice(name)
@ -103,14 +95,14 @@ function selectFluidDevice(name)
error("selectFluidDevice(" .. name .. "); not a known fluid device", 2)
end
if _G.activeFluidDevice ~= nil then
goTo(fluidDevicePos[_G.activeFluidDevice])
_G.activeFluidDevice = nil
setRedRouter(false)
if _G.activeFluidDevice ~= name then
print("set active fluid device", name)
_G.activeFluidDevice = name
goTo(fluidDevicePos[name])
redstone.setOutput("bottom", true)
sleep(0.1)
redstone.setOutput("bottom", false)
end
goTo(fluidDevicePos[name])
setRedRouter(true)
_G.activeFluidDevice = name
end
function connectTankOrAssign(fluid)
@ -135,27 +127,27 @@ function connectTankOrAssign(fluid)
end
end
end
connectTanks({ fluid })
connectTank(fluid)
end
function connectTanks(fluid_list)
print("connecting tanks")
pp(fluid_list)
function connectTank(name)
-- TODO only single tank, otherwise pipes break
for index, tank in pairs(_G.fluidTanks) do
should_be_connected = false
for _, fluid in pairs(fluid_list) do
if tank.name == fluid then
should_be_connected = true
break
if tank.name == name then
if index == _G.connectTank then
print("tank", name, index, "already connected")
return
end
end
if should_be_connected ~= tank.connected then
print("setting", tank.name, index, "to", should_be_connected)
goTo(tankPos[index])
setRedRouter(should_be_connected)
_G.fluidTanks[index].connected = should_be_connected
redstone.setOutput("bottom", true)
sleep(0.1)
redstone.setOutput("bottom", false)
_G.connectedTank = index
print("tank", name, index, "already connected")
return
end
end
saveFluids()
end
function fluidInvAdd(name, amount)
@ -163,6 +155,9 @@ function fluidInvAdd(name, amount)
for index, tank in pairs(_G.fluidTanks) do
if tank.name == name then
tank.amount = tank.amount + amount
if tank.amount < 1 then
tank.amount = 0
end
-- TODO limit capacity
end
end

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

View file

@ -122,9 +122,9 @@ steps:
deploy_tool flint_knife
gravel
base cobblestone
yield 8
steps:
mill
mill cobblestone:8
fluid_valve
steps:
@ -140,6 +140,11 @@ yield 8
steps:
craft black_dye sand sand sand sand gravel gravel gravel gravel
red_concrete_powder
yield 64
steps:
craft red_dye:8 sand:8 sand:8 sand:8 sand:8 gravel:8 gravel:8 gravel:8 gravel:8
rose_quartz_lamp
steps:
craft polished_rose_quartz redstone zinc_ingot
@ -177,6 +182,15 @@ computer_normal
steps:
craft andesite_alloy andesite_alloy andesite_alloy andesite_alloy polished_rose_quartz andesite_alloy andesite_alloy glass_pane andesite_alloy
turtle_normal
steps:
craft iron_ingot iron_ingot iron_ingot iron_ingot computer_normal iron_ingot iron_ingot chest iron_ingot
chest
yield 4
steps:
craft birch_log birch_log birch_log birch_log nil birch_log birch_log birch_log birch_log
glass_pane
yield 16
steps:
@ -271,3 +285,32 @@ water
yield 20000
steps:
make_water
lava
yield 125
steps:
mix andesite_dust cobblestone lava:50
andesite_dust
yield 2
steps:
craft gravel
still_milk
yield 1000
steps:
mix cow_jar
grout
yield 8
steps:
mix andesite_alloy zinc_ingot gravel:8
cable
yield 6
steps:
craft nil andesite_alloy nil andesite_alloy polished_rose_quartz andesite_alloy nil andesite_alloy
spout
steps:
craft copper_casing nil nil dried_kelp

View file

@ -10,7 +10,7 @@ keep_stocked = {
flint = 10
}
resetAllFluidDevices()
-- resetAllFluidDevices()
goHome()
print("known recipes:\n")