Changes

Jump to navigation Jump to search
→‎Context: add new context values
Line 59: Line 59:     
===Context===
 
===Context===
The <tt>Context</tt> class provides information about the game state and player control:
+
The <tt>Context</tt> class provides information about the game state and player control.
   −
{| class="wikitable"
+
; Game/player state&#58;
 +
: {| class="wikitable"
 
|-
 
|-
 
! value
 
! value
Line 77: Line 78:  
| <tt>Context.CanPlayerMove</tt>
 
| <tt>Context.CanPlayerMove</tt>
 
| Whether <tt>Context.IsPlayerFree</tt> and the player is free to move (e.g. not using a tool).
 
| Whether <tt>Context.IsPlayerFree</tt> and the player is free to move (e.g. not using a tool).
 +
|-
 +
| <tt>Context.IsInDrawLoop</tt>
 +
| Whether the game is currently running the draw loop. This isn't relevant to most mods, since you should use [[Modding:Modder Guide/APIs/Events|display events]] to draw to the screen.
 +
|}
 +
 +
; [[Multiplayer]]&#58;
 +
: {| class="wikitable"
 +
|-
 +
! value
 +
! meaning
 
|-
 
|-
 
| <tt>Context.IsMultiplayer</tt>
 
| <tt>Context.IsMultiplayer</tt>
| Whether <tt>Context.IsWorldReady</tt>, and the player loaded the save in multiplayer mode (regardless of whether any other players are connected).
+
| Whether <tt>Context.IsWorldReady</tt>, and the world was loaded in multiplayer mode (regardless of whether any other players are connected) or is currently in split-screen mode.
 +
|-
 +
| <tt>Context.IsSplitScreen</tt>
 +
| Whether <tt>Context.IsMultiplayer</tt> and the ''current player'' is in split-screen mode. This doesn't apply for remote players.
 +
|-
 +
| <tt>Context.HasRemotePlayers</tt>
 +
| Whether <tt>Context.IsMultiplayer</tt> and any players are connected over the network.
 
|-
 
|-
 
| <tt>Context.IsMainPlayer</tt>
 
| <tt>Context.IsMainPlayer</tt>
 
| Whether <tt>Context.IsWorldReady</tt>, and the player is the main player. This is always true in single-player, and true when hosting in multiplayer.
 
| Whether <tt>Context.IsWorldReady</tt>, and the player is the main player. This is always true in single-player, and true when hosting in multiplayer.
 +
|-
 +
| <tt>Context.IsOnHostComputer</tt>
 +
| Whether the current player is on the host computer. This is true when <tt>Context.IsMainPlayer</tt>, or for farmhands in split-screen mode.
 +
|-
 +
| <tt>Context.ScreenId</tt>
 +
| The unique ID of the current screen in split-screen mode. The main player always has ID 0. A screen is always assigned a new ID when it's opened (so a player who quits and rejoins will get a new screen ID).
 
|}
 
|}
  
translators
8,445

edits

Navigation menu