[SCRIPT] GPS - a navigation and positioning system

  • UPDATE: A version of this script as Java plug-in using the new plug-in API is available here. I suggest to use it instead of this older version.
    ___________


    This is my first attempt at a script of some complexity. I hope it will be useful: tests, suggestions, comments and criticisms are welcome.


    Version 0.1 - Features


    *) Displays current player heading as a standard navigation route and position in 'standard' geographic coordinates (N E) and block altitude:

    Note that internal RW positive W longitude is converted into a more common positive E longitude.


    *) Define a Home position and display radial, side (to the left or to the right of the player) and distance to it:


    *) Define up to 9 waypoints and display radial, side and distance to any of them in turn:


    *) Teleport to home and to any defined waypoint. Teleporting to waypoints can be disabled for servers which do not like players popping up everywhere. In fact, it is disabled by default; edit allowTpToWaypoints = false at the begining of gps.lua into allowTpToWaypoints = true to enable.


    *) The scripts comes with English UI. However, UI tetxts are all grouped in a single file (messages.lua) to make translations easier.


    Commands


    /gpstoggles whole GPS display on/off
    /gps onturns whole GPS display on
    /gps offturns whole GPS display off
    /gps sethomeset home position to current position
    /gps showhometoggles home data display on/off
    /gps setwp [n] [name]sets n-th waypoint with name 'name' (both index and name are optional)
    /gps showwp <n>turns waypoint display on with n-th waypoint (n=0 to turn off)
    /gps listlists defined waypoints (incl. home)
    /gps home teleports to home (if defined)
    /gps goto <n> teleports to n-th waypoint (if defined and enabled)
    /gps helpdisplays a help summary
    /homesame as '/gps home' (for compatibility)
    /sethomesame as '/gps sethome' (for compatibility)



    Installation


    Extract the files in the ZIP placing the whole GPS folder into the scripts folder of RW.


    Open points and known issues


    *) The script uses a database relative to the script itself not to the world; this makes it less suited to single-player multi-world contexts, as the positions of home and waypoints will be common to all worlds. However, I am reluctant to pollute the world database with extraneous data.


    *) When the player first appears in the world, his/her heading is displayed as 000°; the value changes to the correct radial as soon as the player moves. This depends on how data are filled by RW and there is little I can do about


    *) If the player changes of heading without actually moving, particularly while flying, RW does not always notify the script which cannot update the displayed heading. The heading is updated as soon as the player moves.


    Enjoy! M.


    EDIT: the originally attached ZIP file contained an already filled database. Users which downloaded it are advised to re-download and re-install it. The old ZIP can be identified because it has no version numbers at the end of the name. Thanks.

  • @Miwarre I'm having a problem with the commands. They aren't working. I tried the following 1.) Tilde- to bring up the menu and typed /gps nothing happened so I tried the other commands again I got the same result of "Unknown Command" So I tried it again without the / again nothing. At this point I'm confused. The GPS looks great but why are the commands not working? If I'm doing something wrong please help me to understand. Thank you for your time :)

  • As with many (most? all?) scripts, commands are issued in the CHAT, not in the CONSOLE!


    Open the chat, type the command(s) with its initial '/' and parameters as needed and press [Enter] to execute, as if you were telling something in the chat.


    To open the chaT, the default key is [T]

    Okay :) My mistake. When I read over your report of how the mod worked I presumed entering the commands meant opening the console. Thank you for helping me to rectify my mistake.

  • @Miwarre I turned on allowTpToWaypoints to true and restarted my server and now the server can't start. I get an error while loading the server.


    Help...

  • As soon as I'll be at my dev machine, I'll try to reproduce the error.


    As as first indication, I would guess that by editing the file, it has been corrupted somehow: there isn't and there shouldn't be a character 239 in line 1 of gps.lua.


    However, as character 239 may be part of an UTF-8 BOM, I suspect you saved it with some text editor which added to the text some encoding of its own. The file has to be pure text.

  • As soon as I'll be at my dev machine, I'll try to reproduce the error.


    As as first indication, I would guess that by editing the file, it has been corrupted somehow: there isn't and there shouldn't be a character 239 in line 1 of gps.lua.


    However, as character 239 may be part of an UTF-8 BOM, I suspect you saved it with some text editor which added to the text some encoding of its own. The file has to be pure text.

    I fixed it, yes you were right, the error was due to using Windows Notepad to edit the file which used ANSI encoding. I edited using Notepad++ and it worked like a charm. Thanks for the help.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!