Changes

Jump to navigation Jump to search
→‎Custom map areas: add documentation
Line 347: Line 347:     
==Custom map areas==
 
==Custom map areas==
<span style="color: red;">'''TODO'''</span>
+
[[File:Modding map area.png|thumb|The valley map, with one map area highlighted.]]
 +
 
 +
You can now add/edit areas on the game menu's map UI by editing the new <samp>Data/InGameMap</samp> asset. For example, this is used to show a different farm on the map depending on the current [[Farm Maps|farm type]].
 +
 
 +
===Concepts===
 +
The game divides the map into three concepts:
 +
 
 +
* A '''map''' is one full world area rendered in one image, like the entire image shown at right.
 +
* A '''map area''' is a smaller section of the map which is linked to one or more in-game areas. The map area might be edited/swapped depending on the context, have its own tooltip(s), or have its own player marker positions. For example, the highlighted area on the image shown at right is swapped depending on the current [[Farm Maps|farm type]].
 +
* A '''group name''' is a unique key shared between all the map areas that are rendered on the same map. For example, if there was a separate map for [[Ginger Island]], all the map areas in the valley group would be hidden.
 +
 
 +
===Format===
 +
The <samp>Data/InGameMap</samp> data asset consists of a string => model lookup, where the key is a unique identifier for the map area, and the value is a model with these fields:
 +
 
 +
{| class="wikitable"
 +
|-
 +
! index
 +
! field
 +
! effect
 +
|-
 +
| 0
 +
| Group
 +
| A unique group key shared between all areas drawn on the same map (see [[#Concepts|concepts]]). When the player is in an area for one group, all map areas with a different group key are hidden automatically.
 +
|-
 +
| 1
 +
| Include when<br />detecting group
 +
| Whether to use this area when the game is scanning areas to see which group the player is in. If this is false, it will be ignored even if the player is in the area.
 +
|-
 +
| 2
 +
| Texture
 +
| The texture asset name to draw when the area is applied to the map (using <samp>\</samp> in the path, or <samp>\\</samp> in JSON).
 +
|-
 +
| 3
 +
| Source rectangle
 +
| The pixel area within the texture asset name to draw, or <samp>-1</samp> to draw the entire texture.
 +
|-
 +
| 4
 +
| Target rectangle
 +
| The pixel area within the map onto which to apply the area if it matches.
 +
|-
 +
| 5
 +
| Condition
 +
| A [[#Game state queries|game state query]] which checks whether the area should be applied, or an empty string to always apply.
 +
|-
 +
| 6
 +
| Show ???
 +
| Whether to replace the tooltip for the area with <samp>???</samp> if the condition isn't met.
 +
|-
 +
| 7
 +
| Tooltip
 +
| The [[Modding:Modder Guide/Game Fundamentals#String keys|string key]] to load for the tooltip shown when the mouse is over the area, or empty to disable the tooltip.
 +
|-
 +
| 8
 +
| In-game locations
 +
| The in-game locations to match with the map. These are used to figure out (a) which map group a player is in, and (b) where they should be shown on the map given their in-game position.
 +
 
 +
This consists of sequences of these 10 fields for each location:
 +
{| class="wikitable"
 +
|-
 +
! index
 +
! field
 +
! effect
 +
|-
 +
| 0
 +
| Locations
 +
| A comma-delimited list of location names. Each location can be one of...
 +
* An internal location name (as shown by the {{nexus mod|679|Debug Mode}} mod), without spaces. Any location within [[The Mines|the mines]] and the [[Skull Cavern]] will be <samp>Mines</samp> and <samp>SkullCave</samp> respectively, and festivals use the map asset name (e.g. <samp>Town-EggFestival</samp>). For example, the vanilla desert uses <code>Desert,SkullCave,SandyHouse,SandyShop,Club</code>.
 +
* <samp>CONTEXT_Default</samp> for any location in the valley.
 +
* <samp>CONTEXT_Island</samp> for any location on [[Ginger Island]].
 +
|-
 +
| 1&ndash;4<br />5&ndash;8
 +
| tile corners<br />map corners
 +
| The corner coordinates for the in-game location measured in tiles (in the form {{t|top-left x}} {{t|bottom-right x}} {{t|top-left y}} {{t|bottom-right y}}), and for the equivalent map area measured in pixels (in the form {{t|top-left x}} {{t|top-left y}} {{t|bottom-right x}} {{t|bottom-right y}}). These are used to calculate the position of a player within the map view, given their real position in-game.
 +
 
 +
For example, let's say an area has tile positions <code>(0, 0)</code> through <code>(10, 20)</code>, and map pixel positions <code>(200, 200)</code> through <code>(300, 400)</code>. If the player is standing on tile <code>(5, 10)</code> in-game (in the exact middle of the location), the game would place their marker at pixel <code>(250, 300)</code> on the map (in the exact middle of the map area).
 +
 
 +
If the positions are set to <samp>-1</samp>, the player marker is simply placed in the center of the map area.
 +
|-
 +
| 9
 +
| Tooltip override
 +
| A [[Modding:Modder Guide/Game Fundamentals#String keys|string key]] for the tooltip to show when the cursor hovers over this section of the area, or the text <samp>null</samp> to use the tooltip for the map area (if any). If this is the exact string <samp>FarmName</samp>, it shows the farm name instead.
 +
|}
    
==Custom shops==
 
==Custom shops==
translators
8,447

edits

Navigation menu