Module Navigator

Utilities and data relating to wilderness map navigation, both on land and sea.

Basic navigation

findWaypoint (targetWaypoint) Finds bearing and distance to waypoint from current location.
getPointBearings (_originX, _originY, _targetX, _targetY) Returns the bearing to target coordinates from origin coordinates.
getChebyshevDistance (originX, originY, targetX, targetY) Returns the Chebyshev distance between two points.
getNearestHarbours (numReturns) Locates an arbitrary number of the nearest harbours.
getWaypointTable () Returns a copy of the full waypoint table.
calculateMovementSpeed () Something to do with movement speed.

Getters/setters

getEasting () Returns the player's current easting.
getSouthing () Returns the player's current southing.
getError () Returns the player's current CEP.
setEasting (input) Sets the player's current easting.
setSouthing (input) Sets the player's current southing.
setError (input) Sets the player's current CEP.

Location status

aboardShip () Returns true if user is aboard a ship.
havePosition () Returns true if Navigator has a valid position set.
inSubdivision () Returns true if user is in a subdivision.
inWildernessMap () Returns true if user is in the wilderness map.
onSeafloor () Returns true if user is in in a seafloor area.

Conversions

cardinalToHeading (_cardinalDirection) Converts a cardinal-direction string to heading in degrees.
roomNumToCoords (_roomNum) Converts standard three-parameter ATP coordinates to screen coordinates.

Auto-calibration

adjustCoords (_dirMoved, _inputEasting, _inputSouthing) Returns current coordinates adjusted for input direction.
autoCal (inputEasting, inputSouthing) Doesn't actually autocalibrate, just takes in stuff to pass to self variables.
buildSearchTable (doFullSearch) Populates searchTable with the relevant rows of text, before we begin finding candidates.
checkCandidates (locationCandidates, shipColumn) It checks candidates?
doShipAutocal () Old autocal
findLineDelta () Finds nearest Δ candidate in Navigator.currentMap.
gatherCandidates (searchString) Gathers the candidates for our line.
getSearchHeight () Gets search height.
doINSmove () Feed our last movement direction to the INS routine.
isInOpenSeas () See if all the lines of our map are blank spaces, to see if we even have any sort of landmarks.
trimLocationCandidates (inputTable, distanceLimit) This finds things.
updateINS () Old INS stuff.

Sailplan stuff

isAtDestination () Returns true if current position matches destination position.
steerpointNext () Next steerpoint.
steerpointPrevious () Previous steerpoint.

Autopilot

autopilot Container for autopilot functionality
checkAlignment () These do things, I guess.
waypointTurn () These do things, I guess.

Maps and map readers

maps Container for maps
Navigator.maps.full Full world map as a table.
Navigator.maps.current The last map sent to us by the game.
isOurShip () True if = under the cursor is our ship, as determined by text colour.
isSeamonster () True if M under cursor is a seamonster, as determined by the text colour.
isTargetShip () True if = under the cursor is our ship, as determined by text colour.


Basic navigation

findWaypoint (targetWaypoint) line 43
Finds bearing and distance to waypoint from current location.

Parameters:

  • targetWaypoint string Shortname of the waypoint to located.

Returns:

  1. float Bearing to waypoint in degrees.
  2. int Chebyshev distance to waypoint.
getPointBearings (_originX, _originY, _targetX, _targetY) line 66
Returns the bearing to target coordinates from origin coordinates.

Parameters:

  • _originX int Origin point X-coordinate.
  • _originY int Origin point Y-coordinate.
  • _targetX int Target point X-coordinate.
  • _targetY int Target point Y-coordinate.

Returns:

    float Bearing to target coordinate in degrees.

Usage:

    local bearing = myNavigator.getPointBearings(  418,443 , 553,221 )
getChebyshevDistance (originX, originY, targetX, targetY) line 127
Returns the Chebyshev distance between two points. Does not account for impassable seas or obstacles.

Parameters:

  • originX int Origin point X-coordinate.
  • originY int Origin point Y-coordinate.
  • targetX int Target point X-coordinate.
  • targetY int Target point Y-coordinate.

Returns:

    int Chebyshev distance to target point.

Usage:

    local distance = myNavigator.getChebyshevDistance(374,804,447,878)
getNearestHarbours (numReturns) line 142
Locates an arbitrary number of the nearest harbours. Gathers the name, distance, and bearings of the nearest harbours, and organises them for further processing. Limited in number of returns by numReturns.

Parameters:

  • numReturns int The number of nearest harbours to return results for, after sorting.

Returns:

    table Indexed table containing information for the numReturns nearest harbours, sorted by ascending distance..

Usage:

    local nearestHarbour = myNavigator.getNearestHarbours(1)[1]
getWaypointTable () line 172
Returns a copy of the full waypoint table.

Returns:

    table A full copy of the master Navigator.waypoints table.

Usage:

    for k,v in pairs(myNavigator.getWaypointTable()) do echo(v.name.."\n") end
calculateMovementSpeed () line 178
Something to do with movement speed.

Getters/setters

For creating and initialising Navigator object.
getEasting () line 226
Returns the player's current easting.

Returns:

    int Current Navigator easting.
getSouthing () line 233
Returns the player's current southing.

Returns:

    int Current Navigator southing.
getError () line 240
Returns the player's current CEP.

Returns:

    int Current Navigator CEP.
setEasting (input) line 248
Sets the player's current easting.

Parameters:

  • input int New Navigator easting.

Usage:

    myNavigator.setEasting(261)
setSouthing (input) line 257
Sets the player's current southing.

Parameters:

  • input int New Navigator southing.

Usage:

    myNavigator.setSouthing(729)
setError (input) line 266
Sets the player's current CEP.

Parameters:

  • input int New Navigator CEP.

