84 lines
2.2 KiB
Text
84 lines
2.2 KiB
Text
_G.position = vector.new(-250,96,106)
|
|
_G.facing = vector.new(-1,0,0)
|
|
rednet.open("left")
|
|
--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]]
|
|
--_G.print = new_print
|
|
--rednet.host("tomfoolery",os.computerLabel())
|
|
--while true do
|
|
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
|
|
--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()
|