Posted 21 December 2012 - 03:04 PM
Hey guys. I'm getting the error
I looked at line 69 and could not for the life of me find out what was wrong.
Here's the code:
And line 69:
Any input?
bios:338: [string "elevatorHost"]:69: syntax error
I looked at line 69 and could not for the life of me find out what was wrong.
Here's the code:
Spoiler
shell.run("openToRednet")
local currentFloor = 0
function recieveClientInfo()
local elevatorType = false
while not elevatorType do
event, ID, message, distance = os.pullEvent("rednet_message")
elevatorType = ("elevator:" == string.sub(message,1,9))
if elevatorType then
floor = tonumber(string.sub(message,10))
end
end
return ID, floor
end
function getNewFloor(currentFloor, clientInfo)
local newFloor
if currentFloor == 0 then
print("Enter desired floor: ")
parallel.waitForAny(
function()
local validFloor = false
while not validFloor do
local tempFloor = shell.run("getFloorSelection")
for i = 1, #clientInfo do
if (tempFloor == tonumber(clientInfo[i])[2]) then
validFloor = true
newFloor = tempFloor
break
end
print("Error 404: Floor not found, please try again.")
end
end
end,
function()
local validFloor = false
while not validFloor do
event, ID, message, distance = os.pullEvent("rednet_message")
for i = 1, #clientInfo do
if (ID == tonumber(clientInfo[i])[2]) then
for i = 1, #clientInfo do
if (message == tonumber((clientInfo[i])[1])) then
validFloor = true
newFloor = message
break
else
rednet.send(ID, "invalid")
end
end
end
end
end
end)
else
print("Press enter to call cart.")
parallel.waitForAny(
function()
local key = -1
while key ~= 28 do
event, key = os.pullEvent("key")
end
newFloor = 0
end,
function()
local validFloor = false
while not validFloor do
event, ID, message, distance,os.pullEvent("rednet_message")
for i = 1, #clientInfo do
if (ID == tonumber(clientInfo[i])[2]) then
for i = 1, #clientInfo do
if (message == tonumber((clientInfo[i])[1])) then
validFloor = true
newFloor = message
break
else
rednet.send(ID, "invalid")
end
end
end
end
end
end)
return newFloor
end
local allRecieved = false
local clientInfo = {}
while not allRecieved do
parallel.waitForAny(
function()
ID, floor = recieveClientInfo()
end,
function()
sleep(5)
ID = -1
end)
if ID ~= -1 then
rednet.send(ID, "confirmed")
table.insert(clientInfo,{ID, floor})
else
allRecieved = true
end
end
rs.setOutput("left",true)
print("Linked to all clients.")
for i = 1, #clientInfo do
print("ID: " .. tostring((clientInfo[i])[1]) .. ", floor: " .. tostring((clientInfo[i])[2]))
end
repeat
local newFloor = getNewFloor(currentFloor, clientInfo)
if newFloor == 0 then
--doNothing
else
local newFloorID
for i = 1, #clientInfo do
if ((clientInfo[i])[2] == newFloor) then
newFloorID = (clientInfo[i])[1]
break
end
end
rednet.send(newFloorID, "accept")
end
if currentFloor == 0 then
rs.setOutput("left", false)
sleep(1)
rs.setOutput("left", true)
else
local currentFloorID
for i = 1, #clientInfo do
if ((clientInfo[i])[2] == currentFloor) then
currentFloorID = (clientInfo[i])[1]
break
end
end
rednet.send(currentFloorID, "launch")
end
currentFloor = newFloor
until false
And line 69:
for i = 1, #clientInfo do
Any input?