44 lines
1.3 KiB
Lua
44 lines
1.3 KiB
Lua
rednet.open("back")
|
|
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 false 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")
|
|
_,messages = rednet.receive("completed",0.2)
|
|
return messages
|
|
end
|
|
)
|
|
turts = copy.lookup("tomfoolery")
|
|
name, sub,id = splitprefixes(thing,turts)
|
|
rednet.send(id,sub,"run")
|
|
end
|
|
--shell.run("report")
|
|
|
|
--parallel.waitForAny(func1,func2)
|