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

Problem in pathfinding program

Started by tenshae, 01 November 2014 - 07:03 PM
tenshae #1
Posted 01 November 2014 - 08:03 PM
I'm getting the error

"multiple points"

when running my program. I know this means it's a number with more than one decimal point, but I can't figure out where.
Here's my code:


print("b1")
world = {}
world.myx = 0
world.myy = 0
world.mydir = "+y"
function mysplit(inputstr, sep)
	    if sep == nil then
			    sep = "%s"
	    end
	    local t={} ; i=1
	    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
			    t[i] = str
			    i = i + 1
	    end
	    return t
end
print("b2")
function world.turnleft()
print("b3")
turtle.turnLeft()
if world.mydir == "+y" then
  world.mydir = "+x"
elseif world.mydir == "-y" then
  world.mydir = "-x"
elseif world.mydir == "+x" then
  world.mydir = "-y"
elseif world.mydir == "-x" then
  world.mydir = "+y"
end
print("facing "..world.mydir)
end
function world.update()
print("world.update()")
local icur = world.myx..","..world.myy
print("current relative position: "..icur)
world[icur] = {}
world[icur].isSolid = false
world[icur].visited = true
if world.mydir == "+y" then
  local ifront = world.myx..","..world.myy+1
elseif world.mydir == "-y" then
  local ifront = world.myx..","..world.myy-1
elseif world.mydir == "+x" then
  local ifront = world.myx+1..","..world.myy
elseif world.mydir == "-x"
  local ifront = world.myx-1..","..world.myy
end
print("b3.5")
world[ifront] = {}
if turtle.detect() then
  world[ifront].isSolid = true
else
  world[ifront].isSolid = false
end
world[ifront].visited = false
if world.mydir == "+y" then
  local iback = world.myx..","..world.myy-1
elseif world.mydir == "-y" then
  local iback = world.myx..","..world.myy+1
elseif world.mydir == "+x" then
  local iback = world.myx-1..","..world.myy
elseif world.mydir == "-x" then
  local iback = world.myx+1..","..world.myy
end
world.turnleft()
world.turnleft()
if turtle.detect() then
  world[iback].isSolid = true
else
  world[iback].isSolid = false
end
world.turnleft()
world.turnleft()
world[iback].visited = false
end
world.update()
print(unpack(world))
print("ok")

Any ideas?
MKlegoman357 #2
Posted 01 November 2014 - 08:44 PM
Maybe here:


elseif world.mydir == "+x" then
  local ifront = world.myx+1..","..world.myy <-- # here
elseif world.mydir == "-x"
  local ifront = world.myx-1..","..world.myy <-- # and here

Try putting a space between those dots and numbers.

EDIT: By the way, this makes two variables:


local t={} ; i=1

…a local variable t and a global variable i. If you meant i to be local then use a comma to separate it:


local t, i = {}, 1
Edited on 01 November 2014 - 07:47 PM
Evil_Bengt #3
Posted 06 November 2014 - 07:29 AM
If it isn't already solved, post the full error msg or atleast on which line it is….
Would be happy to help…
:D/>
Exerro #4
Posted 06 November 2014 - 09:56 AM
That error is caused by the Lua interpretter thinking you're trying to do something like 1.2.3, which is of course impossible. In your code, as MKlegoman357 pointed out, those two lines have a number, followed by a dot (making Lua think it's a decimal) followed by another dot, which makes no sense.
Putting a space between the number and the two dots will work, or putting a tostring() around the number bit i.e.

tostring( world.myx + 1 ) .. [everything else]
would also work.