Lua PathFinder: Difference between revisions

From Spring
Jump to navigationJump to search
No edit summary
Line 18: Line 18:
     [3] = startIdxOfDetailedEstimatedPath2,
     [3] = startIdxOfDetailedEstimatedPath2,
   }
   }
  <font color="#55ee99">GetEstimatedPath() returns 2 tables:
<font color="#55ee99">GetEstimatedPath() returns 2 tables: 1 table with the waypoints and 1 table with 3 indices (in the waypoint table) when a new (more lazy) pathfinding algorithm  begins. So the waypoint table contains 3 different levels of details.</font>
    1 table with the waypoints and 1 table with 3 indices (in the waypoint table)
    when a new (more lazy) pathfinding algorithm  begins.
    So the waypoint table contains 3 different levels of details.</font>


'''Path:Next'''
'''Path:Next'''
Line 27: Line 24:
     [, number radius = 0 ]
     [, number radius = 0 ]
   ) -> nil | number x, number y, number z
   ) -> nil | number x, number y, number z
<font color="#55ee99">Path:Next() returns the next waypoint in the path.  Unlike GetEstimatedPath() in which the resolution of the waypoints decreases, Next updates the path so the resolution will increase as it approaches the target.</font>


Note that ''Path'' in ''Path:GetEstimatedPath'' and ''Path:Next'' is not part of the command, but rather a reference to the path Object created by ''Spring.RequestPath''.  It must match the path Object (case sensitive).
Note that ''Path'' in ''Path:GetEstimatedPath'' and ''Path:Next'' is not part of the command, but rather a reference to the path Object created by ''Spring.RequestPath''.  It must match the path Object (case sensitive).


[[category: Lua]]
[[category: Lua]]

Revision as of 23:55, 30 April 2010

Development < Lua Scripting < Lua PathFinder

PathFinder

Spring.RequestPath

 ( string "MoveTypeName" | number moveID,
   number start_x, number start_y, number start_z,
   number end_x,   number end_y,   number end_z
   [, number radius = 8 ]
 ) -> nil | pathObject path (see below)

Path UserData Object

Path:GetEstimatedPath

 ( ) -> nil | {
    [1] = { x,y,z }, ...
  },{
    [1] = startIdxOfDetailedPath,
    [2] = startIdxOfDetailedEstimatedPath1,
    [3] = startIdxOfDetailedEstimatedPath2,
  }

GetEstimatedPath() returns 2 tables: 1 table with the waypoints and 1 table with 3 indices (in the waypoint table) when a new (more lazy) pathfinding algorithm begins. So the waypoint table contains 3 different levels of details.

Path:Next

 ( number pos_x, number pos_y, number pos_z,
   [, number radius = 0 ]
 ) -> nil | number x, number y, number z

Path:Next() returns the next waypoint in the path. Unlike GetEstimatedPath() in which the resolution of the waypoints decreases, Next updates the path so the resolution will increase as it approaches the target.

Note that Path in Path:GetEstimatedPath and Path:Next is not part of the command, but rather a reference to the path Object created by Spring.RequestPath. It must match the path Object (case sensitive).