Transition.to within a Loop HELP!!! DESPERATE FOR HELP!!!

i do not know what is wrong here im at my whits end. it has taken me a long time to get all this together and i just cannot make it work. please help. modify it and reply it suggest problems. anything laugh at me for doing this in a crap way.

i wanna use the loop to get each item name out of a table, then u want to use transition.to to send the main actor to the item, then continue on to the next one. HELP PLES!!!

much appreciated.

HERE IS THE CODE

local physics = require("physics")  
physics.start()  
physics.setGravity( 0, 0)  
physics.setDrawMode( "hybrid" )  
  
local background = display.newRect(0,0,320,480)  
background:setFillColor(255,50,0)  
local Yaxis = display.newLine(160,0,160,480)  
local Xaxis = display.newLine(0,240,320,240)  
  
-- 4 nodes 1 in each corner type thing  
  
--node Top Left  
  
local tlNode = display.newRect(60,100,20,20)  
  
--node top right  
  
local trNode = display.newRect(240,100,20,20)  
  
--node bottom Left  
  
local blNode = display.newRect(60,400,20,20)  
  
--node bottom right  
  
local brNode = display.newRect(240,400,20,20)  
  
-- new nodes to be used in my dynamic follow the points function  
  
local Node1 = display.newRect(60,350,20,20)  
local Node2 = display.newRect(110,400,20,20)  
-- create the Seeker  
  
local seeker = display.newImage("arrow.png")  
  
physics.addBody( seeker, "static")  
  
seeker.isSensor = true  
  
local seekertail = display.newCircle(60, 20, 10)  
  
physics.addBody( seekertail, "dynamic")  
  
seekertail.isSensor = true  
  
local tail = physics.newJoint( "pivot", seekertail, seeker, seeker.x, seeker.y)  
local loop = 1  
local called = 1  
local name  
local travels = {}  
  
table.insert(travels, "tlNode")  
table.insert(travels, "trNode")  
table.insert(travels, "brNode")  
table.insert(travels, "blNode")  
  
local function driveThePoints()  
while loop \<= #travels do  
if loop == #travels then  
  
name = travels[called]  
  
local mover = function()  
print("mover number "..called.." called, MOVE TO "..name)  
nxtnum = called + 1  
name = travels[nxtnum]  
called = called + 1  
end  
timer.performWithDelay(loop \* 2000 - 2000, mover, 1)  
print("transition.to( seeker, {delay="..loop \* 2000 - 2000 ..",time= 2000, x="..travels[loop]..".x, y="..travels[loop]..".y, onComplete=driveThePoints})")  
print("will now start again")  
  
else  
name = travels[called]  
  
mover = function()  
print("mover number "..called.." called, MOVE TO "..name)  
print("transition.to( seeker, {time= 2000, x="..travels[called]..".x, y="..travels[called]..".y})")  
transition.to( seeker, {time= 1000, x=travels[called].x, y=travels[called].y})  
nxtnum = called + 1  
name = travels[nxtnum]  
called = called + 1  
end  
timer.performWithDelay(loop \* 2000 - 2000, mover, 1)  
  
print("will travel to : "..travels[loop])  
print("transition.to( seeker, {delay="..loop \* 2000 - 2000 ..",time= 1000, x="..travels[loop]..".x, y="..travels[loop]..".y})")  
print("then travels to ...")  
end  
loop = loop + 1  
end  
  
end  
  
driveThePoints()  

[import]uid: 66719 topic_id: 15189 reply_id: 315189[/import]

Problem solved guys hahahahaha im an idiot.

[code]

local physics = require(“physics”)
physics.start()
physics.setGravity( 0, 0)
physics.setDrawMode( “hybrid” )

local background = display.newRect(0,0,320,480)
background:setFillColor(255,50,0)
local Yaxis = display.newLine(160,0,160,480)
local Xaxis = display.newLine(0,240,320,240)

– 4 nodes 1 in each corner type thing

–node Top Left

local tlNode = display.newRect(60,100,20,20)

–node top right

local trNode = display.newRect(240,100,20,20)

–node bottom Left

local blNode = display.newRect(60,400,20,20)

–node bottom right

local brNode = display.newRect(240,400,20,20)

– new nodes to be used in my dynamic follow the points function

local Node1 = display.newRect(60,350,20,20)
local Node2 = display.newRect(110,400,20,20)
– create the Seeker

local seeker = display.newImage(“arrow.png”)

physics.addBody( seeker, “static”)

seeker.isSensor = true

local loop = 1
local called = 1
local name
local travelsx = {}
local travelsy = {}
local again1 = 1

travelsx[1] = tlNode.x
travelsx[2] = trNode.x
travelsx[3] = brNode.x
travelsx[4] = blNode.x

travelsy[1] = tlNode.y
travelsy[2] = trNode.y
travelsy[3] = brNode.y
travelsy[4] = blNode.y

local start = 1

local function finished()
print(“called the function that finishes the loop”)
timer.performWithDelay(1,start,1)
end

local function driveThePoints()
while loop <= #travelsx + 1 do
if loop == #travelsx + 1 then

name = travelsx[called]

local mover = function()
print("mover number “…called…” called, MOVE TO ")

transition.to( seeker, {time= 2000, x=travelsx[called], y=travelsy[called], onComplete=finished})
end
timer.performWithDelay(loop * 2000, mover, 1)
print(“will now start again”)

else
name = travelsx[called]

mover = function()
print(“mover number “…called…” called, MOVE TO “…name)
print(“transition.to( seeker, {time= 2000, x=”…travelsx[called]…”, y=”…travelsy[called]…"})")
transition.to( seeker, {time= 2000, x=travelsx[called], y=travelsy[called]})
nxtnum = called + 1
name = travelsx[nxtnum]
called = called + 1
end
timer.performWithDelay(loop * 2000, mover, 1)

print(“will travel to : “…travelsx[loop])
print(“transition.to( seeker, {delay=”…loop * 2000 - 2000 …”,time= 1000, x=”…travelsx[loop]…", y="…travelsy[loop]…"})")
print(“then travels to …”)
end
loop = loop + 1
end

end

driveThePoints()

start = function()
print(“START CALLED”)
loop = 1
called = 1
name = 1
driveThePoints()
print(“drive the points called again”)
end

–lets make the seeker move around the screen infinitely

–step 1 make it shift to the TL node
–[[
local SKRTL = nil

local function seekertoBL()
seeker:rotate( 90 )
transition.to( seeker, {time=1000, x=blNode.x, y=blNode.y, onComplete=SKRTL})
end

local function seekertoBR()
seeker:rotate( 90 )
transition.to( seeker, {time=2000, x=brNode.x, y=brNode.y, onComplete=seekertoBL})
end

local function seekertoTR()
seeker:rotate( 90 )
transition.to( seeker, {time=1000, x=trNode.x, y=trNode.y, onComplete=seekertoBR})
end

local function seekertoTL()
seeker:rotate( 90 )
transition.to( seeker, {time=2000, x=tlNode.x, y=tlNode.y, onComplete=seekertoTR})
end

seekertoTL()

SKRTL = seekertoTL

]]–

[code] [import]uid: 66719 topic_id: 15189 reply_id: 56161[/import]

You’re not an idiot - and well done on solving it.

I panicked when I saw the thread title :wink: [import]uid: 52491 topic_id: 15189 reply_id: 56259[/import]