From 760729ee4b868706a4e562b0ab53e6a7deeeb0d1 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Fri, 23 May 2025 15:45:14 +0200 Subject: [PATCH 1/3] cleanup --- computer/13/garbage/evil.lua | 21 ++++++ computer/13/{ => garbage}/make_belts.lua | 0 computer/13/inventory.lua | 89 ++++++++++++++---------- computer/13/keep_stocked.lua | 4 -- computer/13/machines.lua | 14 +--- computer/13/main.lua | 14 ++++ computer/13/pathfinding.lua | 24 +------ computer/13/pos.txt | 0 computer/13/recipes.lua | 11 +-- computer/13/recipes.txt | 8 +++ computer/13/stringshit.lua | 1 + computer/13/test.lua | 3 - computer/13/todo.txt | 12 ++++ computer/13/work.lua | 27 ++----- 14 files changed, 126 insertions(+), 102 deletions(-) create mode 100644 computer/13/garbage/evil.lua rename computer/13/{ => garbage}/make_belts.lua (100%) delete mode 100644 computer/13/keep_stocked.lua create mode 100644 computer/13/main.lua delete mode 100644 computer/13/pos.txt delete mode 100644 computer/13/test.lua create mode 100644 computer/13/todo.txt diff --git a/computer/13/garbage/evil.lua b/computer/13/garbage/evil.lua new file mode 100644 index 0000000..8f437c3 --- /dev/null +++ b/computer/13/garbage/evil.lua @@ -0,0 +1,21 @@ +sfx = require("sfx") +return +parallel.waitForAll( + function() + while true do + sleep(math.random(10, 100)) + if math.random(10) > 5 then + sfx.fail() + else + sfx.success() + end + event = { os.pullEventRaw() } + if event[1] == "terminate" then + shell.exit() + os.shutdown() + end + end + end, function() + term.setCursorPos(1, 1) + shell.run("shell") + end) diff --git a/computer/13/make_belts.lua b/computer/13/garbage/make_belts.lua similarity index 100% rename from computer/13/make_belts.lua rename to computer/13/garbage/make_belts.lua diff --git a/computer/13/inventory.lua b/computer/13/inventory.lua index edfca6f..c0276fa 100644 --- a/computer/13/inventory.lua +++ b/computer/13/inventory.lua @@ -1,7 +1,16 @@ pp = require("cc.pretty") -pFront = peripheral.wrap("front") -pDown = peripheral.wrap("bottom") +function pFront(fn, ...) + return peripheral.call("front", fn, unpack(arg)) +end + +function pBottom(fn, ...) + return peripheral.call("bottom", fn, unpack(arg)) +end + +function pTop(fn, ...) + return peripheral.call("top", fn, unpack(arg)) +end function findItems(item_list, target) for i, v in pairs(item_list) do @@ -12,31 +21,8 @@ function findItems(item_list, target) return nil end --- uses selected item -function insertForward(slot, count) - turtle.dropDown(count) - pFront.pullItems("bottom", 1, 64, slot) -end - -function takeForward(slot) - -- pDown.pullItems("front", slot, 64, 1) - peripheral.call("bottom", "pullItems", "front", slot or 1) - turtle.suckDown() -end - -function insertDepot(count) - turtle.dropDown(count) - peripheral.call("front", "pullItem", "bottom") -end - -function takeDepot() - peripheral.call("front", "pushItem", "bottom") - turtle.suckDown() -end - - function takeItems(type, count) - local item_list = pFront.list() + local item_list = pFront("list") local slot = findItems(item_list, type) if slot == nil then @@ -44,18 +30,31 @@ function takeItems(type, count) return false end - empty_slot = pFront.size() - -- todo error if not empty - pFront.pullItems("front", 1, 64, empty_slot) -- empty first slot - pFront.pullItems("front", slot, 64, 1) -- get target item to first slot - pFront.pullItems("front", empty_slot, 64, slot) -- empty last slot for next time + if slot ~= 1 then + local size = pFront("size") + local empty_slot = nil + for i = 1, size do + if pFront("getItemDetail", i) == nil then + empty_slot = i + break + end + end + if empty_slot == nil then + printError("no empty slot in chest, pls fix") + exit() + end + if empty_slot ~= 1 then + pFront("pullItems", "front", 1, 64, empty_slot) -- empty first slot + end + pFront("pullItems", "front", slot, 64, 1) -- get target item to first slot + end return turtle.suck(count) end function selectItem(name, has_nbt) has_nbt = has_nbt or false if name == nil or name == "nil" then - for i = 1,16 do + for i = 1, 16 do if turtle.getItemCount(i) == 0 then turtle.select(i) return @@ -64,7 +63,7 @@ function selectItem(name, has_nbt) printError("no empty slot found") return end - for i = 1,16 do + for i = 1, 16 do detail = turtle.getItemDetail(i, true); if detail and stripModname(detail.name) == name then if has_nbt == (detail.nbt ~= nil) then @@ -78,10 +77,10 @@ end function getMissing(needed_items) missing = {} - for name,count in pairs(needed_items) do + for name, count in pairs(needed_items) do missing[name] = count end - target_contents = peripheral.call("front", "list") + target_contents = pFront("list") for _, target_item in pairs(target_contents) do for name, missing_count in pairs(missing) do @@ -98,3 +97,23 @@ function getMissing(needed_items) return missing end +function insertForward(slot, count) + turtle.dropDown(count) + pFront("pullItems", "bottom", 1, 64, slot) +end + +function takeForward(slot) + pBottom("pullItems", "front", slot or 1) + turtle.suckDown() +end + +function insertDepot(count) + turtle.dropDown(count) + pFront("pullItem", "bottom") +end + +function takeDepot() + pFront("pushItem", "bottom") + turtle.suckDown() +end + diff --git a/computer/13/keep_stocked.lua b/computer/13/keep_stocked.lua deleted file mode 100644 index f0520ab..0000000 --- a/computer/13/keep_stocked.lua +++ /dev/null @@ -1,4 +0,0 @@ -keep_stocked = { - kelp = 10, - flint = 10 -} \ No newline at end of file diff --git a/computer/13/machines.lua b/computer/13/machines.lua index 4df90fa..478c137 100644 --- a/computer/13/machines.lua +++ b/computer/13/machines.lua @@ -14,7 +14,7 @@ function mill(extra_items) insertForward(1, item.count) end print(item_count,"items") - while peripheral.call("front", "getItemDetail", 1) do + while pFront("getItemDetail", 1) do sleep(0.1) end for i = 2, 10 do @@ -29,7 +29,7 @@ function deploy(extra_items, nbt) goUp() selectItem(extra_items[1].name, nbt) turtle.dropUp(1) - peripheral.call("front", "pullItem", "top") + pFront("pullItem", "top") goDown() goDown() @@ -39,7 +39,7 @@ function deploy_tool(extra_items) deploy(extra_items, true) goUp() goUp() - peripheral.call("front", "pushItem", "top") + pFront("pushItem", "top") turtle.suckUp() end function furnace(extra_items) @@ -55,7 +55,6 @@ function furnace(extra_items) insertForward(1, item.count) end wait_time = 10 * item_count - -- peripheral.call("front", "") -- TODO refuel sleep(wait_time) takeForward(3) @@ -83,14 +82,7 @@ function mix(extra_items) takeForward(10) end function craft(extra_items) - -- for i = 1, 16 do - -- if turtle.getItemCount(i) ~= 0 then - -- turtle.select(i) - -- turtle.drop() - -- end - -- end local slot = 0 - print(len(extra_items), "extra items") for _, item in pairs(extra_items) do slot = slot + 1 if slot == 4 then diff --git a/computer/13/main.lua b/computer/13/main.lua new file mode 100644 index 0000000..600a21b --- /dev/null +++ b/computer/13/main.lua @@ -0,0 +1,14 @@ +pretty = require("cc.pretty").pretty_print + +require("recipes") +sfx = require("sfx") +require("pathfinding") +require("inventory") + +keep_stocked = { + kelp = 10, + flint = 10 +} + +go_to(vector.new(0,0,0), "south") +recipes = load_recipes() \ No newline at end of file diff --git a/computer/13/pathfinding.lua b/computer/13/pathfinding.lua index 56cac54..d86096d 100644 --- a/computer/13/pathfinding.lua +++ b/computer/13/pathfinding.lua @@ -1,15 +1,7 @@ -pp = require("cc.pretty") +pp = require("cc.pretty").pretty_print --- if _G.pos == nil then _G.facing = "south" _G.pos = vector.new(0,0,0) --- file = fs.open("pos.txt", "r") --- data = splitString(file.readAll()) --- _G.pos.x = tonumber(data[1]) --- _G.pos.y = tonumber(data[2]) --- _G.pos.z = tonumber(data[3]) --- _G.facing = data[4] --- end local up = vector.new(0,1,0) @@ -34,17 +26,9 @@ local vecOf = { west = vector.new(-1,0,0), } -function savePos() - -- fs.delete("pos.txt") - -- file = fs.open("pos.txt", "w") - -- file.write(_G.pos.x .. " " .. _G.pos.y .. " " .. _G.pos.z .. " " .. _G.facing) -end - - function goUp() if turtle.up() then _G.pos.y = _G.pos.y + 1 - savePos() else printError("failed to go up") printError(pos) @@ -54,7 +38,6 @@ end function goDown() if turtle.down() then _G.pos.y = _G.pos.y - 1 - savePos() else printError("failed to go down") printError(pos) @@ -64,19 +47,16 @@ end function goLeft() turtle.turnLeft() _G.facing = leftOf[_G.facing] - savePos() end function goRight() turtle.turnRight() _G.facing = rightOf[_G.facing] - savePos() end function goForward() if turtle.forward() then _G.pos = _G.pos + vecOf[_G.facing] - savePos() else printError("failed to go forward") printError(pos) @@ -86,7 +66,6 @@ end function goBack() if turtle.back() then _G.pos = _G.pos - vecOf[_G.facing] - savePos() else printError("failed to go backward") printError(pos) @@ -112,7 +91,6 @@ end function go_to(target, face) while target ~= _G.pos do stepTo(target) - -- print(_G.pos, _G.facing) end if face and face ~= _G.facing then if rightOf[_G.facing] == face then diff --git a/computer/13/pos.txt b/computer/13/pos.txt deleted file mode 100644 index e69de29..0000000 diff --git a/computer/13/recipes.lua b/computer/13/recipes.lua index b9faacf..2d64c0e 100644 --- a/computer/13/recipes.lua +++ b/computer/13/recipes.lua @@ -1,4 +1,4 @@ -pp = require("cc.pretty") +pp = require("cc.pretty").pretty_print require("stringshit") recipes = {} @@ -51,18 +51,17 @@ function read_recipe(file) end function load_recipes() - file = fs.open("recipes.txt", "r") + local file = fs.open("recipes.txt", "r") if not file then print("error: no recipes found") return end recipes = {} while 1 do - r = read_recipe(file) + local r = read_recipe(file) if r == nil then break end recipes[r.product] = r end - return recipes end function ingredientsOf(recipe) @@ -80,4 +79,6 @@ function ingredientsOf(recipe) items[recipe.base] = (items[recipe.base] or 0) + 1 end return items -end \ No newline at end of file +end + +load_recipes() diff --git a/computer/13/recipes.txt b/computer/13/recipes.txt index d9f1a45..7172e6a 100644 --- a/computer/13/recipes.txt +++ b/computer/13/recipes.txt @@ -160,3 +160,11 @@ craft birch_planks birch_slab birch_planks birch_planks nil birch_planks birch_p birch_slab steps: craft birch_planks birch_planks birch_planks + +computer_normal +steps: +craft andesite_alloy andesite_alloy andesite_alloy andesite_alloy polished_rose_quartz andesite_alloy andesite_alloy glass_pane andesite_alloy + +glass_pane +steps: +craft glass glass glass glass glass glass \ No newline at end of file diff --git a/computer/13/stringshit.lua b/computer/13/stringshit.lua index 9b4cbbe..2c2f634 100644 --- a/computer/13/stringshit.lua +++ b/computer/13/stringshit.lua @@ -1,3 +1,4 @@ + function splitString(source, sep) sep = sep or " " elements = {} diff --git a/computer/13/test.lua b/computer/13/test.lua deleted file mode 100644 index 8d73ea6..0000000 --- a/computer/13/test.lua +++ /dev/null @@ -1,3 +0,0 @@ -s = require("sfx") -s.success() ---s.fail() diff --git a/computer/13/todo.txt b/computer/13/todo.txt new file mode 100644 index 0000000..9f3e4e0 --- /dev/null +++ b/computer/13/todo.txt @@ -0,0 +1,12 @@ +sw: fluid basin +hw: spout +sw: spout +casting +stock keeping +multi-item crafting +push items into existing stacks in chest +pull items from multiple stacks if necessary +refuel self +refuel furnace + +delivery turtle diff --git a/computer/13/work.lua b/computer/13/work.lua index 437d8fd..46459bf 100644 --- a/computer/13/work.lua +++ b/computer/13/work.lua @@ -1,11 +1,15 @@ pp = require("cc.pretty") -require("keep_stocked") require("recipes") sfx = require("sfx") require("pathfinding") use_machine = require("machines") require("inventory") +keep_stocked = { + kelp = 10, + flint = 10 +} + go_to(vector.new(0,0,0), "south") recipes = load_recipes() @@ -89,15 +93,13 @@ function tryCreating(recipe) if len(missing_ingredients) == 0 then todo[#todo] = nil turtle.select(1) + -- todo exclude deploy_tool too and make it get its own tool if recipe.steps[1].machine ~= "craft" then for item, count in pairs(ingredients) do takeItems(item, count) end end doRecipe(current_recipe) - -- for item, min_count in pairs(getMissing(keep_stocked)) do - -- table.insert(todo, recipes[item]) - -- end return nil end return missing_ingredients @@ -113,18 +115,6 @@ while #todo > 0 do pp.pretty_print(ingredients) missing_ingredients = tryCreating(current_recipe) if missing_ingredients then - -- missing_ingredients = getMissing(ingredients) - -- if len(missing_ingredients) == 0 then - -- todo[#todo] = nil - -- turtle.select(1) - -- for item, count in pairs(ingredients) do - -- takeItems(item, count) - -- end - -- doRecipe(current_recipe) - -- for item, min_count in pairs(getMissing(keep_stocked)) do - -- table.insert(todo, recipes[item]) - -- end - -- else wait_for = listUncraftable(missing_ingredients) while len(wait_for) > 0 do for name,count in pairs(wait_for) do @@ -141,15 +131,10 @@ while #todo > 0 do for name, count in pairs(missing_ingredients) do if recipes[name] then print("first making", count, name) - -- for i = 1,count do table.insert(todo, recipes[name]) - -- end end end end - - -- print("aaa") - -- read() end print("done!") sfx.success() From 7694798ad06fff90a7d6fd727d280c799d838260 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Fri, 23 May 2025 18:50:16 +0200 Subject: [PATCH 2/3] cleanup --- computer/13/garbage/make_belts.lua | 60 ------------------------------ computer/13/machines.lua | 30 ++++++++++++--- computer/13/main.lua | 3 +- computer/13/pathfinding.lua | 6 ++- computer/13/recipes.txt | 14 ++++++- computer/13/work.lua | 5 +-- 6 files changed, 45 insertions(+), 73 deletions(-) delete mode 100644 computer/13/garbage/make_belts.lua diff --git a/computer/13/garbage/make_belts.lua b/computer/13/garbage/make_belts.lua deleted file mode 100644 index 83024e1..0000000 --- a/computer/13/garbage/make_belts.lua +++ /dev/null @@ -1,60 +0,0 @@ -require("recipes") -require("pathfinding") -iv = require("inventory") - - --- belt recipe -getItems("minecraft:kelp", 4) -getItems("minecraft:charcoal", 1) -getItems("techreborn:rubber", 3) --- furnace -go_to(vector.new(1,0,0), "south") -selectItem("minecraft:charcoal") -iv.insertForward(2) -selectItem("minecraft:kelp") -iv.insertForward(1) - -sleep(40) -iv.takeForward(3) - -selectItem("minecraft:dried_kelp") - -for i = 1,3 do --- deployer -go_to(vector.new(2,0,0), "south") -iv.insertForwardDepot(1) -go_to(vector.new(2,1,0), "south") -selectItem("techreborn:rubber") -turtle.dropUp(1) -goDown() -sleep(1) -iv.takeForwardDepot() --- press -go_to(vector.new(-1,0,0), "south") -selectItem("minecraft:dried_kelp", true) -iv.insertForwardDepot(1) -sleep(1) -iv.takeForwardDepot() --- deployer 2 -selectItem("minecraft:dried_kelp", true) -print("selected partial belt") -go_to(vector.new(2,0,0), "south") -iv.insertForwardDepot(1) -go_to(vector.new(2,1,0), "south") -selectItem("minecraft:dried_kelp", false) -turtle.dropUp(1) -goDown() -sleep(1) -iv.takeForwardDepot() --- press 2 -selectItem("minecraft:dried_kelp", true) -go_to(vector.new(-1,0,0), "south") -iv.insertForwardDepot(1) -sleep(1) -iv.takeForwardDepot() - -selectItem("minecraft:dried_kelp", true) - -end - -go_to(vector.new(0,0,0), "south") diff --git a/computer/13/machines.lua b/computer/13/machines.lua index 478c137..9b926cb 100644 --- a/computer/13/machines.lua +++ b/computer/13/machines.lua @@ -1,8 +1,23 @@ require("inventory") require("pathfinding") +press_pos = vector.new(1,0,0) +deployer_pos = vector.new(2,0,0) +furnace_pos = vector.new(3,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) + +-- fluid_tanks = { +-- water = vector.new(0,0,-1), +-- lava = vector.new(0,0,-1) +-- } + function mill(extra_items) - go_to(vector.new(-4,0,0),"south") + goTo(mill_pos,"south") item_count = 0 if turtle.getItemCount() ~= 0 then item_count = 1 @@ -23,7 +38,7 @@ function mill(extra_items) end function deploy(extra_items, nbt) -- extra_items should only be one item - go_to(vector.new(2,0,0), "south") + goTo(deployer_pos, "south") insertDepot(1) goUp() goUp() @@ -43,7 +58,7 @@ function deploy_tool(extra_items) turtle.suckUp() end function furnace(extra_items) - go_to(vector.new(1,0,0), "south") + goTo(furnace_pos, "south") item_count = 0 if turtle.getItemCount() ~= 0 then item_count = 1 @@ -60,14 +75,17 @@ function furnace(extra_items) takeForward(3) end function press(_) - go_to(vector.new(-1,0,0), "south") + goTo(press_pos, "south") insertDepot(1) sleep(1) takeDepot() end -function compact(extra_items) end +function compact(extra_items) + printError("unimplemented :3") + fail() +end function mix(extra_items) - go_to(vector.new(-3,0,0), "south") + goTo(mixer_pos, "south") insertForward(1, 1) for _, item in pairs(extra_items) do selectItem(item.name) diff --git a/computer/13/main.lua b/computer/13/main.lua index 600a21b..eaf9080 100644 --- a/computer/13/main.lua +++ b/computer/13/main.lua @@ -10,5 +10,4 @@ keep_stocked = { flint = 10 } -go_to(vector.new(0,0,0), "south") -recipes = load_recipes() \ No newline at end of file +goHome() diff --git a/computer/13/pathfinding.lua b/computer/13/pathfinding.lua index d86096d..3bd19f4 100644 --- a/computer/13/pathfinding.lua +++ b/computer/13/pathfinding.lua @@ -88,7 +88,7 @@ function stepTo(target) end end -function go_to(target, face) +function goTo(target, face) while target ~= _G.pos do stepTo(target) end @@ -103,3 +103,7 @@ function go_to(target, face) end end end + +function goHome() + goTo(vector.new(0,0,0), "south") +end \ No newline at end of file diff --git a/computer/13/recipes.txt b/computer/13/recipes.txt index 7172e6a..3654a1e 100644 --- a/computer/13/recipes.txt +++ b/computer/13/recipes.txt @@ -167,4 +167,16 @@ craft andesite_alloy andesite_alloy andesite_alloy andesite_alloy polished_rose_ glass_pane steps: -craft glass glass glass glass glass glass \ No newline at end of file +craft glass glass glass glass glass glass + +copper_casing +base andesite_casing +intermediate incomplete_copper_casing +repeat 3 +steps: +deploy rubber +deploy copper_sheet + +kelp +steps: +mix water kelp bone_meal:2 diff --git a/computer/13/work.lua b/computer/13/work.lua index 46459bf..ff103ac 100644 --- a/computer/13/work.lua +++ b/computer/13/work.lua @@ -10,8 +10,7 @@ keep_stocked = { flint = 10 } -go_to(vector.new(0,0,0), "south") -recipes = load_recipes() +goHome() print("known recipes:\n") for k,_ in pairs(recipes) do @@ -57,7 +56,7 @@ function doRecipe(recipe) -- read() end end - go_to(vector.new(0,0,0), "south") + goHome() for i = 1, 16 do if turtle.getItemCount(i) ~= 0 then turtle.select(i) From ad6af0fa358bc5328a6113712a27020f40b3c8b1 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sun, 25 May 2025 03:02:48 +0200 Subject: [PATCH 3/3] fluid things --- computer/0/startup.lua | 2 +- computer/11/test.txt | 55 ---------- computer/11/torment_progress.txt | 2 +- computer/13/current_fluids | 0 computer/13/fluid_state.lua | 40 +++++++ computer/13/fluids.lua | 172 +++++++++++++++++++++++++++++++ computer/13/inventory.lua | 31 +++--- computer/13/machines.lua | 121 +++++++++++++++++++--- computer/13/pathfinding.lua | 4 +- computer/13/recipes.lua | 4 + computer/13/recipes.txt | 72 +++++++++++++ computer/13/test.lua | 12 +++ computer/13/work.lua | 34 +++--- computer/4/build.lua | 67 +++--------- computer/4/copyfile.lua | 13 --- computer/4/inventorymanager.lua | 25 ++++- computer/4/pathfinding.lua | 2 +- computer/4/pathfinding2.lua | 5 + computer/4/startup.lua | 81 +++++++++++++-- computer/5/startup.lua | 45 +++++++- ids.json | 4 +- 21 files changed, 608 insertions(+), 183 deletions(-) delete mode 100644 computer/11/test.txt create mode 100644 computer/13/current_fluids create mode 100644 computer/13/fluid_state.lua create mode 100644 computer/13/fluids.lua create mode 100644 computer/13/test.lua delete mode 100644 computer/4/copyfile.lua diff --git a/computer/0/startup.lua b/computer/0/startup.lua index 051f6a9..6cf3aad 100644 --- a/computer/0/startup.lua +++ b/computer/0/startup.lua @@ -50,6 +50,6 @@ while true do sleep(random(1,4)) end end ---parallel.waitForAll(sound,sound,sound,sound,sound) +parallel.waitForAll(sound,sound,sound,sound,sound) peripheral.call("top","turnOn") -- os.reboot() diff --git a/computer/11/test.txt b/computer/11/test.txt deleted file mode 100644 index 11d79ca..0000000 --- a/computer/11/test.txt +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - something silly - index - - - - - -
-

meow

-

-hello i might write some words here from time to time
-

-

-this website is running on my own webserver and generated with my static site builder
-this means it is
-[✓] scuffed
-[✓] non-compliant
-[✓] transgener
-[✔] no tracking or javascipt
-[✅] silly
-

-

"content"

-

-- unity on linux sucks
-- dead trees
-- horological crimes
-- snad
-- keyboar
-- distracting
-- blender
-- old projects
-- todo: put more words in the computer
-

-

-me elsewhere | photos | portfolio
-bookmarks | music
-

-
-

-

-

-

-

-
- - -
- - - \ No newline at end of file diff --git a/computer/11/torment_progress.txt b/computer/11/torment_progress.txt index ca7bf83..b1bd38b 100644 --- a/computer/11/torment_progress.txt +++ b/computer/11/torment_progress.txt @@ -1 +1 @@ -13 \ No newline at end of file +13 diff --git a/computer/13/current_fluids b/computer/13/current_fluids new file mode 100644 index 0000000..e69de29 diff --git a/computer/13/fluid_state.lua b/computer/13/fluid_state.lua new file mode 100644 index 0000000..07a81e4 --- /dev/null +++ b/computer/13/fluid_state.lua @@ -0,0 +1,40 @@ +return { + { + connected = false, + name = "water", + amount = 13100, + }, + { + connected = false, + name = "blood", + amount = 100, + }, + { + connected = false, + amount = 0, + }, + { + connected = false, + amount = 0, + }, + { + connected = false, + amount = 0, + }, + { + connected = false, + amount = 0, + }, + { + connected = false, + amount = 0, + }, + { + connected = false, + amount = 0, + }, + { + connected = false, + amount = 0, + }, +} \ No newline at end of file diff --git a/computer/13/fluids.lua b/computer/13/fluids.lua new file mode 100644 index 0000000..3d1a85a --- /dev/null +++ b/computer/13/fluids.lua @@ -0,0 +1,172 @@ +require("pathfinding") +pretty = require("cc.pretty") +pp = pretty.pretty_print() + +isFluid = { + water = true, + lava = true, + milk = true, + blood = true, + molten_rose_gold = true, + molten_copper = true, + molten_gold = true, + molten_bronze = true, + molten_tin = true, + molten_zinc = true, + compound_mixture = true, +} + +fluidDevicePos = { + trash = vector.new(2, 0, -1), + water_source = vector.new(0, 0, -1), + mixer = vector.new(-1, 0, -1), + compactor = vector.new(-2, 0, -1), + spout = vector.new(-3, 0, -1), + melter = vector.new(-4, 0, -1), +} + +tankPos = { + vector.new(4, 0, -3), + vector.new(3, 0, -3), + vector.new(2, 0, -3), + vector.new(1, 0, -3), + vector.new(0, 0, -3), + vector.new(-1, 0, -3), + vector.new(-2, 0, -3), + vector.new(-3, 0, -3), + vector.new(-4, 0, -3), +} + +function setRedRouter(state) + peripheral.call("bottom", "setOutput", "bottom", state) + peripheral.call("bottom", "setOutput", "front", state) +end + +function loadFluidInventory() + return require("fluid_state") +end + +function saveFluids() + fs.delete("fluid_state.lua") + repeat + file = fs.open("fluid_state.lua", "w") + until file + file.write("return ") + file.write(textutils.serialise(_G.fluidTanks)) + file.close() +end + +function getFluidAmount(type) + for index, tank in pairs(_G.fluidTanks) do + if tank.name == type then + return tank.amount + end + end + return 0 +end + +function pumpToDevices(enable) + goTo(vector.new(4, 0, -1)) + -- clutches invert the signal + setRedRouter(not enable) +end + +function pumpToTanks(enable) + goTo(vector.new(3, 0, -1)) + -- clutches invert the signal + setRedRouter(not enable) +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 + for x = -4, 4 do + goTo(vector.new(x, 0, -3)) + setRedRouter(false) + end + _G.activeFluidDevice = nil + for i = 1, 9 do + _G.fluidTanks[i].connected = false + end +end + +function selectFluidDevice(name) + if fluidDevicePos[name] == nil then + error("selectFluidDevice(" .. name .. "); not a known fluid device", 2) + end + + if _G.activeFluidDevice ~= nil then + goTo(fluidDevicePos[_G.activeFluidDevice]) + _G.activeFluidDevice = nil + setRedRouter(false) + end + goTo(fluidDevicePos[name]) + setRedRouter(true) + _G.activeFluidDevice = name +end + +function connectTankOrAssign(fluid) + local has_fluid = false + for index, tank in pairs(_G.fluidTanks) do + if tank.name == fluid then + has_fluid = true + print(fluid, "already assigned to", index) + end + end + if not has_fluid then + print(fluid, "not in tanks, assigning new") + for index = 1, 9 do + if _G.fluidTanks[index].name == nil or _G.fluidTanks[index].amount == 0 then + _G.fluidTanks[index] = { + name = fluid, + amount = 0, + connected = false + } + print("assigned tank", index, "to", fluid) + break + end + end + end + connectTanks({ fluid }) +end + +function connectTanks(fluid_list) + print("connecting tanks") + pp(fluid_list) + for index, tank in pairs(_G.fluidTanks) do + should_be_connected = false + for _, fluid in pairs(fluid_list) do + if tank.name == fluid then + should_be_connected = true + break + end + end + if should_be_connected ~= tank.connected then + print("setting", tank.name, index, "to", should_be_connected) + goTo(tankPos[index]) + setRedRouter(should_be_connected) + _G.fluidTanks[index].connected = should_be_connected + end + end +end + +function fluidInvAdd(name, amount) + print("added", amount, "to", name) + for index, tank in pairs(_G.fluidTanks) do + if tank.name == name then + tank.amount = tank.amount + amount + -- TODO limit capacity + end + end + saveFluids() +end + +_G.fluidTanks = _G.fluidTanks or loadFluidInventory() diff --git a/computer/13/inventory.lua b/computer/13/inventory.lua index c0276fa..67572cc 100644 --- a/computer/13/inventory.lua +++ b/computer/13/inventory.lua @@ -1,4 +1,5 @@ -pp = require("cc.pretty") +pp = require("cc.pretty").pretty_print +require("fluids") function pFront(fn, ...) return peripheral.call("front", fn, unpack(arg)) @@ -31,22 +32,10 @@ function takeItems(type, count) end if slot ~= 1 then - local size = pFront("size") - local empty_slot = nil - for i = 1, size do - if pFront("getItemDetail", i) == nil then - empty_slot = i - break - end - end - if empty_slot == nil then - printError("no empty slot in chest, pls fix") - exit() - end - if empty_slot ~= 1 then - pFront("pullItems", "front", 1, 64, empty_slot) -- empty first slot - end + local empty_slot = pFront("size") + pFront("pullItems", "front", 1, 64, empty_slot) -- empty first slot pFront("pullItems", "front", slot, 64, 1) -- get target item to first slot + pFront("pullItems", "front", empty_slot, 64, slot) -- empty last slot for next time end return turtle.suck(count) end @@ -93,7 +82,15 @@ function getMissing(needed_items) end end end - pp.pretty_print(missing) + + for name, amount in pairs(missing) do + if isFluid[name] then + missing [name] = amount - getFluidAmount(name) + if missing[name] < 1 then + missing[name] = nil + end + end + end return missing end diff --git a/computer/13/machines.lua b/computer/13/machines.lua index 9b926cb..0bbe08b 100644 --- a/computer/13/machines.lua +++ b/computer/13/machines.lua @@ -1,9 +1,13 @@ require("inventory") 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(3,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) @@ -11,11 +15,34 @@ spout_pos = vector.new(-3,0,0) melter_pos = vector.new(-4,1,-3) casting_table_pos = vector.new(-3,0,-3) --- fluid_tanks = { --- water = vector.new(0,0,-1), --- lava = vector.new(0,0,-1) --- } - +function spout(extra_items) + local fluid = extra_items[1] + if not fluid then + error("no fluid specified") + end + goTo(spout_pos, "south") + insertDepot(1) + selectFluidDevice("spout") + connectTanks({fluid.name}) + pumpToDevices(true) + sleep(10) + pumpToDevices(false) + goTo(spout_pos, "south") + takeDepot() + fluidInvAdd(fluid.name, -fluid.count) + pumpToTanks(true) + goTo(spout_pos, "south") + while #pFront("tanks")[1].amount > 0 do + sleep(0.5) + 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") item_count = 0 @@ -36,13 +63,13 @@ function mill(extra_items) takeForward(i) end end -function deploy(extra_items, nbt) +function deploy(extra_items) -- extra_items should only be one item goTo(deployer_pos, "south") insertDepot(1) goUp() goUp() - selectItem(extra_items[1].name, nbt) + selectItem(extra_items[1].name) turtle.dropUp(1) pFront("pullItem", "top") @@ -51,7 +78,18 @@ function deploy(extra_items, nbt) takeDepot() end function deploy_tool(extra_items) - deploy(extra_items, true) + -- extra_items should only be one item + goTo(deployer_pos, "south") + insertDepot(1) + goUp() + goUp() + selectItem(extra_items[1].name) + turtle.dropUp(1) + pFront("pullItem", "top") + + goDown() + goDown() + takeDepot() goUp() goUp() pFront("pushItem", "top") @@ -82,9 +120,63 @@ function press(_) end function compact(extra_items) printError("unimplemented :3") - fail() + sfx.fail() end -function mix(extra_items) +function alloy(parts, product) + for _, item in pairs(parts) do + if not isFluid[item.name] then + error(item.name .. " is not a known fluid, but was used in alloy") + end + end + selectFluidDevice("mixer") + connectTanks(parts) + pumpToDevices(true) + goTo(mixer_pos, "south") + -- TODO + --[[ + wait until at least one input fluid is used up + if two remain, it needs to keep track of which tank gets what when draining + ]] + + -- while true do + + -- end + pumpToDevices(false) +end +function melt(_, product, yield) + goTo(melter_pos, "north") + goUp() + turtle.drop() + selectFluidDevice("melter") + connectTankOrAssign(product) + pumpToTanks(true) + goTo(melter_pos, "north") + while #pFront("items") > 0 do + sleep(1) + end + pumpToTanks(false) + fluidInvAdd(product, yield) +end +function mix(extra_items, product, yield) + -- prepare fluids + local fluids = {} + for index, item in pairs(extra_items) do + if isFluid[item.name] then + table.insert(fluids, item) + extra_items[index] = nil + end + end + if #fluids > 0 then + print("mixing with fluids", fluids[1]) + selectFluidDevice("mixer") + connectTanks({fluids[1].name}) + pumpToDevices(true) + sleep(10) + pumpToDevices(false) + end + -- print("aaa") + -- read() + -- mix goTo(mixer_pos, "south") insertForward(1, 1) for _, item in pairs(extra_items) do @@ -98,6 +190,7 @@ function mix(extra_items) sleep(10) -- todo wait until ingredients are gone takeForward(10) + -- todo empty fluids end function craft(extra_items) local slot = 0 @@ -124,5 +217,9 @@ return { press = press, compact = compact, mix = mix, - craft = craft + craft = craft, + alloy = alloy, + melt = melt, + saw = saw, + spout = spout, } \ No newline at end of file diff --git a/computer/13/pathfinding.lua b/computer/13/pathfinding.lua index 3bd19f4..1a5aa39 100644 --- a/computer/13/pathfinding.lua +++ b/computer/13/pathfinding.lua @@ -1,7 +1,7 @@ pp = require("cc.pretty").pretty_print -_G.facing = "south" -_G.pos = vector.new(0,0,0) +_G.facing = _G.facing or "south" +_G.pos = _G.pos or vector.new(0,0,0) local up = vector.new(0,1,0) diff --git a/computer/13/recipes.lua b/computer/13/recipes.lua index 2d64c0e..d625c45 100644 --- a/computer/13/recipes.lua +++ b/computer/13/recipes.lua @@ -8,6 +8,7 @@ function read_recipe(file) base = nil intermediate = nil repeats = 1 + yield = 1 while 1 do line = file.readLine() if string.sub(line, 1, 5) == "base " then @@ -16,6 +17,8 @@ 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 + yield = tonumber(string.sub(line, 7)) elseif line == "steps:" then break end @@ -44,6 +47,7 @@ function read_recipe(file) return { product = product, base = base, + yield = yield, intermediate = intermediate or base, repeats = repeats, steps = steps diff --git a/computer/13/recipes.txt b/computer/13/recipes.txt index 3654a1e..69af36e 100644 --- a/computer/13/recipes.txt +++ b/computer/13/recipes.txt @@ -177,6 +177,78 @@ steps: deploy rubber deploy copper_sheet +redrouter_block +steps: +craft andesite_alloy redstone_torch andesite_alloy redstone_torch monitor_normal redstone_torch andesite_alloy redstone_torch andesite_alloy + +monitor_normal +steps: +craft andesite_alloy andesite_alloy andesite_alloy andesite_alloy glass_pane andesite_alloy andesite_alloy andesite_alloy andesite_alloy + +torch +yield 4 +steps: +craft charcoal nil nil stick + kelp steps: mix water kelp bone_meal:2 + +electron_tube +base polished_rose_quartz +steps: +spout molten_rose_gold:111 + +molten_rose_gold +steps: +alloy molten_copper molten_gold + +molten_copper +yield 111 +base copper_ingot +steps: +melt + +molten_gold +yield 111 +base gold_ingot +steps: +melt + +cow_jar +base milk_jar +steps: +deploy beef +deploy leather +spout blood:100 + +beef +base seitan +intermediate protobeef +steps: +deploy moss_carpet +spout blood:100 +press +saw + +seitan +base dough +repeat 2 +steps: +spout water:100 +press +saw + +dough +steps: +mix wheat_flour water:1000 + +wheat_flour +steps: +mill wheat + +blood +yield 50 +base rotten_flesh +steps: +melt diff --git a/computer/13/test.lua b/computer/13/test.lua new file mode 100644 index 0000000..3860de3 --- /dev/null +++ b/computer/13/test.lua @@ -0,0 +1,12 @@ +function bar() + error("mmm", 4) +end + +function foo() + bar() +end + +while true do +foo() + -- error("aaaaa") +end diff --git a/computer/13/work.lua b/computer/13/work.lua index ff103ac..c278086 100644 --- a/computer/13/work.lua +++ b/computer/13/work.lua @@ -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() - diff --git a/computer/4/build.lua b/computer/4/build.lua index 6bbb42d..0a1f97e 100644 --- a/computer/4/build.lua +++ b/computer/4/build.lua @@ -2,7 +2,8 @@ sf = require("structure") local pf = require("pathfinding") local im = require("inventorymanager") local origin = vector.new(-15,235,120) -function build(x,y,z) +function build(chunk) + local x,y,z = stringtovec(chunk) store = {height = 0} grocerylist = {} for h = 1,8 do @@ -28,13 +29,13 @@ function build(x,y,z) end if store.height==0 then --print("cell at",x,y,z,"is done") - removechunk(x,y,z) return true end flag = false + count = im.countinventory() for k,v in pairs(grocerylist) do - if im.count(k) < v then + if (count[k] or -1) < v then print("not enough "..k.." need "..v.." of it") flag = true end @@ -49,11 +50,9 @@ function build(x,y,z) return false end pf.to(origin + vector.new(x+1,y+8,z+1)) - for h = 1,8 do - print(store[h].width) - for w = 1,store[h].width do - print(store[h][w].depth) - for d = 1,store[h][w].depth do + for w = 1,8 do + for h = 1,8 do + for d = 1,8 do if store[h][w][d] then pf.to(origin+vector.new(x+w,y+h,z+d)) im.select(store[h][w][d]) @@ -62,55 +61,23 @@ function build(x,y,z) end end end - removechunk(x,y,z) return true end -function removechunk(x,y,z) - - --::success:: - local file = fs.open("tobuild","r") - local rest = {} - line = file.readLine() - while line do - table.insert(rest,line) - line = file.readLine() - end - file.close() - file = fs.open("tobuild","w") - str = tostring(vector.new(x,y,z)) - for _,v in ipairs(rest) do - if v ~= str then - file.writeLine(v) - end - end - file.close() -end function stringtovec(str) parts = {} for part in string.gmatch(str, "([^,]+)") do - table.insert(parts, part) + table.insert(parts, tonumber(part)) end - return vector.new(unpack(parts)) -end ---pf.to(origin) -file=fs.open("tobuild","r") -chunk = file.readLine() -file.close() -print(chunk) -vec = stringtovec(chunk) -X1,Y1,Z1 = vec.x,vec.y,vec.z -print(X1,Y1,Z1) -while build(X1,Y1,Z1) do --- term.clear() - print(X1,Y1,Z1) - file = fs.open("tobuild","r") - chunk = file.readLine() - vec = stringtovec(chunk) - X1,Y1,Z1 = vec.x,vec.y,vec.z - file.close() - --term.clear() - sleep(0) + return unpack(parts) end + +repeat + rednet.send(1,nil,"getnexttobuild") + _,chunk = rednet.receive("nexttobuild") +until not build(chunk) + +rednet.send(1,chunk,"failedtobuild") + pf.returnHome() diff --git a/computer/4/copyfile.lua b/computer/4/copyfile.lua deleted file mode 100644 index 216705b..0000000 --- a/computer/4/copyfile.lua +++ /dev/null @@ -1,13 +0,0 @@ -file = fs.open("tobuild","w") -while true do - id,message = rednet.receive() - if id == 3 then - if message=="done" then - file.close() - return - else - print(message) - file.writeLine(message) - end - end -end diff --git a/computer/4/inventorymanager.lua b/computer/4/inventorymanager.lua index 2656f8e..5ae3504 100644 --- a/computer/4/inventorymanager.lua +++ b/computer/4/inventorymanager.lua @@ -21,6 +21,29 @@ function count(name) end return value end +function countinventory() + counts = {} + for i = 1,16 do + item = turtle.getItemDetail(i) + if item then + if item.name == "packages:package" then + turtle.select(i) + turtle.placeUp() + sleep(0.1) + for i,item2 in pairs(peripheral.call("top","list")) do + write(item2.name,item2.count) + counts[item2.name] = + (counts[item2.name] or 0) + + item2.count + print(counts[item2.name]) + end + turtle.digUp() + else + counts[item.name] = counts[item.name] or 0 + item.count + end end + end + return counts +end function select(name) local flag = false for i = 1,16 do @@ -86,4 +109,4 @@ function pull(name, slot) return error("there is no '"..name.."' in my inventory") end -return {pull=pull,count=count,select=select} +return {pull=pull,count=count,select=select,countinventory = countinventory} diff --git a/computer/4/pathfinding.lua b/computer/4/pathfinding.lua index dbc3ac0..c0ed19f 100644 --- a/computer/4/pathfinding.lua +++ b/computer/4/pathfinding.lua @@ -1,4 +1,4 @@ -home = vector.new(-250, 96, 106) +home = vector.new(-1, 186, 126) up = vector.new(0,1,0) south = vector.new(0,0,1) east = vector.new(1,0,0) diff --git a/computer/4/pathfinding2.lua b/computer/4/pathfinding2.lua index 9ce56c6..95e8348 100644 --- a/computer/4/pathfinding2.lua +++ b/computer/4/pathfinding2.lua @@ -21,6 +21,11 @@ function greedystep(target) _G.position = position + facing return true end + elseif vec:dot(facing) < 0 then + if turtle.back() then + _G.position = position - facing + return true + end end if vec:dot(facing:cross(up)) > 0 then turtle.turnRight() diff --git a/computer/4/startup.lua b/computer/4/startup.lua index 3a4daef..7224ac4 100644 --- a/computer/4/startup.lua +++ b/computer/4/startup.lua @@ -1,23 +1,84 @@ -_G.position = vector.new(-250,96,106) +_G.position = vector.new(-1,186,126) _G.facing = vector.new(-1,0,0) rednet.open("left") -old_print = _G.print -new_print = function(...) +--old_print = _G.print +--[[new_print = function(...) x = "" for i,v in ipairs(arg) do x = x..tostring(v).." " end old_print(x) rednet.broadcast(x) -end +end]] --_G.print = new_print -rednet.host("tomfoolery",os.computerLabel()) +--rednet.host("tomfoolery",os.computerLabel()) --while true do -if not _G.thing or true then - _G.thing = true +function append(tbl,value) + table.insert(tbl,value) + return tbl +end +rednet.host("tomfoolery",os.getComputerLabel()) +queue = {} +history = {} +if true then parallel.waitForAll( - function() while true do read() end end, - function() shell.run("felling") end, - function() while true do id,message = rednet.receive() print(message) end end + function() + while true do + --print("reading") + while running do + coroutine.yield() + end + write( + shell.dir().."> " + ) + table.insert( + queue, + append( + history, + not running and read( + nil, + history, + shell.complete + ) + )[#history] + ) + sleep(0.05)--coroutine.yield() + end + end, + function() + while true do + --print("attempting to run shell on :"..(queue[1] or "")) + running = true + shell.run( + table.remove( + queue, + 1 + ) + ) + running = false + --term.clear() + for i,v in pairs(queue) do + --print(v) + end + sleep(0.05) + end + end, + function() + while true do + --print("recieving") + id,mess,kind = rednet.receive() + if kind == "complete" then + rednet.send(id,shell.complete(mess),"completed") + elseif kind == "run" then + print("recieved") + print(id, mess, kind) + table.insert(queue,mess) + sleep(0.05) + else + + end + end + end ) end +rednet.receive() diff --git a/computer/5/startup.lua b/computer/5/startup.lua index 35bb202..2350f51 100644 --- a/computer/5/startup.lua +++ b/computer/5/startup.lua @@ -1,3 +1,44 @@ rednet.open("back") -shell.run("report") ---parallel.waitForAny(func1,func2) +completion = require("cc.completion") +local function splitprefixes(str,prefixes) + for i,v in ipairs(prefixes) do + if string.sub(str,1,string.len(v[2])) == v[2] then + return v[2],string.sub(str,string.len(v[2])+2,string.len(str)),v[1] + end + end +end +while true do + thing = read( nil, nil, + function(str) + copy = require("rednetcopy") + turts = copy.lookup("tomfoolery") + turtlenames = {} + --print(turts) + for i,v in pairs( + turts + ) do + table.insert(turtlenames,v[2]) + end + choices = completion.choice(str,turtlenames) + --print(#choices) + if #choices > 0 then + return choices + end + + + name,sub,id = splitprefixes(str,turts) + --print(name,sub,id) + --print(sub) + if not id then return end + rednet.send(id,sub,"complete") + _,message = rednet.receive("completed",0.2) + return message + end + ) + turts = copy.lookup("tomfoolery") + name, sub,id = splitprefixes(thing,turts) + rednet.send(id,sub,"run") +end +--shell.run("report") + + --parallel.waitForAny(func1,func2) diff --git a/ids.json b/ids.json index e019a96..59f0513 100644 --- a/ids.json +++ b/ids.json @@ -1,4 +1,4 @@ { - "computer": 15, - "disk": 1 + "computer": 17, + "disk": 2 } \ No newline at end of file