Difference between revisions of "Modding Tutorials/Transpiler Hints"
Jump to navigation
Jump to search
(Useful tool in some certain circumstances ><) |
(Added link.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{BackToTutorials}} | ||
+ | |||
Debugging Transpilers can seem impossible. It's very difficult to count exactly correctly, and any mistakes will likely throw a system exception. | Debugging Transpilers can seem impossible. It's very difficult to count exactly correctly, and any mistakes will likely throw a system exception. | ||
==Helpful examples== | ==Helpful examples== | ||
− | One way to get an idea of how to use the Transpiler is to search github for Harmony Transpilers. | + | One way to get an idea of how to use the Transpiler is to [https://github.com/search?o=desc&q=Rimworld+Harmony+Transpiler&s=indexed&type=Code search github for Harmony Transpilers]. |
==Useful debugging tools.== | ==Useful debugging tools.== | ||
Line 28: | Line 30: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | [[Category:Modding tutorials]] |
Latest revision as of 01:34, 10 September 2020
Debugging Transpilers can seem impossible. It's very difficult to count exactly correctly, and any mistakes will likely throw a system exception.
Helpful examples[edit]
One way to get an idea of how to use the Transpiler is to search github for Harmony Transpilers.
Useful debugging tools.[edit]
See what your IL code is[edit]
One thing that can potentially help is to print out your entire modified IL code, to make sure you've got it correct:
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) {
var l=XTranspiler(instructions, generator).ToList(); // name your actual transpiler XTranspiler
string s="Code:";
int i=0;
foreach (var c in l) {
if (c.opcode==OpCodes.Call ||
c.opcode==OpCodes.Callvirt) { // you can make certain operations more visible
Log.Warning(""+i+": "+c);
} else {
Log.Message(""+i+": "+c);
}
s+="\n"+i+": "+c;
i++;
yield return c;
}
Log.Error(s); // or just print the entire thing out to copy to a text editor.
}