Skip to content

Commit

Permalink
Merge pull request #189 from nkrapivin/release/1.1
Browse files Browse the repository at this point in the history
Reset spawn tags on title transition and preprocess newlines.
  • Loading branch information
AlexKhayrullin authored Nov 5, 2021
2 parents a81f54e + 428e625 commit 3df9994
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

</string>
Expand Down
2 changes: 1 addition & 1 deletion SonicTimeTwisted.gmx/scripts/reset_temp_values.gml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// reset_temp_values
with objProgram {
with (objProgram) {
temp_xspeed = 0;
temp_yspeed = 0;
temp_state = player_state_standby;
Expand Down
25 changes: 19 additions & 6 deletions SonicTimeTwisted.gmx/scripts/tr_load_file.gml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ 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)) {
_str += file_text_readln(_filehandle); // reads the full line +newline symbol.
}
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) {
Expand All @@ -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;

0 comments on commit 3df9994

Please sign in to comment.