Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

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

[Bug] Recursive Constructor Function

A topic by Yokin created Nov 16, 2022 Views: 222 Replies: 1
Viewing posts 1 to 2
(2 edits)

This might be one of the known unfixable constructor issues. BUT:

This code works initially, but hard crashes after a live reload with some kind of memory access error. Nothing changed in the live reload besides the addition of a semi-colon to make it reload.

Log:

Entering main loop.
**********************************.
17
Pause event has been registered for this frame
Pause event has been unregistered
[live][11/16/2022 4:33:42 PM] Reloaded Test.
Runner exited with non-zero status (0xc0000005 = 3221225477)
Compile Ended: 16:33:42
(1 edit)

Raw code if you want to test it yourself

function Test(_value) constructor {
	if(live_call(_value)) return live_result;
	
	obj_list = [];
	value    = _value;
	
	static get_sum =function()/*=>*/ {
		var	_sum      = value,
			_objIndex = 0;;
			
		repeat(array_length(obj_list)){
			_sum += obj_list[_objIndex++].get_sum();
		}
		
		return _sum;
	};
	
	static add_obj =function(_obj)/*=>*/ {
		array_push(obj_list, _obj);
	};
}
	var _obj = new Test(3);
	_obj.add_obj(new Test(5));
	_obj.add_obj(new Test(9));
	show_debug_message(_obj.get_sum());