I have a function that creates a number of tables, sort of like tiles, that you specify, and gives each one a separate ‘x’, ‘y’, ‘xRef’ and ‘yRef’. Now, I want to be able to make an object go to a ‘tile’ with this: [lua]obj:position(2, 1)[/lua]. What I have happening is making it look through each ‘tile’ and find if the xRef and yRef equal the two numbers you specify. Then it sets the obj.x and y to that tile’s x and y. I’m sure, though, that there’s a better way. I made it so you use the function [lua]makeGrids(3, 3)[/lua], and that makes it 3 by 3. It builds the ‘tiles’ left to right, up to down, with a [lua]for i=1, rows do[/lua] loop. Inside the loop it builds each column. So the tiles are in number like this:
1 2 3
4 5 6
7 8 9
If there were some way with math to find the tile’s number (1-9) instead of comparing it with the xRef and yRef, that’s what I’m asking for. Then I could just set it to that tile’s x and y instead of looking through each one.
quinc [import]uid: 147322 topic_id: 29870 reply_id: 329870[/import]