idk lol
This commit is contained in:
parent
f8fd2513c8
commit
491112768c
27 changed files with 1095 additions and 3537 deletions
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue