Posted August 19, 2026 by katsaii
#v3 #patch
catspeak_get_self and catspeak_get_index. (tabularelf) (Addendum #2)Addendum #1 (written by Harlem512)
script_execute_ext<br>has issues with optional arguments for built-in functions. The following code fails:// expected output is `[ ]`, however this returns `["","","",""]` var ext = script_execute_ext(string_split, ["AAAA", "A", true]) var normal = string_split("AAAA", "A", true) // fails assertEq(array_length(ext), array_length(normal))For most functions this isn't a problem, since__compileCalldoes some short-cutting based on number of arguments (and the shortcuts usescript_execute, which does allow for optional arguments). However, some built-in functions (notablyinstance_create_depthandinstance_create_layer) have more than 3 arguments and fail.var parsed = Catspeak.parseString("instance_create_depth(0,0, -100, dummy_object, {my_var:20})") var compiled = Catspeak.compile(parsed) var inst = compiled() // fails assertEq(inst.my_var, 20)This pr adds__catspeak_expr_call_4__and__catspeak_expr_call_5__to bypass this issue.
Addendum #2 (written by tabularelf)
This PR introducescatspeak_get_selfandcatspeak_get_index, which play as counterparts tomethod_get_selfandmethod_get_index. The reason for this is thatmethod_get_indexwill return__catspeak_function__or__catspeak_method__from Catspeak programs. And even then, not as a method but as a GML function index. That's likely to cause all sorts of issues.method_get_selfalso has the unfortunate issue where it could return the Catspeak program struct itself. Which may also be unintended depending on who you ask.
catspeak_get_indexresolves this by always returning a method. Never a function ID. This means that any Catspeak functions or Catspeak methods, will always return their callee program "as is". And any GML function will be returned as a method with a bound toundefined.
catspeak_get_selfresolves this by returning self from only GML functions and Catspeak methods. Anything marked as a Catspeak function (viais_catspeak) will retrieveself_via accessor (if it exists), or returnsundefined.