Skip to content

Expose Waypoint data to lua

As I'm currently working on a custom SPB type item for a mod, it has turned out quite difficult to actually make it follow the track While I have replicated the pathfinding and waypoints, the scripts end up being quite massive. Additionally I can't imagine a lua based solution performing well on servers.

The clean solution to this would be exposing the following functions

  • K_GetWaypointIsShortcut
  • K_GetWaypointIsEnabled
  • K_GetClosestWaypointToMobj
  • K_GetBestWaypointForMobj
  • K_GetSpecialUFOWaypoint
  • K_PathfindToWaypoint (the path could be returned as array of waypoints in this)

The waypoint userdata itself only really needs to expose its mobj, and the arrays of next and previous waypoints (the number of these can be implemented via the length # operator)

Infact k_waypoint.h claims most of the functions would be available to lua