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

@ -1,15 +1,15 @@
return {
{
name = "water",
amount = 32900,
amount = 32700,
},
{
name = "blood",
amount = 150,
amount = 50,
},
{
name = "still_milk",
amount = 2000,
amount = 1000,
},
{
name = "lava",
@ -25,7 +25,7 @@ return {
},
{
name = "molten_rose_gold",
amount = 0.44444444444446,
amount = 0,
},
{
amount = 0,

View file

@ -120,7 +120,6 @@ function connectTankOrAssign(fluid)
_G.fluidTanks[index] = {
name = fluid,
amount = 0,
connected = false
}
print("assigned tank", index, "to", fluid)
break

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,
}

View file

@ -11,6 +11,7 @@ function read_recipe(file)
yield = 1
while 1 do
line = file.readLine()
if not line then return nil end
if string.sub(line, 1, 5) == "base " then
base = string.sub(line, 6)
elseif string.sub(line, 1, 13) == "intermediate " then

View file

@ -112,6 +112,10 @@ yield 3
steps:
craft andesite_alloy bronze_sheet
large_cogwheel
steps:
craft cogwheel bronze_sheet cogwheel
flint_knife
steps:
craft flint nil nil stick
@ -231,6 +235,10 @@ molten_rose_gold
steps:
alloy molten_copper molten_gold
rose_gold_ingot
steps:
cast_ingot molten_rose_gold
molten_copper
yield 111
base copper_ingot
@ -366,3 +374,66 @@ salmon
yield 0.25
steps:
compact wet_sponge
milk_jar
steps:
craft glass birch_planks glass glass milk_bucket glass glass glass glass
milk_bucket
base bucket
steps:
spout still_milk:1000
bucket
steps:
craft iron_ingot nil iron_ingot nil iron_ingot
molten_bronze
yield 888
steps:
mix copper_nugget:36 tin_nugget:36
bronze_ingot
steps:
cast_ingot molten_bronze
copper_nugget
yield 9
steps:
craft copper_ingot
tin_nugget
yield 9
steps:
craft tin_ingot
iron_wire
yield 2
steps:
rolling_mill iron_sheet
redstone_chip
base electron_tube
intermediate incomplete_redstone_chip
repeat 12
steps:
spout molten_copper:41
deploy iron_wire
press
smart_chute
steps:
craft filter golden_sheet nil comparator observer nil chute chute
chute
yield 4
steps:
craft iron_sheet nil nil iron_ingot nil nil iron_sheet
stone_growth_chamber
steps:
craft copper_casing copper_casing copper_casing copper_sheet water_bucket copper_sheet copper_casing copper_casing copper_casing
cobblestone
steps:
growth_chamber

View file

@ -1,7 +1,5 @@
term.clear()
term.setCursorPos(1,1)
parallel.waitForAny(
function()
shell.run("shell")

View file

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