Usage:

    myNavigator.setError(2)

Location status

aboardShip () line 286
Returns true if user is aboard a ship. Does its best to avoid false positives, such as ferries, using a table of failure states as its metric.

Returns:

    bool Whether user is aboard a ship.

See also:

Usage:

    if myNavigator.aboardShip() then...
havePosition () line 311
Returns true if Navigator has a valid position set.

Returns:

    bool True, if valid position set.

Usage:

    if myNavigator.havePosition() then...
inSubdivision () line 321
Returns true if user is in a subdivision.

Returns:

    bool True, if in subdivision.

Usage:

    if myNavigator.inSubdivision() then...
inWildernessMap () line 338
Returns true if user is in the wilderness map. Does not count being aboard a vessel as being in the wilderness map.

Returns:

    bool True, if in subdivision.

See also:

Usage:

    if myNavigator.aboardShip() then...
onSeafloor () line 351
Returns true if user is in in a seafloor area. Useful to keep us from zeroing out data when we don't actually want to.

Returns:

    bool True, if in seafloor area.

See also:

Usage:

    if myNavigator.onSeafloor() then...

Conversions

cardinalToHeading (_cardinalDirection) line 380
Converts a cardinal-direction string to heading in degrees.

Parameters:

  • _cardinalDirection string Direction (e.g. "north", "e", "south-southwest", "ene")

Returns:

    float Heading in degrees
roomNumToCoords (_roomNum) line 413
Converts standard three-parameter ATP coordinates to screen coordinates. Used in setting our position when we have a wilderness room number.

Parameters:

  • _roomNum int The room number we wish to convert.

Returns:

  1. int Easting in screen coordinates.
  2. int Southing in screen coordinates.

Auto-calibration

adjustCoords (_dirMoved, _inputEasting, _inputSouthing) line 476
Returns current coordinates adjusted for input direction. Also invoked by Figurehead for wavecall.

Parameters:

  • _dirMoved string Short-form direction string.
  • _inputEasting int Current Navigator easting.
  • _inputSouthing int Current Navigator southing.

Returns:

  1. int Adjusted easting.
  2. int Adjusted southing.

Usage:

    myNavigator.adjustCoords("n",625,715)
autoCal (inputEasting, inputSouthing) line 523
Doesn't actually autocalibrate, just takes in stuff to pass to self variables.

Parameters:

  • inputEasting int New easting to set.
  • inputSouthing int New southing to set.
buildSearchTable (doFullSearch) line 548
Populates searchTable with the relevant rows of text, before we begin finding candidates.

Parameters:

  • doFullSearch bool True, to search the entire map for candidates. False if building a limited array to search through.
checkCandidates (locationCandidates, shipColumn) line 574
It checks candidates?

Parameters:

  • locationCandidates
  • shipColumn
doShipAutocal () line 657
Old autocal
findLineDelta () line 767
Finds nearest Δ candidate in Navigator.currentMap.

Returns:

  1. string Contents of the line containing the located reference. Used in later steps to verify location candidates, before heading into confidence calculations.
  2. int Latitudinal distance from the central calibration point, Δ. Negative values are north.

Usage:

    local locatorString, lineDelta = myNavigator.findLineDelta()
gatherCandidates (searchString) line 820
Gathers the candidates for our line.

Parameters:

  • searchString string Map line to gather candidates for.
getSearchHeight () line 843
Gets search height.
doINSmove () line 854
Feed our last movement direction to the INS routine. Adjusts current Navigator coords acordingly.
isInOpenSeas () line 862
See if all the lines of our map are blank spaces, to see if we even have any sort of landmarks.
trimLocationCandidates (inputTable, distanceLimit) line 877
This finds things. allegedly, not great though

Parameters:

  • inputTable what.
  • distanceLimit what.
updateINS () line 901
Old INS stuff.

Sailplan stuff

isAtDestination () line 1037
Returns true if current position matches destination position.

Returns:

    bool True if at destination position.
steerpointNext () line 1056
Next steerpoint.
steerpointPrevious () line 1071
Previous steerpoint.

Autopilot

autopilot line 1142
Container for autopilot functionality

Fields:

  • _autopilotEnabled If autopilot is enabled
  • _stoppedToTurn If autopilot is stopped for purposes of turning
checkAlignment () line 1150
These do things, I guess. Yep. I guess.
waypointTurn () line 1167
These do things, I guess. Yep. I guess.

Maps and map readers

maps line 1261
Container for maps
Navigator.maps.full line 1265
Full world map as a table. Table indices are 1 higher than their actual coordinate value!
Navigator.maps.current line 1289
The last map sent to us by the game.

Usage:

     {
       "nnnnnnnnnn....wwwwww     ",
       "nnnnnnnnn.....wwwwwww    ",
       "nnnnnnnn.......wwwwww    ",
       "++++++++++++++.w.www     ",
       "nnnnnn.........wwwww     ",
       "nnnnnn..........ww       ",
       "nnnnn..........ww        ",
       "nnnnn.........ww         ",
       "nnnnn.......=            ",
       "nnnnn.........ww         ",
       "nnnnn..........www       ",
       "nnnnn.......wwwwww       ",
       "nnnnn......wwwwww        ",
       "nnnnnn.....www;www       ",
       "nnnnnnn...wwwwwwwww      ",
       "nnnnnnnn..wwwwwwwww      ",
       "nnnnnnnn..wwwwwwww       "
     }
isOurShip () line 1294
True if = under the cursor is our ship, as determined by text colour.
isSeamonster () line 1308
True if M under cursor is a seamonster, as determined by the text colour.
isTargetShip () line 1322
True if = under the cursor is our ship, as determined by text colour.
generated by LDoc 1.4.3 Last updated 2021-01-24 20:08:44