Changes

Jump to navigation Jump to search
m
Text replacement - "''e.g.''," to "''e.g.,''"
Line 84: Line 84:  
Notes:
 
Notes:
 
* You can't call <samp>GetApi</samp> until all mods are initialised and their <samp>Entry</samp> methods called. You can use the <samp>GameLoop.GameLaunched</samp> [[#Events|event]] if you need to access mod APIs early; this is guaranteed to happen after all mods are initialised.
 
* You can't call <samp>GetApi</samp> until all mods are initialised and their <samp>Entry</samp> methods called. You can use the <samp>GameLoop.GameLaunched</samp> [[#Events|event]] if you need to access mod APIs early; this is guaranteed to happen after all mods are initialised.
* You should always null-check APIs you consume. <samp>GetApi</samp> will return <samp>null</samp> if the API isn't available (''e.g.'', because the mod isn't already installed or doesn't have one), or if an error occurs fetching the API.
+
* You should always null-check APIs you consume. <samp>GetApi</samp> will return <samp>null</samp> if the API isn't available (''e.g.,'' because the mod isn't already installed or doesn't have one), or if an error occurs fetching the API.
    
===Known limitations===
 
===Known limitations===
 
* When providing an API, the interface and implementation must be public.
 
* When providing an API, the interface and implementation must be public.
* When mapping an API to a custom interface using <samp>GetApi&lt;T&gt;</samp> (i.e. not using the mod's original interface), only the API interface itself can be proxied. Method return values and parameters must be types that both mods have access to (''e.g.'', built-in types like <samp>bool</samp>, SMAPI types like <samp>IManifest</samp>, or game types like <samp>GameLocation</samp>).
+
* When mapping an API to a custom interface using <samp>GetApi&lt;T&gt;</samp> (i.e. not using the mod's original interface), only the API interface itself can be proxied. Method return values and parameters must be types that both mods have access to (''e.g.,'' built-in types like <samp>bool</samp>, SMAPI types like <samp>IManifest</samp>, or game types like <samp>GameLocation</samp>).
    
==Message sending==
 
==Message sending==
You can send messages using [[Modding:Modder Guide/APIs/Multiplayer|the multiplayer API]], with a destination ranging from very narrow (''e.g.'', one mod on one connected computer) to very broad (all mods on all computers). Messages can also be sent to the current computer, ''e.g.'',to communicate between two mods. This can be used for a variety of integrations.
+
You can send messages using [[Modding:Modder Guide/APIs/Multiplayer|the multiplayer API]], with a destination ranging from very narrow (''e.g.,'' one mod on one connected computer) to very broad (all mods on all computers). Messages can also be sent to the current computer, ''e.g.,''to communicate between two mods. This can be used for a variety of integrations.
    
For example:
 
For example:
 
* Request something from a host mod. (Tractor Mod uses this to summon a tractor to the current player in multiplayer, even if the tractor isn't in a location synced to that player.)
 
* Request something from a host mod. (Tractor Mod uses this to summon a tractor to the current player in multiplayer, even if the tractor isn't in a location synced to that player.)
 
* Notify another mod about something. (Chests Anywhere uses this to notify Automate when a chest's automation options are edited.)
 
* Notify another mod about something. (Chests Anywhere uses this to notify Automate when a chest's automation options are edited.)
105,662

edits

Navigation menu