Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

Livecoding for GameMaker: Studio / GameMaker Studio 2 · By YellowAfterlife

A couple of built-in physics variables doesn't work well with gmlive

A topic by K.Blank created Dec 30, 2021 Views: 182 Replies: 2
Viewing posts 1 to 2
(7 edits)

I'm using the lastest GMS2 & GMLive.

Variables thats causing error are 

phy_collision_x
phy_collision_y
phy_col_normal_x
phy_col_normal_y

I was using two physical objects named o_phy_wall & o_phy_body, and only o_phy_wall has the collision event.

The error output from the collision event of o_phy_wall (When colliding with o_phy_body) : 

{ current_fix : [ 0 ] }
[live][2021/12/30 17:55:49] Runtime error: [error] { script : "gml_Script_vm_group_field_on_field", line : 519, stacktrace : [ "gml_Script_vm_group_field_on_field (line 519)","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_o_phy_wall_Collision_o_phy_body (line 1) - if (live_call()) return live_result;
" ], longMessage : "ERROR in
action number 1
of  Step Evento_phy_body
for object o_phy_wall:
Invalid index passed to phy_collision_x -2147483648
 at gml_Script_vm_group_field_on_field (line 519) - l_val=variable_instance_get(self,l_s);
", message : "Invalid index passed to phy_collision_x -2147483648" }
 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:o_phy_wall_Collision_o_phy_body:1
 called from 0
 called from o_phy_wall:Collision_o_phy_body[L4,c20]

And the content of the event is simply just:

if (live_call()) return live_result;
show_debug_message(phy_collision_x);

Errors are the same for all four variables, with only their names in the log being different.


I've noticed that despite the GMS2 manual stated those variables should be arraies, their content are all just non-array values, no matter how many collision points are:

show_debug_message(phy_collision_points) == 1
show_debug_message(phy_collision_x) == 10.30
show_debug_message(is_array(phy_collision_x)) == 0
show_debug_message(phy_col_normal_x) == 0
show_debug_message(is_array(phy_col_normal_x)) == 0
show_debug_message(phy_collision_points) == 2
show_debug_message(phy_collision_x) == 386.30
show_debug_message(is_array(phy_collision_x)) == 0
show_debug_message(phy_col_normal_x) == 0
show_debug_message(is_array(phy_col_normal_x)) == 0


Are there any solution to this? I really need to live coding with those variables. Thanks!

Developer

You could make a few functions for accessing these - they are apparently fake arrays (like alarm[] is), therefore cannot be accessed through usual means (via variable_instance_).

You can also use

live_variable_add("some[]", function(set, idx, val) {
    if (set) {
        some[idx] = val;
    } else return some[idx];
});

but do note that this defines a global variable, so inst.some[] wouldn’t work right, only some[].

For alarm, I have a good amount of code that makes it work largely-correctly, but I’ve not foreseen there being more instance variables like this.

Making getter functions for them is a genius workaround! making doppelganger variables are so neat too!

They're now working perfectly. Thank you so much :DD