Quote: "it breaks out of the loop"
Hmmm, i think your coding is a bit dodgy then... lol... (I don't mean to be harsh, it was a joke...)
Where you have;
if ny#=1 then t=numberoftiles+1
I am assuming that is where you are meant to be brakeing from the loop?
If so ( i may be wrong in my assumption again here ), that will not work...
Ok... here is the lengthy explination that i wrote out, which is indeed completely wrong... lol:
#### Start incorrect explination ####
What the For...Next Loop does, is it takes the variable, gives a value equal to the starting value that you provide ( in your case, the variable is
t and the value is
1 ).
It then goes through the code to the next Loop command ( in this case,
Next ), using that variable the entire way through it...
Once it hits that Next Loop command, the "read head" ( the part of the code that is being executed ) returns to the last For command that was read.
When it get's to this command, it incriments the variable by a value of one, checks to see if it exceedes the limit value of your
To command ( in your case the limit is equal to the value of
numberoftiles ), and if it does, it skips the code untill after the Next command, and continues from there.
If it doesn't exceed the value of the limit you asigned then it does the loop again...
Where you have assigned the variable t = numberoftiles + 1 , the For...Next Command will ignore that when it comes time to incriment the value of t for the next loop, it will incriment t compared to the last value it was incrimented to at the start of the loop.
#### End incorrect explination ####
Ok, to hopefuly fix your problem.. change this:
for t=1 to numberoftiles
xt#=tile#(t,1)
yt#=tile#(t,2)
h#=tile#(t,4)
w#=tile#(t,3)
und#=(yt#+h#/2)-.5
lnd#=(xt#-w#/2)+.25
dnd#=(yt#-h#/2)+.5
rnd#=(xt#+w#/2)-.25
ny#=y_normal#(lx#,rx#,fy#,hy#,und#,dnd#,xt#,yt#,h#,w#)
if ny#=1 then t=numberoftiles+1
next t
To this:
for t=1 to numberoftiles
xt#=tile#(t,1)
yt#=tile#(t,2)
h#=tile#(t,4)
w#=tile#(t,3)
und#=(yt#+h#/2)-.5
lnd#=(xt#-w#/2)+.25
dnd#=(yt#-h#/2)+.5
rnd#=(xt#+w#/2)-.25
ny#=y_normal#(lx#,rx#,fy#,hy#,und#,dnd#,xt#,yt#,h#,w#)
if ny#=1 then exit
next t
Hope I Helped...

Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy