Commit fec3d739 authored by Jacob Piela's avatar Jacob Piela
Browse files

working command queue

parent 14ec266f
if not setup then
--Settings
mainRobot = true
onBoot = ""
useChat = true
speed = 14
safetyOn = true
......@@ -43,13 +44,13 @@ if not setup then
copyCords = function(cord)
return {x = cord.x,y = cord.y,z = cord.z}
end
deque = {}
dequeStart = 1
dequeEnd = 1
runit = function(obj)
if running == false then
action = obj
deque[dequeEnd] = obj
dequeEnd = dequeEnd + 1
running = true
else
sayit(string.concat({owner, ": Please wait"}))
end
end
setblock = function(pos, fill)
if safetyOn then
......@@ -91,8 +92,8 @@ if not setup then
if y > 10 then
y = constraine(y,10,-10)
end
if y > 10 then
y = constraine(y,10,-10)
if z > 10 then
z = constraine(z,10,-10)
end
return {x=x+spos.x, y=y+spos.y, z=z+spos.z}
end
......@@ -130,7 +131,6 @@ if not setup then
bookpos = 1
running = false
paused = false
action = nil
owner = read_text.down("owner") --Find name of robot owner
if not rom.pos1 or not rom.pos2 then
rom.pos1 = {x=0,y=0,z=0}
......@@ -300,8 +300,14 @@ if msg and speaker == owner then
end
end
if not paused and running then
action.data = action.action(action.data)
if not paused then
if deque[dequeStart] ~= nil then
deque[dequeStart].data = deque[dequeStart].action(deque[dequeStart].data)
if running == false then
deque[dequeStart] = nil
dequeStart = dequeStart + 1
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment