fluid things
This commit is contained in:
parent
7694798ad0
commit
ad6af0fa35
21 changed files with 608 additions and 183 deletions
|
@ -1,4 +1,4 @@
|
|||
pp = require("cc.pretty")
|
||||
pp = require("cc.pretty").pretty_print
|
||||
require("recipes")
|
||||
sfx = require("sfx")
|
||||
require("pathfinding")
|
||||
|
@ -10,23 +10,25 @@ keep_stocked = {
|
|||
flint = 10
|
||||
}
|
||||
|
||||
resetAllFluidDevices()
|
||||
goHome()
|
||||
|
||||
print("known recipes:\n")
|
||||
for k,_ in pairs(recipes) do
|
||||
for k, _ in pairs(recipes) do
|
||||
write(k)
|
||||
write(", ")
|
||||
end
|
||||
write("\nchoose one: ")
|
||||
function completion(partial)
|
||||
list = {}
|
||||
for k,_ in pairs(recipes) do
|
||||
for k, _ in pairs(recipes) do
|
||||
if string.sub(k, 1, #partial) == partial then
|
||||
table.insert(list, string.sub(k, #partial + 1))
|
||||
end
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
input = splitString(read(nil, nil, completion))
|
||||
|
||||
target_product = input[1]
|
||||
|
@ -52,7 +54,7 @@ function doRecipe(recipe)
|
|||
inited = true
|
||||
selectItem(recipe.base, false)
|
||||
end
|
||||
use_machine[step.machine](step.extra_items)
|
||||
use_machine[step.machine](step.extra_items, recipe.product, recipe.yield)
|
||||
-- read()
|
||||
end
|
||||
end
|
||||
|
@ -66,10 +68,9 @@ function doRecipe(recipe)
|
|||
turtle.select(1)
|
||||
end
|
||||
|
||||
|
||||
todo = {}
|
||||
for i = 1,copies do
|
||||
table.insert(todo, recipes[target_product])
|
||||
work_queue = {}
|
||||
for i = 1, copies do
|
||||
table.insert(work_queue, recipes[target_product])
|
||||
end
|
||||
|
||||
function listUncraftable(ingredients)
|
||||
|
@ -90,10 +91,12 @@ function tryCreating(recipe)
|
|||
ingredients = ingredientsOf(recipe)
|
||||
missing_ingredients = getMissing(ingredients)
|
||||
if len(missing_ingredients) == 0 then
|
||||
todo[#todo] = nil
|
||||
work_queue[#work_queue] = nil
|
||||
turtle.select(1)
|
||||
-- todo exclude deploy_tool too and make it get its own tool
|
||||
if recipe.steps[1].machine ~= "craft" then
|
||||
if recipe.steps[1].machine ~= "craft" and
|
||||
recipe.steps[1].machine ~= "alloy"
|
||||
then
|
||||
for item, count in pairs(ingredients) do
|
||||
takeItems(item, count)
|
||||
end
|
||||
|
@ -104,19 +107,19 @@ function tryCreating(recipe)
|
|||
return missing_ingredients
|
||||
end
|
||||
|
||||
while #todo > 0 do
|
||||
while #work_queue > 0 do
|
||||
-- for item, _count in pairs(getMissing(keep_stocked)) do
|
||||
-- print("creating", item, "to keep stock up")
|
||||
-- tryCreating(recipes[item])
|
||||
-- end
|
||||
current_recipe = todo[#todo]
|
||||
current_recipe = work_queue[#work_queue]
|
||||
-- ingredients = ingredientsOf(current_recipe)
|
||||
pp.pretty_print(ingredients)
|
||||
pp(ingredients)
|
||||
missing_ingredients = tryCreating(current_recipe)
|
||||
if missing_ingredients then
|
||||
wait_for = listUncraftable(missing_ingredients)
|
||||
while len(wait_for) > 0 do
|
||||
for name,count in pairs(wait_for) do
|
||||
for name, count in pairs(wait_for) do
|
||||
print("please supply", count, name, "manually")
|
||||
end
|
||||
print("press return to continue, q to quit")
|
||||
|
@ -130,11 +133,10 @@ while #todo > 0 do
|
|||
for name, count in pairs(missing_ingredients) do
|
||||
if recipes[name] then
|
||||
print("first making", count, name)
|
||||
table.insert(todo, recipes[name])
|
||||
table.insert(work_queue, recipes[name])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
print("done!")
|
||||
sfx.success()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue