This commit is contained in:
Crispy 2025-05-28 02:37:55 +02:00
parent 5422d52065
commit 4f2631b349
24 changed files with 414 additions and 5665 deletions

View file

@ -3,18 +3,19 @@ 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(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)
spout_pos = vector.new(-3,0,0)
melter_pos = vector.new(-4,1,-3)
casting_table_pos = vector.new(-3,0,-3)
washer_pos = vector.new(3,0,-4)
press_pos = vector.new(1, 0, 0)
deployer_pos = vector.new(2, 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)
spout_pos = vector.new(-3, 0, 0)
melter_pos = vector.new(-4, 1, -3)
casting_pos = vector.new(-2, 1, -4)
washer_pos = vector.new(3, 0, -4)
growth_chamber_pos = vector.new(-3, 2, 0)
function spout(extra_items)
local fluid = extra_items[1]
@ -40,25 +41,27 @@ function spout(extra_items)
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")
goTo(mill_pos, "south")
item_count = 0
if turtle.getItemCount() ~= 0 then
item_count = 1
end
insertForward(1, 1)
for _,item in pairs(extra_items) do
for _, item in pairs(extra_items) do
item_count = item_count + item.count
selectItem(item.name)
insertForward(1, item.count)
end
print(item_count,"items")
print(item_count, "items")
while pFront("getItemDetail", 1) do
sleep(0.1)
end
@ -66,6 +69,7 @@ function mill(extra_items)
takeForward(i)
end
end
function deploy(extra_items)
-- extra_items should only be one item
goTo(deployer_pos, "south")
@ -80,6 +84,7 @@ function deploy(extra_items)
goDown()
takeDepot()
end
function deploy_tool(extra_items)
-- extra_items should only be one item
goTo(deployer_pos, "south")
@ -98,6 +103,7 @@ function deploy_tool(extra_items)
pFront("pushItem", "top")
turtle.suckUp()
end
function furnace(extra_items)
goTo(furnace_pos, "south")
item_count = 0
@ -106,7 +112,7 @@ function furnace(extra_items)
end
turtle.dropUp(1)
pFront("pullItems", "top", 1, 64, 1)
for _,item in pairs(extra_items) do
for _, item in pairs(extra_items) do
item_count = item_count + item.count
selectItem(item.name)
turtle.dropUp(item.count)
@ -118,19 +124,22 @@ function furnace(extra_items)
pFront("pushItems", "top", 3)
turtle.suckUp()
end
function press(_)
goTo(press_pos, "south")
insertDepot(1)
sleep(1)
takeDepot()
end
function compact(extra_items, product, yield)
silly_temp = mixer_pos
mixer_pos = compactor_pos
mix(extra_items, product, yield)
mixer_pos = silly_temp
end
function make_water(_,_,yield)
function make_water(_, _, yield)
selectFluidDevice("water_source")
connectTank("water")
pumpToTanks(true)
@ -139,6 +148,7 @@ function make_water(_,_,yield)
pumpToTanks(false)
fluidInvAdd("water", yield)
end
function alloy(parts, product)
for _, item in pairs(parts) do
if not isFluid[item.name] then
@ -174,6 +184,7 @@ function alloy(parts, product)
fluidInvAdd(fluid.name, -created_amount)
end
end
function melt(_, product, yield)
goTo(melter_pos, "north")
goUp()
@ -188,6 +199,7 @@ function melt(_, product, yield)
pumpToTanks(false)
fluidInvAdd(product, yield)
end
function mix(extra_items, product, yield)
-- prepare fluids
local fluids = {}
@ -221,7 +233,7 @@ function mix(extra_items, product, yield)
sleep(1)
contents = pFront("list")
inputs_remaining = false
for i = 1,9 do
for i = 1, 9 do
if contents[i] then
inputs_remaining = true
break
@ -231,7 +243,7 @@ function mix(extra_items, product, yield)
if product == "still_milk" then
repeat
is_done = false
for _,t in pairs(pFront("tanks")) do
for _, t in pairs(pFront("tanks")) do
if stripModname(t.name) == "still_milk" then
is_done = t.amount >= yield
break
@ -245,7 +257,7 @@ function mix(extra_items, product, yield)
end
-- empty fluids
tanks = pFront("tanks")
for _,tank in pairs(tanks) do
for _, tank in pairs(tanks) do
if tank.amount > 0 then
connectTankOrAssign(stripModname(tank.name))
pumpToTanks(true)
@ -255,6 +267,7 @@ function mix(extra_items, product, yield)
end
fluidInvAdd(product, yield)
end
function craft(extra_items)
local slot = 0
for _, item in pairs(extra_items) do
@ -277,7 +290,7 @@ function wash(_, product)
insertDepot(1)
repeat
is_done = false
for _,item in pairs(pFront("items")) do
for _, item in pairs(pFront("items")) do
if stripModname(item.name) == product then
is_done = true
end
@ -286,6 +299,57 @@ function wash(_, product)
takeDepot()
end
function growth_chamber()
goTo(growth_chamber_pos, "west")
pTop("pushItem", "front")
turtle.suck()
end
function cast_ingot(source, product, yield)
fluid = source[1]
if not isFluid[fluid.name] then
error(fluid .. " is not a fluid")
end
connectTank(fluid)
selectFluidDevice("melter")
pumpToDevices(true)
goTo(melter_pos, "north")
repeat
melter_tank = pFront("tanks")[1]
local storage_emptied = melter_tank.amount >= getFluidAmount(fluid.name)
local melter_full = melter_tank.amount >= melter_tank.capacity
done_filling = storage_emptied or melter_full
until done_filling
pumpToDevices(false)
local fluid_in_melter = melter_tank.amount
local ingot_count = math.floor(fluid_in_melter / 111)
local leftover = fluid_in_melter - ingot_count * 111.11
print("expecting", ingot_count, "ingots")
goTo(casting_pos, "west")
for i = 1, ingot_count do
redstone.setOutput("front", true)
sleep(0.1)
redstone.setOutput("front", false)
goDown()
repeat
sleep(0.1)
until pFront("getItemDetail", 2)
takeForward(2)
goUp()
end
if leftover > 1 then
pumpToTanks(true)
sleep(5)
pumpToTanks(false)
end
fluidInvAdd(fluid.name, -(ingot_count * 111))
end
function rolling_mill()
print("unimplemented :3")
end
return {
mill = mill,
deploy = deploy,
@ -301,4 +365,7 @@ return {
spout = spout,
make_water = make_water,
wash = wash,
}
cast_ingot = cast_ingot,
rolling_mill = rolling_mill,
growth_chamber = growth_chamber,
}