Modding:Harmony: Difference between revisions
Jump to navigation
Jump to search
(stub) |
No edit summary |
||
Line 5: | Line 5: | ||
For a primer on using Harmony to patch game methods, see [https://harmony.pardeike.net/articles/patching.html this article]. | For a primer on using Harmony to patch game methods, see [https://harmony.pardeike.net/articles/patching.html this article]. | ||
== Example: Chaotic-Colored Message Text == | |||
[[Image:Harmony_example_chaotic_message_text.png|thumb|500px|Chaotic-colored message text created by the example harmony patch.]] | |||
Create <code>somefile.cs</code> in your <code>.../Mods/ModName/</code> directory, with the following code: | |||
<syntaxhighlight lang="c#"> | |||
using HarmonyLib; | |||
namespace YourMod.HarmonyPatches | |||
{ | |||
[HarmonyPatch(typeof(XRL.Messages.MessageQueue))] | |||
class YourPatch1 | |||
{ | |||
[HarmonyPrefix] | |||
[HarmonyPatch("Add")] | |||
static void Prefix(ref string Message) | |||
{ | |||
Message = "{{chaotic|" + Message + "}}"; | |||
} | |||
} | |||
} | |||
</syntaxhighlight> | |||
{{Modding Navbox}} | {{Modding Navbox}} | ||
[[Category:Script Modding]] | [[Category:Script Modding]] |