Changes

Jump to navigation Jump to search
1,226 bytes removed ,  05:31, 1 September 2018
Line 100: Line 100:     
==Locations==
 
==Locations==
See [[Modding:Modder Guide/Game Fundamentals#GameLocation et al|Game Fundamentals#GameLocation]].
+
See [[Modding:Modder Guide/Game Fundamentals#GameLocation et al|Game Fundamentals#GameLocation et al]].
    
===Get all locations===
 
===Get all locations===
Line 128: Line 128:  
Note that farmhands in multiplayer can't see all locations; see [[Modding:Modder Guide/APIs/Multiplayer#GetActiveLocations|<tt>GetActiveLocations</tt>]] instead.
 
Note that farmhands in multiplayer can't see all locations; see [[Modding:Modder Guide/APIs/Multiplayer#GetActiveLocations|<tt>GetActiveLocations</tt>]] instead.
   −
===Map Properties===
+
===Edit a location map===
You can edit many properties of the current map and the tiles in the map. This is already documented here [[Modding:Maps#Map_properties | Map Properties]]
+
See [[Modding:Maps]].
 
  −
===Tiles===
  −
''terrainFeatures'' contains information about the tiles. (e.g. dirt, grass, crops, etc.)
  −
 
  −
''objects'' contains information about objects on top of tiles. (e.g. crops, stones)
  −
 
  −
===Handling TerrainFeatures===
  −
 
  −
As ''terrainFeatures'' is a NetField, always use .Pairs to access it for enumeration. The .Key value of this stores the location, and the .Value contains the terrainFeature itself.  As a note, this includes items spawned off the map, which is usually cleared at end of day.
  −
 
  −
If you need to access just crops, this snippet will be of use:
  −
 
  −
<source lang="c#">
  −
 
  −
foreach (var tf in Game1.getFarm().terrainFeatures.Pairs)
  −
{
  −
    if ((tf.Value is HoeDirt hd) && hd.crop != null)
  −
    {
  −
        // do crop like things here.
  −
    }
  −
}
  −
</source>
  −
 
  −
If you need some other location, sub that out for Game1.getFarm(). Note this doesn't null check Farm! Make sure Farm is loaded.
  −
 
  −
===Handling Objects===
  −
 
  −
There are several fields that handle objects, but always use the .objects one. The same rules apply as in TerrainFeatures, except that you really can't place objects beyond the edge of the map.
      
==Player==
 
==Player==
translators
8,438

edits

Navigation menu