Changes

m
Replace deprecated <source> tags with <syntaxhighlight> tags; add new template Template:Modder compatibility header
Line 1: Line 1:  
←[[Modding:Index|Index]]
 
←[[Modding:Index|Index]]
   −
'''This page is for modders. Players: see [[Modding:Mod compatibility]] instead.'''
+
{{Modder compatibility header}}
 
   
This page explains how to update your SMAPI mod code for compatibility with SMAPI 1.9 (released alongside Stardew Valley 1.2 in April 2017) and 2.0 (released in October 2017).
 
This page explains how to update your SMAPI mod code for compatibility with SMAPI 1.9 (released alongside Stardew Valley 1.2 in April 2017) and 2.0 (released in October 2017).
   Line 169: Line 168:  
Change your mod's entry class from this:
 
Change your mod's entry class from this:
   −
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
/// <summary>Initialise the mod.</summary>
 
/// <summary>Initialise the mod.</summary>
 
public override void Entry(params object[] objects)
 
public override void Entry(params object[] objects)
Line 175: Line 174:  
     // your code
 
     // your code
 
}
 
}
</source>
+
</syntaxhighlight>
    
to this:
 
to this:
   −
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
 
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
 
/// <param name="helper">Provides simplified APIs for writing mods.</param>
 
/// <param name="helper">Provides simplified APIs for writing mods.</param>
Line 186: Line 185:  
     // your code
 
     // your code
 
}
 
}
</source>
+
</syntaxhighlight>
    
===Mod configuration===
 
===Mod configuration===
Line 196: Line 195:  
<li>Find your subclass of <tt>StardewModdingAPI.Config</tt>, which probably looks something like this:
 
<li>Find your subclass of <tt>StardewModdingAPI.Config</tt>, which probably looks something like this:
   −
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
class SampleConfig : StardewModdingAPI.Config
 
class SampleConfig : StardewModdingAPI.Config
 
{
 
{
Line 209: Line 208:  
   }
 
   }
 
}
 
}
</source></li>
+
</syntaxhighlight></li>
    
<li>Edit this class as follows:
 
<li>Edit this class as follows:
Line 219: Line 218:  
<li>Your class should now look something like this:
 
<li>Your class should now look something like this:
   −
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
class SampleConfig
 
class SampleConfig
 
{
 
{
Line 225: Line 224:  
   public float ExampleFloat { get; set; } = 0.5;
 
   public float ExampleFloat { get; set; } = 0.5;
 
}
 
}
</source>
+
</syntaxhighlight>
    
or like this if you used a constructor:
 
or like this if you used a constructor:
   −
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
class SampleConfig
 
class SampleConfig
 
{
 
{
Line 241: Line 240:  
   }
 
   }
 
}
 
}
</source></li>
+
</syntaxhighlight></li>
    
<li>In your <tt>Mod</tt> class, change anything that looks like this:
 
<li>In your <tt>Mod</tt> class, change anything that looks like this:
   −
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
var config = new SampleConfig().InitializeConfig(this.BaseConfigPath);
 
var config = new SampleConfig().InitializeConfig(this.BaseConfigPath);
</source>
+
</syntaxhighlight>
    
to this:
 
to this:
   −
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
var config = helper.ReadConfig<SampleConfig>();
 
var config = helper.ReadConfig<SampleConfig>();
</source></li>
+
</syntaxhighlight></li>
    
<li>If you use other methods, here's how to migrate them:
 
<li>If you use other methods, here's how to migrate them:
114

edits