Modding:General Best Practices: Difference between revisions

Jump to navigation Jump to search
Moves to Modding Resources category
(add modding info box)
(Moves to Modding Resources category)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[[Category:Modding]]{{Modding Info}}
[[Category:Modding Resources]]{{Modding Info}}{{Cleanup|This article should be merged into [[Modding:Overview]] as well as the main articles for each section.}}
= Prefix your object and table names with some unique ID =
=Prefixing=
Prefix your object and table names with some unique ID.
 
For instance, <code>alphabeardmods_{id}</code>. This will prevent namespace conflicts with official content and other mods in the future.
For instance, <code>alphabeardmods_{id}</code>. This will prevent namespace conflicts with official content and other mods in the future.


Line 12: Line 14:
</syntaxhighlight>
</syntaxhighlight>


= Only include your content and the minimum changeset via <code>Load="Merge"</code> in tables and object definitions =
=Merging=
Only include your content and the minimum changeset via <code>Load="Merge"</code> in tables and object definitions.
 
Don't copy the whole contents of the game xml. You only need to include new content.
Don't copy the whole contents of the game xml. You only need to include new content.


Line 26: Line 30:
</syntaxhighlight>
</syntaxhighlight>


==Random Functions==
=Random Functions=
{{Main|Modding:Random Functions}}
{{Main|Modding:Random Functions}}
To avoid conflicts and to keep consistency between seeds, Stat.Random() and Stat.Rnd() should not be called. The ideal is to use [[Modding:Random_Functions#GetSeededRandomGenerator.28string_Seed.29|GetSeededRandomGenerator()]] for your mod's randomness. The next best is calling RandomCosmetic() or Rnd2().
To avoid conflicts and to keep consistency between seeds, Stat.Random() and Stat.Rnd() should not be called. The ideal is to use [[Modding:Random_Functions#GetSeededRandomGenerator.28string_Seed.29|GetSeededRandomGenerator()]] for your mod's randomness. The next best is calling RandomCosmetic() or Rnd2().
=ObjectBlueprint Definitions=
In general, unless you're defining a unique object, make sure you add the xml property <code>Load="Merge"</code> to prevent breaking behavior.
==Stats==
Prefer using <code>value</code> over <code>sValue</code>, unless you're creating a unique creature. When loading ObjectBlueprints, the code loads both <code>sValue</code> and <code>value</code> into a stat, then if <code>sValue</code> is set, prefers using that to set a stat over <code>value</code>.
== Harmony Patches ==
Harmony Patches are an advanced technique for code injection/modification. It allows modding parts of the game that are not normally accessible via the normal part and event systems exposed to modders. Harmony patching is recommended only for modders with advanced coding experience. For some advice about when and when not to use Harmony, see [[Modding:Harmony|Harmony Modding]].{{Modding Navbox}}
45

edits

Navigation menu