This commit is contained in:
Crispy 2025-06-22 00:08:46 +02:00
parent f8fd2513c8
commit 491112768c
27 changed files with 1095 additions and 3537 deletions

File diff suppressed because it is too large Load diff

4
computer/11/.settings Normal file
View file

@ -0,0 +1,4 @@
{
[ "motd.enable" ] = false,
[ "motd.path" ] = "/rom/motd.txt:/motd.txt:/rom/cccbridge_motd.txt",
}

1
computer/11/oilrig.txt Normal file
View file

@ -0,0 +1 @@
9

23
computer/11/square.lua Normal file
View file

@ -0,0 +1,23 @@
turtle.forward()
right = true
function turn()
if right then
turtle.turnRight()
else
turtle.turnLeft()
end
end
for row = 1, 5 do
for block = 1, 16 do
turtle.placeDown()
turtle.forward()
end
turn()
turtle.forward()
turn()
turtle.forward()
right = not right
end

View file

@ -1,26 +1,26 @@
return {
{
name = "water",
amount = 25900,
amount = 1409400,
},
{
name = "blood",
amount = 50,
amount = 4050,
},
{
name = "molten_brass",
amount = 42,
amount = 2991,
},
{
name = "lava",
amount = 1450,
amount = 162000,
},
{
name = "molten_silver",
amount = 55.555,
amount = 31500,
},
{
name = "still_milk",
name = "molten_copper",
amount = 0,
},
{
@ -29,7 +29,7 @@ return {
},
{
name = "molten_rose_gold",
amount = 0,
amount = 9000,
},
{
amount = 0,

View file

@ -2,6 +2,8 @@ require("pathfinding")
pretty = require("cc.pretty")
pp = pretty.pretty_print
tankCapacity = 2 * 10 * 81000
isFluid = {
water = true,
lava = true,
@ -70,7 +72,7 @@ end
function getFluidAmountInTanks(type, tanks)
for _, fluid in pairs(tanks) do
if stripModname(fluid.name) == type then
return fluid.amount
return mb2droplet(fluid.amount)
end
end
return 0
@ -91,14 +93,6 @@ end
function resetAllFluidDevices()
pumpToDevices(false)
pumpToTanks(false)
-- for name, pos in pairs(fluidDevicePos) do
-- goTo(pos)
-- setRedRouter(false)
-- end
-- for x = 2, -4, -1 do
-- goTo(vector.new(x, 0, -1))
-- setRedRouter(false)
-- end
end
function selectFluidDevice(name)
@ -159,14 +153,20 @@ function connectTank(name)
end
function fluidInvAdd(name, amount)
print("added", amount, "to", name)
print("added", droplet2string(amount), "to", name)
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
if tank.amount > tankCapacity then
tank.amount = tankCapacity
if name ~= "water" then
error("Warning: tank capacity for " ..
name .. "(tank " .. index .. ") exceeded by " .. droplet2string(tank.amount - tankCapacity))
end
end
end
end
saveFluids()

View file

@ -114,3 +114,13 @@ function takeDepot()
turtle.suckDown()
end
function emptyInventory()
for i = 1, 16 do
if turtle.getItemCount(i) ~= 0 then
turtle.select(i)
chest_items = pFront("items")
turtle.drop()
end
end
end

View file

@ -162,8 +162,8 @@ function alloy(parts, product)
pumpToDevices(true)
goTo(mixer_pos, "south")
-- wait for 1B or tank content is in the mixer
expected_amount = math.min(getFluidAmount(fluid.name), 1000)
print("waiting for", expected_amount, fluid.name, "in mixer")
expected_amount = math.min(getFluidAmount(fluid.name), 81000)
print("waiting for", droplet2string(expected_amount), fluid.name, "in mixer")
while getFluidAmountInTanks(fluid.name, pFront("tanks")) < expected_amount do
sleep(0.1)
end
@ -191,13 +191,13 @@ function alloy(parts, product)
end
pumpToTanks(false)
if stripModname(fluid.name) == product then
fluidInvAdd(product, fluid.amount)
fluidInvAdd(product, mb2droplet(fluid.amount))
created_amount = fluid.amount
end
end
end
for _, fluid in pairs(parts) do
fluidInvAdd(fluid.name, -created_amount)
fluidInvAdd(fluid.name, -mb2droplet(created_amount))
end
end
@ -226,7 +226,7 @@ function mix(extra_items, product, yield)
end
end
if #fluids > 0 then
print("mixing with fluids", fluids[1])
print("mixing with fluid", fluids[1].name)
selectFluidDevice("mixer")
connectTank(fluids[1].name)
pumpToDevices(true)
@ -335,8 +335,8 @@ function cast_ingot(source, product, yield)
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
local ingot_count = math.floor(fluid_in_melter / 9000)
local leftover = fluid_in_melter - ingot_count * 9000
print("expecting", ingot_count, "ingots")
goTo(casting_pos, "west")
for i = 1, ingot_count do
@ -356,7 +356,7 @@ function cast_ingot(source, product, yield)
sleep(5)
pumpToTanks(false)
end
fluidInvAdd(fluid.name, -(ingot_count * 111))
fluidInvAdd(fluid.name, -(ingot_count * 9000))
end
function rolling_mill(extra_items)

View file

@ -57,6 +57,9 @@ end
function goForward()
if turtle.forward() then
_G.pos = _G.pos + vecOf[_G.facing]
if math.random(10) > 9 then
meow()
end
else
printError("failed to go forward")
printError(pos)
@ -106,4 +109,4 @@ end
function goHome()
goTo(vector.new(0,0,0), "south")
end
end

View file

@ -1,7 +1,44 @@
pp = require("cc.pretty").pretty_print
require("stringshit")
require("fluids")
recipes = {}
local knownAmounts = {}
knownAmounts["111"] = 9000
knownAmounts["222"] = 18000
knownAmounts["333"] = 27000
knownAmounts["444"] = 36000
knownAmounts["41.6"] = 3375 -- 500mB / 12
knownAmounts["41"] = 3375 -- 500mB / 12
knownAmounts["12"] = 1000
function mb2droplet(amount)
return math.floor(amount * 81 + 0.5)
end
function droplet2mb(amount)
return amount / 81
end
function droplet2string(droplets)
local mb = droplet2mb(droplets)
local out = tostring(math.floor(mb))
-- local frac = math.fmod(mb, 1)
-- if frac > 0 then
-- out = out .. ""
-- end
out = out .. " mB"
return out
end
function parseFluidAmount(text)
-- local parts = splitString(text, "*")
if knownAmounts[text] then
return knownAmounts[text]
end
return mb2droplet(tonumber(text))
end
function read_recipe(file)
product = file.readLine()
if product == nil then return nil end
@ -18,8 +55,11 @@ function read_recipe(file)
intermediate = string.sub(line, 14)
elseif string.sub(line, 1, 7) == "repeat " then
repeats = tonumber(string.sub(line, 8))
elseif string.sub(line, 1, 6) == "yield " then
elseif string.sub(line, 1, 6) == "yield " then
yield = tonumber(string.sub(line, 7))
if isFluid[product] then
yield = parseFluidAmount(yield)
end
elseif line == "steps:" then
break
end
@ -35,9 +75,14 @@ function read_recipe(file)
extra_items = {}
for i = 2, #words do
itemdata = splitString(words[i], ":")
if isFluid[itemdata[1]] and itemdata[2] then
amount = parseFluidAmount(itemdata[2])
else
amount = tonumber(itemdata[2]) or 1
end
table.insert(extra_items, {
name = itemdata[1],
count = tonumber(itemdata[2] or 1)
count = amount
})
end
table.insert(steps, {
@ -71,9 +116,9 @@ end
function ingredientsOf(recipe)
items = {}
for step_index = 1,#recipe.steps do
for step_index = 1, #recipe.steps do
step = recipe.steps[step_index]
for _,item in pairs(step.extra_items) do
for _, item in pairs(step.extra_items) do
if item.name ~= "nil" then
old_sum = items[item.name] or 0
items[item.name] = old_sum + item.count * recipe.repeats

View file

@ -17,15 +17,15 @@ furnace kelp:8
polished_rose_quartz
base rose_quartz
steps:
deploy_tool sand_paper
deploy_tool diamond_grit_sandpaper
rose_quartz
steps:
craft quartz redstone redstone redstone redstone redstone redstone redstone redstone
sand_paper
diamond_grit_sandpaper
steps:
craft sand paper
craft diamond_dust paper
paper
base sugar_cane
@ -415,7 +415,7 @@ base electron_tube
intermediate incomplete_redstone_chip
repeat 12
steps:
spout molten_copper:41.6
spout molten_copper:41
deploy iron_wire
press
@ -511,33 +511,18 @@ yield 111
steps:
melt
integrated_circuit_deprecated
base lapis_sheet
intermediate transitional_lapis_sheet
repeat 4
steps:
spout molten_silver:41.6
deploy copper_wire
deploy copper_wire
press
lapis_sheet
base lapis_block
steps:
press
copper_wire
base copper_sheet
yield 2
steps:
rolling_mill
lapis_block
steps:
craft lapis_lazuli lapis_lazuli lapis_lazuli lapis_lazuli lapis_lazuli lapis_lazuli lapis_lazuli lapis_lazuli lapis_lazuli
water_bucket
base bucket
steps:
spout water:1000
brass_tunnel
yield 2
steps:
craft electron_tube nil nil brass_ingot brass_ingot nil rubber rubber

View file

@ -13,5 +13,10 @@ return {
speaker.playNote("didgeridoo", volume, 6)
sleep(0.2)
speaker.playNote("didgeridoo", volume, 3)
end,
eat = function ()
speaker.playSound("entity.generic.eat")
sleep(0.1)
speaker.playSound("entity.generic.eat")
end
}

View file

@ -1,5 +1,8 @@
term.clear()
term.setCursorPos(1,1)
_G.meow = function()
peripheral.call("left","playSound","entity.cat.ambient")
end
parallel.waitForAny(
function()
shell.run("shell")
@ -8,7 +11,8 @@ parallel.waitForAny(
while true do
os.pullEvent("turtle_inventory")
if math.random(100) > 95 then
peripheral.call("left","playSound","entity.cat.ambient")
meow()
--peripheral.call("left","playSound","entity.cat.ambient")
end
end
end

View file

@ -1,9 +1,11 @@
-casting
-use droplets for liquid amounts
stock keeping
keep spout filled during repeated operations
multi-item crafting
push items into existing stacks in chest
pull items from multiple stacks if necessary
refuel self
-refuel self
refuel furnace
delivery turtle

View file

@ -73,6 +73,7 @@ function doRecipe(recipe)
if got_items then
selectItem("charcoal")
turtle.refuel()
sfx.eat()
else
sfx.fail()
print("no charcoal found, please add some")

4
computer/18/.settings Normal file
View file

@ -0,0 +1,4 @@
{
[ "motd.enable" ] = false,
[ "motd.path" ] = "/rom/motd.txt:/motd.txt:/rom/cccbridge_motd.txt",
}

21
computer/23/startup.lua Normal file
View file

@ -0,0 +1,21 @@
dropoff = peripheral.wrap("top")
while true do
item = dropoff.getItemDetail(1)
if item and item.count > 32 then
repeat
item = dropoff.getItemDetail(1)
until not item or (item.count < 10)
end
bonemeal = turtle.getItemCount(1)
turtle.select(1)
for i = 2,bonemeal do
turtle.place()
end
while turtle.suck() do end
for i = 2,16 do
turtle.select(i)
turtle.dropUp(turtle.getItemCount()-1)
end
end

11
computer/24/remove.lua Normal file
View file

@ -0,0 +1,11 @@
function step()
if turtle.dig()then
turtle.forward()
return true
end
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
return turtle.detect()
end
while step() do end

22
computer/24/startup.lua Normal file
View file

@ -0,0 +1,22 @@
rednet.open("left")
forward = {}
for i,v in pairs(term.native()) do
forward[i] = function(...)
rednet.send(5,{i,{...}})
return v(...)
end
end
term.redirect(forward)
parallel.waitForAny(
function()
shell.run("shell")
end,
function()
while true do
id,message,protocol =
rednet.receive("pocketevent")
os.queueEvent(unpack(message))
end
end
)
shell.exit()

31
computer/24/stupid.lua Normal file
View file

@ -0,0 +1,31 @@
for y = 1, 100 do
for q = 1, 4 do
for i = 1,5 do
turtle.digDown()
turtle.forward()
end
turtle.turnLeft()
turtle.forward()
turtle.digDown()
turtle.turnRight()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.digDown()
turtle.turnLeft()
turtle.forward()
turtle.digDown()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.forward()
end
turtle.down()
turtle.refuel()
end

53
computer/3/felling Normal file
View file

@ -0,0 +1,53 @@
trees = {
vector.new(-12,193,174),
vector.new(-6,191,165),
vector.new(-5,194,172),
vector.new(-11,189,162),
vector.new(-16,187,161),
vector.new(-9,188,156),
vector.new(-17,185,154),
vector.new(-9,186,149),
vector.new(-13,183,146),
vector.new(-7,183,143),
vector.new(0,186,144),
vector.new(-3,189,153),
vector.new(0,191,161),
vector.new(3,193,168),
vector.new(4,190,155),
vector.new(4,189,150)
}
pf = require("pathfinding")
im = require("inventorymanager")
function fell(index)
im.select("techreborn:rubber_sapling")
pf.lookat(trees[index or math.random(#trees)])
has, data = turtle.inspect()
--print(has,data)
if
has and data.name ==
"techreborn:rubber_log"
then
turtle.dig()
turtle.forward()
height = 0
while turtle.digUp() do
turtle.up()
height = height + 1
end
for i = 1,height do
turtle.down()
end
turtle.back()
end
turtle.place()
end
for i = 1,#trees do
fell(i)
end
pf.to(pf.home+vector.new(0,10,0))
pf.returnHome()

9
computer/3/ref.lua Normal file
View file

@ -0,0 +1,9 @@
depot = peripheral.wrap("front")
while true do
turtle.refuel()
turtle.dropUp()
depot.pullItem("top")
sleep(2)
depot.pushItem("top")
turtle.suckUp()
end

56
computer/5/both Normal file
View file

@ -0,0 +1,56 @@
W = window.create(term.native(),5,10,10,13)
W2 = window.create(term.native(),35,10,10,13)
--W.setBackgroundColor(colors.lightGray)
--W.setTextColor(colors.black)
W.clear()
W2.clear()
function scoundrilmirror()
while true do
--local x,y = W.getCursorPos()
--paintutils.drawBox(4,9,46,23,colors.gray)
--W.setBackgroundColor(colors.brown)
--W.setTextColor(colors.pink)
id,mess = rednet.receive()
if id == 4 then
W[mess[1]](unpack(mess[2]))
end
--W.setCursorPos(x,y)
--paintutils.drawBox(4,9,46,23,colors.gray)
end
end
function theifmirror()
while true do
id,mess = rednet.receive()
if id == 3 then
W2[mess[1]](unpack(mess[2]))
end
end
end
function eventmirror()
while true do
event = {os.pullEventRaw()}
if event[1] == "rednet_message" then
elseif event[1] == "modem_message" then
else
rednet.send(
4,
event,
"pocketevent"
)
rednet.send(
3,
event,
"pocketevent"
)
--print(event)
end
end
end
parallel.waitForAll(
scoundrilmirror,
theifmirror,
eventmirror
)

40
computer/5/julias Normal file
View file

@ -0,0 +1,40 @@
W = window.create(term.native(),5,10,39,13)
--W.setBackgroundColor(colors.lightGray)
--W.setTextColor(colors.black)
W.clear()
function juliamirror()
while true do
--local x,y = W.getCursorPos()
--paintutils.drawBox(4,9,46,23,colors.gray)
--W.setBackgroundColor(colors.brown)
--W.setTextColor(colors.pink)
id,mess = rednet.receive()
if id == 24 then
W[mess[1]](unpack(mess[2]))
end
--W.setCursorPos(x,y)
--paintutils.drawBox(4,9,46,23,colors.gray)
end
end
function eventmirror()
while true do
event = {os.pullEventRaw()}
if event[1] == "rednet_message" then
elseif event[1] == "modem_message" then
else
rednet.send(
24,
event,
"pocketevent"
)
--print(event)
end
end
end
parallel.waitForAll(
juliamirror,
eventmirror
)

21
disk/4/mirror Normal file
View file

@ -0,0 +1,21 @@
forward = {}
for i,v in pairs(term.native()) do
forward[i] = function(...)
rednet.send(5,{i,{...}})
return v(...)
end
end
term.redirect(forward)
parallel.waitForAny(
function
shell.run("shell")
end,
function
while true do
id,message,protocol =
rednet.receive("pocketevent")
os.queueEvent(unpack(message))
end
end
)
shell.exit()

2
disk/4/startup.lua Normal file
View file

@ -0,0 +1,2 @@
fs.copy("disk/mirror","startup.lua")

View file

@ -1,6 +1,6 @@
{
"computer": 23,
"disk": 3,
"computer": 26,
"disk": 4,
"peripheral.create:fluid_tank": 2,
"peripheral.create:item_vault": 0,
"peripheral.create:chute": 0,