lah30303Join Date: 2008-02-15 Post Count: 10027 |
http://www.roblox.com/Working-on-pathfinding-item?id=22333228
Right now it's only a very basic version. I'm going to be working on it to make it much faster and easy to use.
Right now it requires a 2 dimensional table, there are several ways to make one, I like to make it like this so I can really see what it looks like
Table = {
{1,1,1,0,1,1,1},
{1,1,0,0,1,1,1},
{1,1,0,1,1,1,1},
{1,0,0,1,1,1,1},
{1,0,1,1,1,1,1},
{1,0,0,0,0,0,0}}
Please note that the above is just an example of what a map made out of a table would look like. The 0's are walkable areas, and the 1's are "walls" (or just bottomless pits if you want to think imaginatively :3).
After creating that, you run the pathfinding functions like this..
for i, v in pairs(CalcPath(CalcMoves(Table, 4, 1, 7, 6))) do print(v["x"], v["y"]) end
'woah, what?!'
Really all you need to look at is this:
CalcMoves(Table, 4, 1, 7, 6)
The 4 and the 1 are the starting x and y spots. If you look at the table I made (just know that y is increasing as it goes down, not up, so it starts with 1 at the top), 4, 1 is at the top, with 4 going accross and y going down.
The 7, 6 works the same way, except it is the targed spot on the map to get to.
Now, useing what I said before:
for i, v in pairs(CalcPath(CalcMoves(Table, 4, 1, 7, 6))) do print(v["x"], v["y"]) end
The output will look like this:
4 1
4 2
3 2
3 3
3 4
2 4
2 5
2 6
3 6
4 6
5 6
6 6
7 6 |