enum TURRET {
	SPRITE,
	BULLET,
	DAMAGE,
	COOLDOWN,
	RANGE,
	COST,
	UP,
	SIZE
};

global.turret = [];
global.tur_array = [];
var _turrets = 0;

var _file = file_text_open_read(PATH_DATA + "turrets.txt");

while(!file_text_eof(_file)) {
	var _line = file_text_readln(_file);
	_line = string_replace_all(_line, chr(10), "");
	_line = string_replace_all(_line, chr(13), "");
	
	if (string_char_at(_line, 1) == "#")
		continue;
	
	var _type = 0;
	var _str = "";
	
	for(var i = 1; i <= string_length(_line)+1; i++) {
		var _c = string_char_at(_line, i);
		if (i == 1 && _c == ">") {
			global.tur_array[array_length_1d(global.tur_array)] = _turrets;
		}
		else if (_c == " " || i > string_length(_line)) {
			switch(_type) {
			case TURRET.SPRITE:
				global.turret[_turrets, _type] = asset_get_index(_str);
				break;
			case TURRET.BULLET:
				global.turret[_turrets, _type] = _str;
				break;
			case TURRET.UP:
				if (_str == ">")
					global.turret[_turrets, _type] = _turrets + 1;
				else
					global.turret[_turrets, _type] = -1;
				break;
			default:
				global.turret[_turrets, _type] = real(_str);
			}
			_str = "";
			_type++;
			if (_type > TURRET.SIZE)
				break;
		}
		else {
			_str += _c;
		}
	}
	_turrets++;
}

file_text_close(_file);

show_debug_message("Tur array: " + string(global.tur_array));