Compare commits
No commits in common. "ad6af0fa358bc5328a6113712a27020f40b3c8b1" and "c78597a8fb82c816a24c3cb22afc81020e09d841" have entirely different histories.
ad6af0fa35
...
c78597a8fb
27 changed files with 334 additions and 755 deletions
|
@ -50,6 +50,6 @@ while true do
|
||||||
sleep(random(1,4))
|
sleep(random(1,4))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
parallel.waitForAll(sound,sound,sound,sound,sound)
|
--parallel.waitForAll(sound,sound,sound,sound,sound)
|
||||||
peripheral.call("top","turnOn")
|
peripheral.call("top","turnOn")
|
||||||
-- os.reboot()
|
-- os.reboot()
|
||||||
|
|
55
computer/11/test.txt
Normal file
55
computer/11/test.txt
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>something silly - index</title>
|
||||||
|
<link rel="stylesheet" href="/style.css">
|
||||||
|
<link rel="icon" type="image/x-icon" href="/creacher.png">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<h1 id="meow">meow</h1>
|
||||||
|
<p>
|
||||||
|
hello i might write some words here from time to time<br>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a href="/">this</a> <a href="https://git.crispypin.cc/CrispyPin/blug">website</a> is running on my own <a href="https://git.crispypin.cc/CrispyPin/webserver">webserver</a> and generated with my <a href="https://git.crispypin.cc/CrispyPin/htmd">static site builder</a><br>
|
||||||
|
this means it is<br>
|
||||||
|
[✓] scuffed<br>
|
||||||
|
[✓] non-compliant<br>
|
||||||
|
[✓] transgener<br>
|
||||||
|
[✔] no tracking or javascipt<br>
|
||||||
|
[✅] silly<br>
|
||||||
|
</p>
|
||||||
|
<h2 id="content">"content"</h2>
|
||||||
|
<p>
|
||||||
|
- <a href="/awful_software/unity-on-linux">unity on linux sucks</a><br>
|
||||||
|
- <a href="/vent/dead-trees">dead trees</a><br>
|
||||||
|
- <a href="/horological-crimes">horological crimes</a><br>
|
||||||
|
- <a href="/snad">snad</a><br>
|
||||||
|
- <a href="/keyboards-are-fun">keyboar</a><br>
|
||||||
|
- <a href="/vent/distracting">distracting</a><br>
|
||||||
|
- <a href="/blender">blender</a><br>
|
||||||
|
- <a href="/old-projects/old-project-list">old projects</a><br>
|
||||||
|
- todo: put more words in the computer<br>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a href="/lists/me">me elsewhere</a> | <a href="/photos">photos</a> | <a href="/portfolio">portfolio</a><br>
|
||||||
|
<a href="/lists/bookmarks">bookmarks</a> | <a href="/lists/music">music</a><br>
|
||||||
|
</p>
|
||||||
|
<div class="flags">
|
||||||
|
<div id="pan"></div><br>
|
||||||
|
<div id="enby"></div><br>
|
||||||
|
<div id="trans"></div><br>
|
||||||
|
<div id="pride"></div><br>
|
||||||
|
<div id="lesbian"></div><br>
|
||||||
|
</div>
|
||||||
|
<a rel="me" href="https://cathode.church/@crispy"></a>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -1 +1 @@
|
||||||
13
|
13
|
|
@ -1,40 +0,0 @@
|
||||||
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,
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -1,172 +0,0 @@
|
||||||
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()
|
|
|
@ -1,21 +0,0 @@
|
||||||
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)
|
|
|
@ -1,17 +1,7 @@
|
||||||
pp = require("cc.pretty").pretty_print
|
pp = require("cc.pretty")
|
||||||
require("fluids")
|
|
||||||
|
|
||||||
function pFront(fn, ...)
|
pFront = peripheral.wrap("front")
|
||||||
return peripheral.call("front", fn, unpack(arg))
|
pDown = peripheral.wrap("bottom")
|
||||||
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)
|
function findItems(item_list, target)
|
||||||
for i, v in pairs(item_list) do
|
for i, v in pairs(item_list) do
|
||||||
|
@ -22,8 +12,31 @@ function findItems(item_list, target)
|
||||||
return nil
|
return nil
|
||||||
end
|
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)
|
function takeItems(type, count)
|
||||||
local item_list = pFront("list")
|
local item_list = pFront.list()
|
||||||
local slot = findItems(item_list, type)
|
local slot = findItems(item_list, type)
|
||||||
|
|
||||||
if slot == nil then
|
if slot == nil then
|
||||||
|
@ -31,19 +44,18 @@ function takeItems(type, count)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if slot ~= 1 then
|
empty_slot = pFront.size()
|
||||||
local empty_slot = pFront("size")
|
-- todo error if not empty
|
||||||
pFront("pullItems", "front", 1, 64, empty_slot) -- empty first slot
|
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", slot, 64, 1) -- get target item to first slot
|
||||||
pFront("pullItems", "front", empty_slot, 64, slot) -- empty last slot for next time
|
pFront.pullItems("front", empty_slot, 64, slot) -- empty last slot for next time
|
||||||
end
|
|
||||||
return turtle.suck(count)
|
return turtle.suck(count)
|
||||||
end
|
end
|
||||||
|
|
||||||
function selectItem(name, has_nbt)
|
function selectItem(name, has_nbt)
|
||||||
has_nbt = has_nbt or false
|
has_nbt = has_nbt or false
|
||||||
if name == nil or name == "nil" then
|
if name == nil or name == "nil" then
|
||||||
for i = 1, 16 do
|
for i = 1,16 do
|
||||||
if turtle.getItemCount(i) == 0 then
|
if turtle.getItemCount(i) == 0 then
|
||||||
turtle.select(i)
|
turtle.select(i)
|
||||||
return
|
return
|
||||||
|
@ -52,7 +64,7 @@ function selectItem(name, has_nbt)
|
||||||
printError("no empty slot found")
|
printError("no empty slot found")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for i = 1, 16 do
|
for i = 1,16 do
|
||||||
detail = turtle.getItemDetail(i, true);
|
detail = turtle.getItemDetail(i, true);
|
||||||
if detail and stripModname(detail.name) == name then
|
if detail and stripModname(detail.name) == name then
|
||||||
if has_nbt == (detail.nbt ~= nil) then
|
if has_nbt == (detail.nbt ~= nil) then
|
||||||
|
@ -66,10 +78,10 @@ end
|
||||||
|
|
||||||
function getMissing(needed_items)
|
function getMissing(needed_items)
|
||||||
missing = {}
|
missing = {}
|
||||||
for name, count in pairs(needed_items) do
|
for name,count in pairs(needed_items) do
|
||||||
missing[name] = count
|
missing[name] = count
|
||||||
end
|
end
|
||||||
target_contents = pFront("list")
|
target_contents = peripheral.call("front", "list")
|
||||||
|
|
||||||
for _, target_item in pairs(target_contents) do
|
for _, target_item in pairs(target_contents) do
|
||||||
for name, missing_count in pairs(missing) do
|
for name, missing_count in pairs(missing) do
|
||||||
|
@ -82,35 +94,7 @@ function getMissing(needed_items)
|
||||||
end
|
end
|
||||||
end
|
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
|
return missing
|
||||||
end
|
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
|
|
||||||
|
|
||||||
|
|
4
computer/13/keep_stocked.lua
Normal file
4
computer/13/keep_stocked.lua
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
keep_stocked = {
|
||||||
|
kelp = 10,
|
||||||
|
flint = 10
|
||||||
|
}
|
|
@ -1,50 +1,8 @@
|
||||||
require("inventory")
|
require("inventory")
|
||||||
require("pathfinding")
|
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)
|
|
||||||
|
|
||||||
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)
|
function mill(extra_items)
|
||||||
goTo(mill_pos,"south")
|
go_to(vector.new(-4,0,0),"south")
|
||||||
item_count = 0
|
item_count = 0
|
||||||
if turtle.getItemCount() ~= 0 then
|
if turtle.getItemCount() ~= 0 then
|
||||||
item_count = 1
|
item_count = 1
|
||||||
|
@ -56,47 +14,36 @@ function mill(extra_items)
|
||||||
insertForward(1, item.count)
|
insertForward(1, item.count)
|
||||||
end
|
end
|
||||||
print(item_count,"items")
|
print(item_count,"items")
|
||||||
while pFront("getItemDetail", 1) do
|
while peripheral.call("front", "getItemDetail", 1) do
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
end
|
end
|
||||||
for i = 2, 10 do
|
for i = 2, 10 do
|
||||||
takeForward(i)
|
takeForward(i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function deploy(extra_items)
|
function deploy(extra_items, nbt)
|
||||||
-- extra_items should only be one item
|
-- extra_items should only be one item
|
||||||
goTo(deployer_pos, "south")
|
go_to(vector.new(2,0,0), "south")
|
||||||
insertDepot(1)
|
insertDepot(1)
|
||||||
goUp()
|
goUp()
|
||||||
goUp()
|
goUp()
|
||||||
selectItem(extra_items[1].name)
|
selectItem(extra_items[1].name, nbt)
|
||||||
turtle.dropUp(1)
|
turtle.dropUp(1)
|
||||||
pFront("pullItem", "top")
|
peripheral.call("front", "pullItem", "top")
|
||||||
|
|
||||||
goDown()
|
goDown()
|
||||||
goDown()
|
goDown()
|
||||||
takeDepot()
|
takeDepot()
|
||||||
end
|
end
|
||||||
function deploy_tool(extra_items)
|
function deploy_tool(extra_items)
|
||||||
-- extra_items should only be one item
|
deploy(extra_items, true)
|
||||||
goTo(deployer_pos, "south")
|
|
||||||
insertDepot(1)
|
|
||||||
goUp()
|
goUp()
|
||||||
goUp()
|
goUp()
|
||||||
selectItem(extra_items[1].name)
|
peripheral.call("front", "pushItem", "top")
|
||||||
turtle.dropUp(1)
|
|
||||||
pFront("pullItem", "top")
|
|
||||||
|
|
||||||
goDown()
|
|
||||||
goDown()
|
|
||||||
takeDepot()
|
|
||||||
goUp()
|
|
||||||
goUp()
|
|
||||||
pFront("pushItem", "top")
|
|
||||||
turtle.suckUp()
|
turtle.suckUp()
|
||||||
end
|
end
|
||||||
function furnace(extra_items)
|
function furnace(extra_items)
|
||||||
goTo(furnace_pos, "south")
|
go_to(vector.new(1,0,0), "south")
|
||||||
item_count = 0
|
item_count = 0
|
||||||
if turtle.getItemCount() ~= 0 then
|
if turtle.getItemCount() ~= 0 then
|
||||||
item_count = 1
|
item_count = 1
|
||||||
|
@ -108,76 +55,20 @@ function furnace(extra_items)
|
||||||
insertForward(1, item.count)
|
insertForward(1, item.count)
|
||||||
end
|
end
|
||||||
wait_time = 10 * item_count
|
wait_time = 10 * item_count
|
||||||
|
-- peripheral.call("front", "")
|
||||||
-- TODO refuel
|
-- TODO refuel
|
||||||
sleep(wait_time)
|
sleep(wait_time)
|
||||||
takeForward(3)
|
takeForward(3)
|
||||||
end
|
end
|
||||||
function press(_)
|
function press(_)
|
||||||
goTo(press_pos, "south")
|
go_to(vector.new(-1,0,0), "south")
|
||||||
insertDepot(1)
|
insertDepot(1)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
takeDepot()
|
takeDepot()
|
||||||
end
|
end
|
||||||
function compact(extra_items)
|
function compact(extra_items) end
|
||||||
printError("unimplemented :3")
|
function mix(extra_items)
|
||||||
sfx.fail()
|
go_to(vector.new(-3,0,0), "south")
|
||||||
end
|
|
||||||
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)
|
insertForward(1, 1)
|
||||||
for _, item in pairs(extra_items) do
|
for _, item in pairs(extra_items) do
|
||||||
selectItem(item.name)
|
selectItem(item.name)
|
||||||
|
@ -190,10 +81,16 @@ function mix(extra_items, product, yield)
|
||||||
sleep(10)
|
sleep(10)
|
||||||
-- todo wait until ingredients are gone
|
-- todo wait until ingredients are gone
|
||||||
takeForward(10)
|
takeForward(10)
|
||||||
-- todo empty fluids
|
|
||||||
end
|
end
|
||||||
function craft(extra_items)
|
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
|
local slot = 0
|
||||||
|
print(len(extra_items), "extra items")
|
||||||
for _, item in pairs(extra_items) do
|
for _, item in pairs(extra_items) do
|
||||||
slot = slot + 1
|
slot = slot + 1
|
||||||
if slot == 4 then
|
if slot == 4 then
|
||||||
|
@ -217,9 +114,5 @@ return {
|
||||||
press = press,
|
press = press,
|
||||||
compact = compact,
|
compact = compact,
|
||||||
mix = mix,
|
mix = mix,
|
||||||
craft = craft,
|
craft = craft
|
||||||
alloy = alloy,
|
|
||||||
melt = melt,
|
|
||||||
saw = saw,
|
|
||||||
spout = spout,
|
|
||||||
}
|
}
|
|
@ -1,13 +0,0 @@
|
||||||
pretty = require("cc.pretty").pretty_print
|
|
||||||
|
|
||||||
require("recipes")
|
|
||||||
sfx = require("sfx")
|
|
||||||
require("pathfinding")
|
|
||||||
require("inventory")
|
|
||||||
|
|
||||||
keep_stocked = {
|
|
||||||
kelp = 10,
|
|
||||||
flint = 10
|
|
||||||
}
|
|
||||||
|
|
||||||
goHome()
|
|
60
computer/13/make_belts.lua
Normal file
60
computer/13/make_belts.lua
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
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")
|
|
@ -1,7 +1,15 @@
|
||||||
pp = require("cc.pretty").pretty_print
|
pp = require("cc.pretty")
|
||||||
|
|
||||||
_G.facing = _G.facing or "south"
|
-- if _G.pos == nil then
|
||||||
_G.pos = _G.pos or vector.new(0,0,0)
|
_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)
|
local up = vector.new(0,1,0)
|
||||||
|
|
||||||
|
@ -26,9 +34,17 @@ local vecOf = {
|
||||||
west = vector.new(-1,0,0),
|
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()
|
function goUp()
|
||||||
if turtle.up() then
|
if turtle.up() then
|
||||||
_G.pos.y = _G.pos.y + 1
|
_G.pos.y = _G.pos.y + 1
|
||||||
|
savePos()
|
||||||
else
|
else
|
||||||
printError("failed to go up")
|
printError("failed to go up")
|
||||||
printError(pos)
|
printError(pos)
|
||||||
|
@ -38,6 +54,7 @@ end
|
||||||
function goDown()
|
function goDown()
|
||||||
if turtle.down() then
|
if turtle.down() then
|
||||||
_G.pos.y = _G.pos.y - 1
|
_G.pos.y = _G.pos.y - 1
|
||||||
|
savePos()
|
||||||
else
|
else
|
||||||
printError("failed to go down")
|
printError("failed to go down")
|
||||||
printError(pos)
|
printError(pos)
|
||||||
|
@ -47,16 +64,19 @@ end
|
||||||
function goLeft()
|
function goLeft()
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
_G.facing = leftOf[_G.facing]
|
_G.facing = leftOf[_G.facing]
|
||||||
|
savePos()
|
||||||
end
|
end
|
||||||
|
|
||||||
function goRight()
|
function goRight()
|
||||||
turtle.turnRight()
|
turtle.turnRight()
|
||||||
_G.facing = rightOf[_G.facing]
|
_G.facing = rightOf[_G.facing]
|
||||||
|
savePos()
|
||||||
end
|
end
|
||||||
|
|
||||||
function goForward()
|
function goForward()
|
||||||
if turtle.forward() then
|
if turtle.forward() then
|
||||||
_G.pos = _G.pos + vecOf[_G.facing]
|
_G.pos = _G.pos + vecOf[_G.facing]
|
||||||
|
savePos()
|
||||||
else
|
else
|
||||||
printError("failed to go forward")
|
printError("failed to go forward")
|
||||||
printError(pos)
|
printError(pos)
|
||||||
|
@ -66,6 +86,7 @@ end
|
||||||
function goBack()
|
function goBack()
|
||||||
if turtle.back() then
|
if turtle.back() then
|
||||||
_G.pos = _G.pos - vecOf[_G.facing]
|
_G.pos = _G.pos - vecOf[_G.facing]
|
||||||
|
savePos()
|
||||||
else
|
else
|
||||||
printError("failed to go backward")
|
printError("failed to go backward")
|
||||||
printError(pos)
|
printError(pos)
|
||||||
|
@ -88,9 +109,10 @@ function stepTo(target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function goTo(target, face)
|
function go_to(target, face)
|
||||||
while target ~= _G.pos do
|
while target ~= _G.pos do
|
||||||
stepTo(target)
|
stepTo(target)
|
||||||
|
-- print(_G.pos, _G.facing)
|
||||||
end
|
end
|
||||||
if face and face ~= _G.facing then
|
if face and face ~= _G.facing then
|
||||||
if rightOf[_G.facing] == face then
|
if rightOf[_G.facing] == face then
|
||||||
|
@ -103,7 +125,3 @@ function goTo(target, face)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function goHome()
|
|
||||||
goTo(vector.new(0,0,0), "south")
|
|
||||||
end
|
|
|
@ -1,4 +1,4 @@
|
||||||
pp = require("cc.pretty").pretty_print
|
pp = require("cc.pretty")
|
||||||
require("stringshit")
|
require("stringshit")
|
||||||
recipes = {}
|
recipes = {}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ function read_recipe(file)
|
||||||
base = nil
|
base = nil
|
||||||
intermediate = nil
|
intermediate = nil
|
||||||
repeats = 1
|
repeats = 1
|
||||||
yield = 1
|
|
||||||
while 1 do
|
while 1 do
|
||||||
line = file.readLine()
|
line = file.readLine()
|
||||||
if string.sub(line, 1, 5) == "base " then
|
if string.sub(line, 1, 5) == "base " then
|
||||||
|
@ -17,8 +16,6 @@ function read_recipe(file)
|
||||||
intermediate = string.sub(line, 14)
|
intermediate = string.sub(line, 14)
|
||||||
elseif string.sub(line, 1, 7) == "repeat " then
|
elseif string.sub(line, 1, 7) == "repeat " then
|
||||||
repeats = tonumber(string.sub(line, 8))
|
repeats = tonumber(string.sub(line, 8))
|
||||||
elseif string.sub(line, 1, 6) == "yield " then
|
|
||||||
yield = tonumber(string.sub(line, 7))
|
|
||||||
elseif line == "steps:" then
|
elseif line == "steps:" then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -47,7 +44,6 @@ function read_recipe(file)
|
||||||
return {
|
return {
|
||||||
product = product,
|
product = product,
|
||||||
base = base,
|
base = base,
|
||||||
yield = yield,
|
|
||||||
intermediate = intermediate or base,
|
intermediate = intermediate or base,
|
||||||
repeats = repeats,
|
repeats = repeats,
|
||||||
steps = steps
|
steps = steps
|
||||||
|
@ -55,17 +51,18 @@ function read_recipe(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
function load_recipes()
|
function load_recipes()
|
||||||
local file = fs.open("recipes.txt", "r")
|
file = fs.open("recipes.txt", "r")
|
||||||
if not file then
|
if not file then
|
||||||
print("error: no recipes found")
|
print("error: no recipes found")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
recipes = {}
|
recipes = {}
|
||||||
while 1 do
|
while 1 do
|
||||||
local r = read_recipe(file)
|
r = read_recipe(file)
|
||||||
if r == nil then break end
|
if r == nil then break end
|
||||||
recipes[r.product] = r
|
recipes[r.product] = r
|
||||||
end
|
end
|
||||||
|
return recipes
|
||||||
end
|
end
|
||||||
|
|
||||||
function ingredientsOf(recipe)
|
function ingredientsOf(recipe)
|
||||||
|
@ -83,6 +80,4 @@ function ingredientsOf(recipe)
|
||||||
items[recipe.base] = (items[recipe.base] or 0) + 1
|
items[recipe.base] = (items[recipe.base] or 0) + 1
|
||||||
end
|
end
|
||||||
return items
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
load_recipes()
|
|
|
@ -160,95 +160,3 @@ craft birch_planks birch_slab birch_planks birch_planks nil birch_planks birch_p
|
||||||
birch_slab
|
birch_slab
|
||||||
steps:
|
steps:
|
||||||
craft birch_planks birch_planks birch_planks
|
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
|
|
||||||
|
|
||||||
copper_casing
|
|
||||||
base andesite_casing
|
|
||||||
intermediate incomplete_copper_casing
|
|
||||||
repeat 3
|
|
||||||
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
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
function splitString(source, sep)
|
function splitString(source, sep)
|
||||||
sep = sep or " "
|
sep = sep or " "
|
||||||
elements = {}
|
elements = {}
|
||||||
|
|
|
@ -1,12 +1,3 @@
|
||||||
function bar()
|
s = require("sfx")
|
||||||
error("mmm", 4)
|
s.success()
|
||||||
end
|
--s.fail()
|
||||||
|
|
||||||
function foo()
|
|
||||||
bar()
|
|
||||||
end
|
|
||||||
|
|
||||||
while true do
|
|
||||||
foo()
|
|
||||||
-- error("aaaaa")
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
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
|
|
|
@ -1,34 +1,29 @@
|
||||||
pp = require("cc.pretty").pretty_print
|
pp = require("cc.pretty")
|
||||||
|
require("keep_stocked")
|
||||||
require("recipes")
|
require("recipes")
|
||||||
sfx = require("sfx")
|
sfx = require("sfx")
|
||||||
require("pathfinding")
|
require("pathfinding")
|
||||||
use_machine = require("machines")
|
use_machine = require("machines")
|
||||||
require("inventory")
|
require("inventory")
|
||||||
|
|
||||||
keep_stocked = {
|
go_to(vector.new(0,0,0), "south")
|
||||||
kelp = 10,
|
recipes = load_recipes()
|
||||||
flint = 10
|
|
||||||
}
|
|
||||||
|
|
||||||
resetAllFluidDevices()
|
|
||||||
goHome()
|
|
||||||
|
|
||||||
print("known recipes:\n")
|
print("known recipes:\n")
|
||||||
for k, _ in pairs(recipes) do
|
for k,_ in pairs(recipes) do
|
||||||
write(k)
|
write(k)
|
||||||
write(", ")
|
write(", ")
|
||||||
end
|
end
|
||||||
write("\nchoose one: ")
|
write("\nchoose one: ")
|
||||||
function completion(partial)
|
function completion(partial)
|
||||||
list = {}
|
list = {}
|
||||||
for k, _ in pairs(recipes) do
|
for k,_ in pairs(recipes) do
|
||||||
if string.sub(k, 1, #partial) == partial then
|
if string.sub(k, 1, #partial) == partial then
|
||||||
table.insert(list, string.sub(k, #partial + 1))
|
table.insert(list, string.sub(k, #partial + 1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
|
|
||||||
input = splitString(read(nil, nil, completion))
|
input = splitString(read(nil, nil, completion))
|
||||||
|
|
||||||
target_product = input[1]
|
target_product = input[1]
|
||||||
|
@ -54,11 +49,11 @@ function doRecipe(recipe)
|
||||||
inited = true
|
inited = true
|
||||||
selectItem(recipe.base, false)
|
selectItem(recipe.base, false)
|
||||||
end
|
end
|
||||||
use_machine[step.machine](step.extra_items, recipe.product, recipe.yield)
|
use_machine[step.machine](step.extra_items)
|
||||||
-- read()
|
-- read()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
goHome()
|
go_to(vector.new(0,0,0), "south")
|
||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
if turtle.getItemCount(i) ~= 0 then
|
if turtle.getItemCount(i) ~= 0 then
|
||||||
turtle.select(i)
|
turtle.select(i)
|
||||||
|
@ -68,9 +63,10 @@ function doRecipe(recipe)
|
||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
work_queue = {}
|
|
||||||
for i = 1, copies do
|
todo = {}
|
||||||
table.insert(work_queue, recipes[target_product])
|
for i = 1,copies do
|
||||||
|
table.insert(todo, recipes[target_product])
|
||||||
end
|
end
|
||||||
|
|
||||||
function listUncraftable(ingredients)
|
function listUncraftable(ingredients)
|
||||||
|
@ -91,35 +87,47 @@ function tryCreating(recipe)
|
||||||
ingredients = ingredientsOf(recipe)
|
ingredients = ingredientsOf(recipe)
|
||||||
missing_ingredients = getMissing(ingredients)
|
missing_ingredients = getMissing(ingredients)
|
||||||
if len(missing_ingredients) == 0 then
|
if len(missing_ingredients) == 0 then
|
||||||
work_queue[#work_queue] = nil
|
todo[#todo] = nil
|
||||||
turtle.select(1)
|
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
|
for item, count in pairs(ingredients) do
|
||||||
takeItems(item, count)
|
takeItems(item, count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
doRecipe(current_recipe)
|
doRecipe(current_recipe)
|
||||||
|
-- for item, min_count in pairs(getMissing(keep_stocked)) do
|
||||||
|
-- table.insert(todo, recipes[item])
|
||||||
|
-- end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
return missing_ingredients
|
return missing_ingredients
|
||||||
end
|
end
|
||||||
|
|
||||||
while #work_queue > 0 do
|
while #todo > 0 do
|
||||||
-- for item, _count in pairs(getMissing(keep_stocked)) do
|
-- for item, _count in pairs(getMissing(keep_stocked)) do
|
||||||
-- print("creating", item, "to keep stock up")
|
-- print("creating", item, "to keep stock up")
|
||||||
-- tryCreating(recipes[item])
|
-- tryCreating(recipes[item])
|
||||||
-- end
|
-- end
|
||||||
current_recipe = work_queue[#work_queue]
|
current_recipe = todo[#todo]
|
||||||
-- ingredients = ingredientsOf(current_recipe)
|
-- ingredients = ingredientsOf(current_recipe)
|
||||||
pp(ingredients)
|
pp.pretty_print(ingredients)
|
||||||
missing_ingredients = tryCreating(current_recipe)
|
missing_ingredients = tryCreating(current_recipe)
|
||||||
if missing_ingredients then
|
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)
|
wait_for = listUncraftable(missing_ingredients)
|
||||||
while len(wait_for) > 0 do
|
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")
|
print("please supply", count, name, "manually")
|
||||||
end
|
end
|
||||||
print("press return to continue, q to quit")
|
print("press return to continue, q to quit")
|
||||||
|
@ -133,10 +141,16 @@ while #work_queue > 0 do
|
||||||
for name, count in pairs(missing_ingredients) do
|
for name, count in pairs(missing_ingredients) do
|
||||||
if recipes[name] then
|
if recipes[name] then
|
||||||
print("first making", count, name)
|
print("first making", count, name)
|
||||||
table.insert(work_queue, recipes[name])
|
-- for i = 1,count do
|
||||||
|
table.insert(todo, recipes[name])
|
||||||
|
-- end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- print("aaa")
|
||||||
|
-- read()
|
||||||
end
|
end
|
||||||
print("done!")
|
print("done!")
|
||||||
sfx.success()
|
sfx.success()
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@ sf = require("structure")
|
||||||
local pf = require("pathfinding")
|
local pf = require("pathfinding")
|
||||||
local im = require("inventorymanager")
|
local im = require("inventorymanager")
|
||||||
local origin = vector.new(-15,235,120)
|
local origin = vector.new(-15,235,120)
|
||||||
function build(chunk)
|
function build(x,y,z)
|
||||||
local x,y,z = stringtovec(chunk)
|
|
||||||
store = {height = 0}
|
store = {height = 0}
|
||||||
grocerylist = {}
|
grocerylist = {}
|
||||||
for h = 1,8 do
|
for h = 1,8 do
|
||||||
|
@ -29,13 +28,13 @@ function build(chunk)
|
||||||
end
|
end
|
||||||
if store.height==0 then
|
if store.height==0 then
|
||||||
--print("cell at",x,y,z,"is done")
|
--print("cell at",x,y,z,"is done")
|
||||||
|
removechunk(x,y,z)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
end
|
end
|
||||||
flag = false
|
flag = false
|
||||||
count = im.countinventory()
|
|
||||||
for k,v in pairs(grocerylist) do
|
for k,v in pairs(grocerylist) do
|
||||||
if (count[k] or -1) < v then
|
if im.count(k) < v then
|
||||||
print("not enough "..k.." need "..v.." of it")
|
print("not enough "..k.." need "..v.." of it")
|
||||||
flag = true
|
flag = true
|
||||||
end
|
end
|
||||||
|
@ -50,9 +49,11 @@ function build(chunk)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
pf.to(origin + vector.new(x+1,y+8,z+1))
|
pf.to(origin + vector.new(x+1,y+8,z+1))
|
||||||
for w = 1,8 do
|
for h = 1,8 do
|
||||||
for h = 1,8 do
|
print(store[h].width)
|
||||||
for d = 1,8 do
|
for w = 1,store[h].width do
|
||||||
|
print(store[h][w].depth)
|
||||||
|
for d = 1,store[h][w].depth do
|
||||||
if store[h][w][d] then
|
if store[h][w][d] then
|
||||||
pf.to(origin+vector.new(x+w,y+h,z+d))
|
pf.to(origin+vector.new(x+w,y+h,z+d))
|
||||||
im.select(store[h][w][d])
|
im.select(store[h][w][d])
|
||||||
|
@ -61,23 +62,55 @@ function build(chunk)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
removechunk(x,y,z)
|
||||||
return true
|
return true
|
||||||
end
|
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)
|
function stringtovec(str)
|
||||||
parts = {}
|
parts = {}
|
||||||
for part in string.gmatch(str, "([^,]+)") do
|
for part in string.gmatch(str, "([^,]+)") do
|
||||||
table.insert(parts, tonumber(part))
|
table.insert(parts, part)
|
||||||
end
|
end
|
||||||
return unpack(parts)
|
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
repeat
|
|
||||||
rednet.send(1,nil,"getnexttobuild")
|
|
||||||
_,chunk = rednet.receive("nexttobuild")
|
|
||||||
until not build(chunk)
|
|
||||||
|
|
||||||
rednet.send(1,chunk,"failedtobuild")
|
|
||||||
|
|
||||||
pf.returnHome()
|
pf.returnHome()
|
||||||
|
|
||||||
|
|
13
computer/4/copyfile.lua
Normal file
13
computer/4/copyfile.lua
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
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
|
|
@ -21,29 +21,6 @@ function count(name)
|
||||||
end
|
end
|
||||||
return value
|
return value
|
||||||
end
|
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)
|
function select(name)
|
||||||
local flag = false
|
local flag = false
|
||||||
for i = 1,16 do
|
for i = 1,16 do
|
||||||
|
@ -109,4 +86,4 @@ function pull(name, slot)
|
||||||
return error("there is no '"..name.."' in my inventory")
|
return error("there is no '"..name.."' in my inventory")
|
||||||
end
|
end
|
||||||
|
|
||||||
return {pull=pull,count=count,select=select,countinventory = countinventory}
|
return {pull=pull,count=count,select=select}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
home = vector.new(-1, 186, 126)
|
home = vector.new(-250, 96, 106)
|
||||||
up = vector.new(0,1,0)
|
up = vector.new(0,1,0)
|
||||||
south = vector.new(0,0,1)
|
south = vector.new(0,0,1)
|
||||||
east = vector.new(1,0,0)
|
east = vector.new(1,0,0)
|
||||||
|
|
|
@ -21,11 +21,6 @@ function greedystep(target)
|
||||||
_G.position = position + facing
|
_G.position = position + facing
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
elseif vec:dot(facing) < 0 then
|
|
||||||
if turtle.back() then
|
|
||||||
_G.position = position - facing
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if vec:dot(facing:cross(up)) > 0 then
|
if vec:dot(facing:cross(up)) > 0 then
|
||||||
turtle.turnRight()
|
turtle.turnRight()
|
||||||
|
|
|
@ -1,84 +1,23 @@
|
||||||
_G.position = vector.new(-1,186,126)
|
_G.position = vector.new(-250,96,106)
|
||||||
_G.facing = vector.new(-1,0,0)
|
_G.facing = vector.new(-1,0,0)
|
||||||
rednet.open("left")
|
rednet.open("left")
|
||||||
--old_print = _G.print
|
old_print = _G.print
|
||||||
--[[new_print = function(...)
|
new_print = function(...)
|
||||||
x = ""
|
x = ""
|
||||||
for i,v in ipairs(arg) do
|
for i,v in ipairs(arg) do
|
||||||
x = x..tostring(v).." "
|
x = x..tostring(v).." "
|
||||||
end
|
end
|
||||||
old_print(x)
|
old_print(x)
|
||||||
rednet.broadcast(x)
|
rednet.broadcast(x)
|
||||||
end]]
|
|
||||||
--_G.print = new_print
|
|
||||||
--rednet.host("tomfoolery",os.computerLabel())
|
|
||||||
--while true do
|
|
||||||
function append(tbl,value)
|
|
||||||
table.insert(tbl,value)
|
|
||||||
return tbl
|
|
||||||
end
|
end
|
||||||
rednet.host("tomfoolery",os.getComputerLabel())
|
--_G.print = new_print
|
||||||
queue = {}
|
rednet.host("tomfoolery",os.computerLabel())
|
||||||
history = {}
|
--while true do
|
||||||
if true then
|
if not _G.thing or true then
|
||||||
|
_G.thing = true
|
||||||
parallel.waitForAll(
|
parallel.waitForAll(
|
||||||
function()
|
function() while true do read() end end,
|
||||||
while true do
|
function() shell.run("felling") end,
|
||||||
--print("reading")
|
function() while true do id,message = rednet.receive() print(message) end end
|
||||||
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
|
end
|
||||||
rednet.receive()
|
|
||||||
|
|
|
@ -1,44 +1,3 @@
|
||||||
rednet.open("back")
|
rednet.open("back")
|
||||||
completion = require("cc.completion")
|
shell.run("report")
|
||||||
local function splitprefixes(str,prefixes)
|
--parallel.waitForAny(func1,func2)
|
||||||
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)
|
|
||||||
|
|
4
ids.json
4
ids.json
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"computer": 17,
|
"computer": 15,
|
||||||
"disk": 2
|
"disk": 1
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue