robot debug

This commit is contained in:
Redo
2022-10-28 15:53:09 -06:00
parent d768193275
commit b463fd3dfe
5 changed files with 27 additions and 6 deletions

View File

@@ -7,13 +7,16 @@ local function intToPort(gate, port, len, v)
end
return function(gate, argv)
print("robot input")
print(argv[1])
for word in argv[1]:gmatch("[^\t]+") do
local first, rest = word:sub(1, 1), word:sub(2, #word)
local vec = {}
for a in rest:gmatch("[^ ]+") do table.insert(vec, tonumber(a) or error("invalid number "..a)) end
if first=="P" then -- set position
assert(#vec==3, "invalid position given to robot: "..word)
brick.robotpos = vec
assert(#vec==4, "invalid position given to robot: "..word)
brick.robotpos = {vec[1], vec[2], vec[3]}
brick.robotdir = vec[4]
elseif first=="B" then -- detected brick info
assert(#vec==7, "invalid brick info given to robot: "..word)
gate.brickexists = vec[1]