Space Engineers

Space Engineers

Not enough ratings
GPS Ingame Scripting API
   
Award
Favorite
Favorited
Unfavorite
Type: Mod
Mod category: Script
File Size
Posted
Updated
370.631 KB
17 Jan, 2018 @ 3:32pm
3 Nov, 2023 @ 11:27am
14 Change Notes ( view )

Subscribe to download
GPS Ingame Scripting API

Description
To enable persistence and multiplayer, server-side GPS markers are used instead of local GPS markers. If you constantly hear the sound for a new GPS marker, it is because your script is still using the old variant (delete everything, and recreate). With this update it is possible to move GPS markers without deleting them.

This mod allows you to create Gps markers. The created (non-persistent) markers can be moved and deleted.


Requirements
  • An antenna must be installed on the grid, or you must control it.
  • The antenna, the block whose custom data field is used (hereinafter referred to as custom data block), as well as the programmable block must be functional.
  • You must be able to access the antenna, the custom data block and the programmable block.

Functionality

The mod reads the custom data field of the custom data block. Through certain instructions, Gps markers (created by this mod!) can be created, edited and deleted.
For easier use there are two C# classes that simplify this part:

GPSInterface (old): Old class, updated with the new functionality (backwards compatible).
GPSInterfaceV2: New variant, easier to use (breaking changes).
GPSInterfaceV3: Updated to use only a part of the custom data field, so that other things in can be stored there as well (see workshop page for more information)


Bugs, Issues, Suggestions

Feel free to report any problems.


Todos

Change 'antenna on grid' condition to 'grid accessible via antenna network' (for realism and balancing) Won't change anymore
22 Comments
Ikarus_Sol_314  [author] 3 Nov, 2023 @ 12:00pm 
The mod is updated and a new version for the example script is available . The mod will delete the section used for the interface, so it's best to test it first and see if it works as you expect
Ikarus_Sol_314  [author] 26 Oct, 2023 @ 8:44am 
That would be possible, but then you could only use the ini format and not json for example. I use the custom data field as interface between script and mod. So far it worked like this, but since multiple scripts can be executed from one block, there are probably problems here (the mod itself is a bit older, but still works). I will have a look at this in the near future
H3PO 22 Oct, 2023 @ 6:52am 
Hi Ikarus, is there any way to have other content inside the PB's CustomData other than the lines required by your script? Maybe you can add an ini parser on the mod side to only use a section marked [gpsapi]?
Ikarus_Sol_314  [author] 9 Jul, 2023 @ 10:53am 
Yes this is possible. This mod allows scripts to create GPS markers. The event controller can execute a script in a programmable block and thereby create a GPS marker.
A simple script that creates a new marker every time it is executed could look like this:


[code]
private readonly GPSInterfaceV2 gps;

public Program()
{
gps = new GPSInterfaceV2(Me);
}

void Main()
{
gps.Update();
gps.AddGps("Test", Me.GetPosition());
}

// Here you have to paste the code from https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2559461462 from the "GPSInterfaceV2 - Source" section

[/code]


If you don't want to create a new marker every time, but just move the marker, you have to extend the script
Rulin 8 Jul, 2023 @ 1:35am 
Scripting noob here. Can I use this to let the new event controller, triggered by altitude, create a new gps coordinate? If yes, how?
kamilmomot 18 Jan, 2022 @ 12:17am 
Hello.
I very big potential in this script.
It would be great to have gps waypoint, attachet to connector on ship(some distance of the fornt of it) to make it fully operational with remote control.
Ikarus_Sol_314  [author] 28 Jul, 2021 @ 6:20am 
I updated the mod and moved the code that is responsible for the GPS markers to the server. This allows multiplayer and also moving GPS markers.
There is now also a function to get all GPS positions created by this block.
If it is not too much effort to adjust the code I recommend to use the new GPSInterfaceV2 in ingame scripts.
Seyha 11 Jul, 2021 @ 2:23pm 
That's would be awesome... Looking forward.
Best regards.
Ikarus_Sol_314  [author] 11 Jul, 2021 @ 5:27am 
Unfortunately no.

I made this mod over 3 years ago. At that time it was meant as a proof of concept to give ingame scripts the possibilities of mods, so it is kept relatively simple. (No persistence, no multiplayer)

I will have another look at the mod, maybe it's time to improve it a bit and add new features. (Like for example methods to get all GPS positions, or to change them)
Seyha 5 Jul, 2021 @ 4:40am 
Heya, is there is a way to Edit GPS not to always clear and add?
And someway to get coords from existing gps?