Skip to content

Accessing Game Info

Thomas edited this page Apr 13, 2022 · 3 revisions

Accessing Game Info

This page details how you can access the game info that's exposed by the API.

The No Mans Sky API exposes a lot of information about the game to C# code. Examples include Player Health, Units, Quicksilver, etc. Any info related to the game in general, like whether or not we've loaded into the actual game or if we're still on the main menu, can be accessed from the Game Instance. Information about the player, like their Health, Exosuit, or current Ship, can be accessed from the Player Instance. Things are organized based on how they actually are within the game.

Even though things are separated based on how they appear within the game, all of this info is linked to the game instance in your code. This can be accessed in 2 ways. The first and easiest way is by using a Mod class that inherits NMSMod. If you are using the NoMansSky.ModTemplate then this is already available to you. Inside of the constructor for Mod.cs, right around this line, you can type Game to get access to it. Alternatively, if you are working on a bigger mod with multiple classes, you can access the game instance by typing IGame.Instance. Both of these methods offer access to the same game instance and they exist to support different use cases for mods.

If you wanted to access the Player instance, you could do it from your NMSMod class by typing Player, or you can access it from the Game Instance by typing IGame.Instance.Player. This trend continues for all important things. With that said not all info is accessible directly from your NMSMod class. For example, the player's health is only accessible from the Player instance. You can't do Health or PlayerHealth within your NMSMod and instead you must do Player.Health. So while all of the most important things are easily accessible in your NMSMod, some things must be accessed from their corresponding instances.

Important instances

Below are the current instances supported by the API. All of these instances can be accessed from both IGame.Instance as well as from the NMSMod base class. Each of them also contains relevant info about the instance, for example the Player instance contains info about Health, Units, Nanites, etc as well as containing the reference to the Exosuit.

  • IGame.Instance
  • IGame.Instance.Player
  • IGame.Instance.Player.Exosuit
  • IGame.Instance.Player.ActiveShip
  • IGame.Instance.Player.ActiveMultiTool
Clone this wiki locally