UndertaleModTool
UndertaleModTool copied to clipboard
Compiler self call support
Resolves #1133
Description
-
Adds support for GMS2.3+ self calls in the compiler, cherrypicked from UndertaleModTool Community Edition.
-
Fixed an issue where sub functions in an object should be stored in a self variable without the object function name suffix. Example: the utmt compiler would make
gml_Script_act_gml_Object_menu_chapter_btn_Create_0be stored inself.act_gml_Object_menu_chapter_btn_Create_0when the original game code hadself.act.
Caveats
None
Notes
I've tested this with Submachine Legacy (2023.8), and the one from #1133 (2022.5)
How to Reproduce:
-
Create a function in a GlobalScript or Object code, then call that function from another function
-
In gamemaker (I've only tested this for 2023.8), make a function in an object, then call that function from another one in the same object
See also #564.
As a heads up, we'll probably be looking at merging this functionality in once the Underanalyzer decompiler is merged in. We do have a few things to make decisions about, though:
- Do we consult the builtin function list to determine self calls, or do we make a setting on the decompiler to force
self.notation? - Do we account for more complex chains of calls, like
a.b().c().d(), or do we hold off until we (possibly) make a new compiler on the Underanalyzer side?
Curious for thoughts!
Just a note, UTMTCE's self calls have received further improvements since this PR, that are not in the PR (https://github.com/XDOneDude/UndertaleModToolCE/commit/19a4f44b8b4a81e6e22448b3f1c469e0b48b73a2 https://github.com/XDOneDude/UndertaleModToolCE/commit/aeb662421929adb0dd815e2f907b3090ff3cd9cf), and they now do support chains of calls and also local variables (although still using self, yeah I know it's messy):
var a = function() {
return {
b: function() {
return 123;
}
};
}
show_message(self.a().b()) // shows "123"