This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Chain99's profile picture

Help with Nav program

Started by Chain99, 22 June 2014 - 02:52 AM
Chain99 #1
Posted 22 June 2014 - 04:54 AM
Hi all,
I hate to ask but I am simply dumbfounded as to why this program is not working.
The error it gives me is [string "nav"]:20: unexpected symbol.
Sincerely, Chain

Post Script: Thanks in advance!
Post Post Script: oh yeah here is the code http://pastebin.com/ve9B54zV

if not fs.exists("position") then
local pos={0,0,0}
print("false")
file.create("position",pos) end
pos=file.read("position")
x=pos[1]
y=pos[2]
z=pos[3]
print("true")
print("I am at |x:",x,"|y:",y,"|z:",z)
facing={"north","south","east","west"}
if not fs.exists("direction") then
file.create("direction","north") end
way=file.read("direction")

function turn(direction,count)
counter=0
repeat
counter=counter+1
if direction == "right" and if way ~= "north" and if way ~= "south" then
countDirection=1
turtle.turnRight()
end
if direction=="left" and if way~= "north" and if way ~= "south" then
countDirection=-1
turtle.turnLeft()
end
until counter==#count
end

I forgot to include my file api :http://pastebin.com/erXji62P

function create(fileName,data)
  local file=fs.open(fileName,"w")
  file.write(textutils.serialize(data))
  file.close()
end

function read(fileName)
  local file = fs.open(fileName,"r")
  local data = file.readAll()
  file.close()
  return textutils.unserialize(data)
end
Bomb Bloke #2
Posted 22 June 2014 - 04:55 AM
if direction == "right" and way ~= "north" and way ~= "south" then
Chain99 #3
Posted 22 June 2014 - 05:07 AM
Thanks! Man I feel like an idiot.
Bomb Bloke #4
Posted 22 June 2014 - 05:09 AM
You're not the first, you won't be the last.