I have been using the function live_function_add,
adding optional parameters with symbol: "?"
live_function_add("instance_create_layer(x, y, layer, obj, ?var_struct)", function(x, y, layer, obj, var_struct) { instance_create_layer(x, y, layer, obj, var_struct); });
Everything works fine when I use all 5 parameters, but when I use only 4, I get an error:
[live][26/07/2022 12:02:06] Runtime error: [error] { message : "argument 5 needs to be a struct", stacktrace : [ "gml_Script_anon_gml_Object_obj_gmlive_Create_0_1166_gml_Object_obj_gmlive_Create_0 (line 26)","gml_Script_vm_gml_thread_exec_slice_with4 (line 40) - return l_f(l_w[l_i],l_w[l_i+1],l_w[l_i+2],l_w[l_i+3]); ","gml_Script_vm_group_call_call_func (line 97) - l_v1=l_sf(l_func,l_array1,l_arrOffset); ","gml_Script_vm_group_call_on_call_func (line 256) - if(vm_group_call_check_func_args(l_th,l_act,l__argChecks,l__restCheck,l_stack,l_k,l__argc)&&vm_group_call_call_func(l_th,l_act,l__func,l__inst,l_stack,l_k,l__argc)){ ","gml_Script_anon_gml_thread_gml_GlobalScript_GMLive_thread_3298_gml_thread_gml_GlobalScript_GMLive_thread (line 109) - var l_ar1=l_handler(l__gthis,l_act); ","gml_Script_anon_gml_program_gml_GlobalScript_GMLive_program_1897_gml_program_gml_GlobalScript_GMLive_program (line 58) - l_th.h_exec(); ","gml_Script_live_proc_call_impl (line 33) - var l_th=l_pg.h_call_v(l_scriptName,l_args1,false); ","gml_Script_live_call (line 74) - return live_proc_call_impl(l_data,l_vals,l_def); ","gml_Object_objScarecrow_Create_0 (line 2) - if (live_call()) return live_result; " ], longMessage : "ERROR in action number 1 of Create Event for object objScarecrow: argument 5 needs to be a struct at gml_Script_anon_gml_Object_obj_gmlive_Create_0_1166_gml_Object_obj_gmlive_Create_0 (line 26) - instance_create_layer(x, y, layer, obj, var_struct); ", script : "gml_Script_anon_gml_Object_obj_gmlive_Create_0_1166_gml_Object_obj_gmlive_Create_0", line : 26 } called from game:gml_std_haxe_Exception_caught:1235 called from game:anon_gml_thread_gml_GlobalScript_GMLive_thread_3298_gml_thread_gml_GlobalScript_GMLive_thread:119 called from game:anon_gml_program_gml_GlobalScript_GMLive_program_1897_gml_program_gml_GlobalScript_GMLive_program:58 called from game:live_proc_call_impl:33 called from game:live_call:74 called from game:objScarecrow_Create_0:2 called from 0 called from objScarecrow:Create_0[L30,c34]
Am I doing something wrong? Thank you in advance.