From 428e625007e8bf735515204f72c8c6c2e3cdb4e8 Mon Sep 17 00:00:00 2001 From: Nikita Krapivin Date: Sat, 6 Nov 2021 00:16:23 +0500 Subject: [PATCH] Reset spawn tags on title transition and preprocess newlines. --- .../objFadeWhiteFromLevelToTitle.object.gmx | 6 +++-- .../scripts/reset_temp_values.gml | 2 +- SonicTimeTwisted.gmx/scripts/tr_load_file.gml | 25 ++++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/SonicTimeTwisted.gmx/objects/objFadeWhiteFromLevelToTitle.object.gmx b/SonicTimeTwisted.gmx/objects/objFadeWhiteFromLevelToTitle.object.gmx index 4b8e44dec..8ee49f517 100644 --- a/SonicTimeTwisted.gmx/objects/objFadeWhiteFromLevelToTitle.object.gmx +++ b/SonicTimeTwisted.gmx/objects/objFadeWhiteFromLevelToTitle.object.gmx @@ -40,11 +40,13 @@ with (objGameData) { event_perform(ev_create, 0); } -// reset time. +// reset time AND spawn tags. with (objProgram) { // TODO: should this be put in reset_temp_values script instead? - temp_spawn_time = -1; + spawn_tag = 0; spawn_time = 36000; + temp_spawn_tag = -1; + temp_spawn_time = -1; } diff --git a/SonicTimeTwisted.gmx/scripts/reset_temp_values.gml b/SonicTimeTwisted.gmx/scripts/reset_temp_values.gml index bbd348c56..7702ad9e8 100644 --- a/SonicTimeTwisted.gmx/scripts/reset_temp_values.gml +++ b/SonicTimeTwisted.gmx/scripts/reset_temp_values.gml @@ -1,5 +1,5 @@ // reset_temp_values -with objProgram { +with (objProgram) { temp_xspeed = 0; temp_yspeed = 0; temp_state = player_state_standby; diff --git a/SonicTimeTwisted.gmx/scripts/tr_load_file.gml b/SonicTimeTwisted.gmx/scripts/tr_load_file.gml index 5ecd7a9ac..97e7ab8f3 100644 --- a/SonicTimeTwisted.gmx/scripts/tr_load_file.gml +++ b/SonicTimeTwisted.gmx/scripts/tr_load_file.gml @@ -8,12 +8,7 @@ if (!file_exists(_fname)) { show_debug_message("Loading translation " + _fname); var _str; -if (DEVICE_INFO & DEVICE_OS_BROWSER) { // not HTML5, native. - var _buff = buffer_load(_fname); - _str = buffer_read(_buff, buffer_text); - buffer_delete(_buff); -} -else { // is HTML5. it does not support raw buffers. +if (DEVICE_INFO & DEVICE_OS_BROWSER) { // HTML5. var _filehandle = file_text_open_read(_fname); _str = ""; while (!file_text_eof(_filehandle)) { @@ -21,6 +16,11 @@ else { // is HTML5. it does not support raw buffers. } file_text_close(_filehandle); } +else { // not HTML5. + var _buff = buffer_load(_fname); + _str = buffer_read(_buff, buffer_text); + buffer_delete(_buff); +} var _map = json_decode(_str); if (_map == -1) { @@ -39,4 +39,17 @@ ds_map_replace(_map[? "info"], "fname", filename_change_ext(filename_name(_fname // add json ds map to a global map. ds_map_add_map(global.TR_map, ds_map_find_value(_map[? "info"], "intname"), _map); +// preprocess strings: +if (ds_map_exists(_map, "data")) { + var _mapdata = _map[? "data"]; + // that's how you loop through a ds map + for (var _key = ds_map_find_first(_mapdata), _value; + ds_map_exists(_mapdata, _key); + _key = ds_map_find_next(_mapdata, _key)) { + // replace "\n" symbol with a gms1 newline + _value = _mapdata[? _key]; + _mapdata[? _key] = string_replace_all(_value, chr(10), "#");; + } +} + return true;