From 763a74ebe39f8a9e4b6db5d7be493ff38ee6e3f6 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 3 Nov 2024 03:57:17 +0300 Subject: [PATCH 01/14] String functions fiddle --- scripts/scr_string/scr_string.gml | 26 ----- .../scr_string_functions.gml | 103 ++++++++++++++++++ .../scr_string_functions.yy} | 2 +- .../scr_string_plural/scr_string_plural.gml | 18 --- .../scr_string_plural/scr_string_plural.yy | 11 -- .../scr_truncate_string_width.gml | 21 ---- .../scr_truncate_string_width.yy | 11 -- 7 files changed, 104 insertions(+), 88 deletions(-) delete mode 100644 scripts/scr_string/scr_string.gml create mode 100644 scripts/scr_string_functions/scr_string_functions.gml rename scripts/{scr_string/scr_string.yy => scr_string_functions/scr_string_functions.yy} (85%) delete mode 100644 scripts/scr_string_plural/scr_string_plural.gml delete mode 100644 scripts/scr_string_plural/scr_string_plural.yy delete mode 100644 scripts/scr_truncate_string_width/scr_truncate_string_width.gml delete mode 100644 scripts/scr_truncate_string_width/scr_truncate_string_width.yy diff --git a/scripts/scr_string/scr_string.gml b/scripts/scr_string/scr_string.gml deleted file mode 100644 index 266186bab6..0000000000 --- a/scripts/scr_string/scr_string.gml +++ /dev/null @@ -1,26 +0,0 @@ -/// @function string_upper_first -/// @description Capitalizes the first character in a string. -/// @param {string} _string The string to be modified. -/// @returns {string} Modified string. - -function string_upper_first(_string) { - try { - var _first_char; - var _modified_string; - - _first_char = string_char_at(_string, 1); - _first_char = string_upper( _first_char ); - - _modified_string = _string; - _modified_string = string_delete(_modified_string, 1, 1); - _modified_string = string_insert(_first_char, _modified_string, 1); - - return _modified_string; - } - catch(_exception) { - log_into_file(_exception.longMessage); - log_into_file(_exception.script); - log_into_file(_exception.stacktrace); - show_debug_message(_exception.longMessage); - } -} \ No newline at end of file diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml new file mode 100644 index 0000000000..6dd74d242b --- /dev/null +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -0,0 +1,103 @@ +/// @function string_upper_first +/// @description Capitalizes the first character in a string. +/// @param {string} _string The string to be modified. +/// @returns {string} Modified string. + +function string_upper_first(_string) { + try { + var _first_char; + var _modified_string; + + _first_char = string_char_at(_string, 1); + _first_char = string_upper( _first_char ); + + _modified_string = _string; + _modified_string = string_delete(_modified_string, 1, 1); + _modified_string = string_insert(_first_char, _modified_string, 1); + + return _modified_string; + } + catch(_exception) { + log_into_file(_exception.longMessage); + log_into_file(_exception.script); + log_into_file(_exception.stacktrace); + show_debug_message(_exception.longMessage); + } +} + +/// @function string_plural +/// @description This function formats a string into a plural form by adding affixes following common rules. +function string_plural(_string, _variable = 2) { + if (_variable < 2) { + return _string; + } + + var _last_char = string_char_at(_string, string_length(_string)); + var _last_two_chars = string_copy(_string, string_length(_string) - 1, 2); + if (_last_char == "y") { + return string_copy(_string, 1, string_length(_string) - 1) + "ies"; + } + else if (array_contains(["s", "x", "z", "ch", "sh"], _last_char)) { + return _string + "es"; + } + else if (_last_char == "f" || _last_two_chars == "fe") { + return string_copy(_string, 1, string_length(_string) - string_length(_last_two_chars)) + "ves"; + } + else { + return _string + "s"; + } +} + +/// @function string_truncate +/// @description Truncates a string to fit within a specified pixel width, appending "..." if the string was truncated. +/// @param {string} _text The string to be truncated. +/// @param {int} _max_width The maximum allowable pixel width for the string. +/// @returns {string} Original or truncated string. +function string_truncate(_text, _max_width) { + var _ellipsis = "..."; + var _ellipsis_width = string_width(_ellipsis); + var _text_width = string_width(_text); + if (_text_width > _max_width) { + var i = string_length(_text); + while (_text_width + _ellipsis_width > _max_width && i > 0) { + i--; + _text = string_delete(_text, i+1, 1); + _text_width = string_width(_text + _ellipsis); + } + return _text + _ellipsis; + } else { + return _text; + } +} + +function integer_to_letters(_integer) { + var _ones = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; + var _teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; + var _tens = ["", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; + var _thousands = ["", "thousand", "million", "billion"]; + + if (_integer == 0) return "zero"; // Handle zero + + var _num_str = ""; + var _num_int = floor(_integer); + + if (_num_int < 10) { + _num_str += _ones[_num_int]; + } else if (_num_int < 20) { + _num_str += _teens[_num_int - 10]; + } else if (_num_int < 100) { + _num_str += _tens[floor(_num_int / 10)] + (_num_int % 10 != 0 ? " " + _ones[_num_int % 10] : ""); + } else if (_num_int < 1000) { + _num_str += _ones[floor(_num_int / 100)] + " hundred" + (_num_int % 100 != 0 ? " " + integer_to_letters(_num_int % 100) : ""); + } else { + for (var _i = 0; _num_int > 0; _i += 1) { + if (_num_int % 1000 != 0) { + var _part = integer_to_letters(_num_int % 1000); + _num_str = _part + " " + _thousands[_i] + (_num_str != "" ? " " : "") + _num_str; + } + _num_int = floor(_num_int / 1000); + } + } + + return string_trim(_num_str); +} diff --git a/scripts/scr_string/scr_string.yy b/scripts/scr_string_functions/scr_string_functions.yy similarity index 85% rename from scripts/scr_string/scr_string.yy rename to scripts/scr_string_functions/scr_string_functions.yy index c7d2aaf8f8..51d81dcb1b 100644 --- a/scripts/scr_string/scr_string.yy +++ b/scripts/scr_string_functions/scr_string_functions.yy @@ -1,7 +1,7 @@ { "resourceType": "GMScript", "resourceVersion": "1.0", - "name": "scr_string", + "name": "scr_string_functions", "isCompatibility": false, "isDnD": false, "parent": { diff --git a/scripts/scr_string_plural/scr_string_plural.gml b/scripts/scr_string_plural/scr_string_plural.gml deleted file mode 100644 index ca7ea877d9..0000000000 --- a/scripts/scr_string_plural/scr_string_plural.gml +++ /dev/null @@ -1,18 +0,0 @@ -/// @function string_plural -/// @description This function formats a string into a plural form by adding affixes following common rules. -function string_plural(_string) { - var _last_char = string_char_at(_string, string_length(_string)); - var _last_two_chars = string_copy(_string, string_length(_string) - 1, 2); - if (_last_char == "y") { - return string_copy(_string, 1, string_length(_string) - 1) + "ies"; - } - else if (array_contains(["s", "x", "z", "ch", "sh"], _last_char)) { - return _string + "es"; - } - else if (_last_char == "f" || _last_two_chars == "fe") { - return string_copy(_string, 1, string_length(_string) - string_length(_last_two_chars)) + "ves"; - } - else { - return _string + "s"; - } -} \ No newline at end of file diff --git a/scripts/scr_string_plural/scr_string_plural.yy b/scripts/scr_string_plural/scr_string_plural.yy deleted file mode 100644 index 5e91f6c317..0000000000 --- a/scripts/scr_string_plural/scr_string_plural.yy +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType": "GMScript", - "resourceVersion": "1.0", - "name": "scr_string_plural", - "isCompatibility": false, - "isDnD": false, - "parent": { - "name": "Text", - "path": "folders/Scripts/Helpers/Text.yy", - }, -} \ No newline at end of file diff --git a/scripts/scr_truncate_string_width/scr_truncate_string_width.gml b/scripts/scr_truncate_string_width/scr_truncate_string_width.gml deleted file mode 100644 index e881a3f251..0000000000 --- a/scripts/scr_truncate_string_width/scr_truncate_string_width.gml +++ /dev/null @@ -1,21 +0,0 @@ -/// @function string_truncate -/// @description Truncates a string to fit within a specified pixel width, appending "..." if the string was truncated. -/// @param {string} _text The string to be truncated. -/// @param {int} _max_width The maximum allowable pixel width for the string. -/// @returns {string} Original or truncated string. -function string_truncate(_text, _max_width) { - var _ellipsis = "..."; - var _ellipsis_width = string_width(_ellipsis); - var _text_width = string_width(_text); - if (_text_width > _max_width) { - var i = string_length(_text); - while (_text_width + _ellipsis_width > _max_width && i > 0) { - i--; - _text = string_delete(_text, i+1, 1); - _text_width = string_width(_text + _ellipsis); - } - return _text + _ellipsis; - } else { - return _text; - } -} \ No newline at end of file diff --git a/scripts/scr_truncate_string_width/scr_truncate_string_width.yy b/scripts/scr_truncate_string_width/scr_truncate_string_width.yy deleted file mode 100644 index b893dd1dd8..0000000000 --- a/scripts/scr_truncate_string_width/scr_truncate_string_width.yy +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType": "GMScript", - "resourceVersion": "1.0", - "name": "scr_truncate_string_width", - "isCompatibility": false, - "isDnD": false, - "parent": { - "name": "Text", - "path": "folders/Scripts/Helpers/Text.yy", - }, -} \ No newline at end of file From f869643b2f90b61249aa89a4b567ec03948d6533 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 3 Nov 2024 03:57:43 +0300 Subject: [PATCH 02/14] Fix welcome message names and improve it a bit --- objects/obj_controller/Create_0.gml | 53 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index c9e0c86874..ced3b42ece 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1475,14 +1475,14 @@ if (global.load==0) then marines-=command; // **** INTRO SCREEN **** temp[30]=string(check_number)+" "+string(year_fraction)+" "+string(year)+".M"+string(millenium);// Date temp[31]=string_upper(adept_name);// Adept name -temp[32]=string_upper(obj_ini.name[0,1]);// Master name +temp[32]=string_upper(obj_ini.name[0][0]);// Master name temp[33]=string_upper(scr_thought());// Thought of the day // Starts the vars for the 4 pages of intro var njm=34,com=0,vih=0,word="",masta=0,forga=0,chapla=0,apa=0,liba=0,techa=0,libra=0,coda=0,lexa=0,apotha=0,old_dudes=0; var honoh=0,termi=0,veter=0,capt=0,chap=0,apoth=0,stand=0,dread=0,tact=0,assa=0,deva=0,rhino=0,speeder=0,raider=0,standard=0,bike=0,scou=0,whirl=0,pred=0; -for(var mm=1; mm<=100; mm++){ +for(var mm=0; mm<=100; mm++){ if (obj_ini.role[com,mm]=="Chapter Master") then masta=1; if (obj_ini.role[com,mm]=="Forge Master") then forga=1; if (obj_ini.role[com,mm]=="Master of Sanctity") then chapla=1; @@ -1497,30 +1497,31 @@ for(var mm=1; mm<=100; mm++){ if (obj_ini.role[com,mm]==obj_ini.role[100][2]) then honoh+=1; } -temp[njm]="Command staff which includes"; +temp[njm]="Command staff made of"; + +if (masta == 1) then temp[njm] += $", your majesty Chapter Master {obj_ini.name[com][0]}"; +if (forga == 1) then temp[njm] += $", Forge Master {obj_ini.name[com][1]}"; +if (chapla == 1) then temp[njm] += $", Master of Sanctity {obj_ini.name[com][2]}"; +if (apa == 1) then temp[njm] += $", Master of the Apothecarion {obj_ini.name[com][3]}"; +if (liba == 1) then temp[njm] += $", and Chief Librarian {obj_ini.name[com][4]}. "; -if (masta==1) then temp[njm]+=", your majesty "+string(obj_ini.name[com,1]); -if (forga==1) then temp[njm]+=", Forge Master "+string(obj_ini.name[com,2]); -if (chapla==1) then temp[njm]+=", Master of Sanctity "+string(obj_ini.name[com,3]); -if (apa==1) then temp[njm]+=", Master of the Apothecarion "+string(obj_ini.name[com,4]); -if (liba==1) then temp[njm]+=", and Chief Librarian "+string(obj_ini.name[com,5])+". "; vih=string_pos(",",temp[njm]); temp[njm]=string_delete(temp[njm],vih,1); njm+=1; -temp[njm] = ""; -temp[njm]+=" It has"; -if (techa>0) then temp[njm]+=", "+string(techa)+" "+string(obj_ini.role[100][16])+"s"; -if (old_dudes>0) then temp[njm]+=", "+string(techa)+" "+string(obj_ini.role[100][16])+"s"; -if (apotha>0) then temp[njm]+=", "+string(apotha)+" "+string(obj_ini.role[100][15])+"s"; -if (libra>0) then temp[njm]+=", "+string(libra)+" "+string(obj_ini.role[100,17])+"s"; -if (coda>0) then temp[njm]+=", "+string(coda)+" Codiciery"; -if (lexa>0) then temp[njm]+=", "+string(lexa)+" Lexicanum."; +temp[njm] = "Specialist branches staffed by"; +if (techa > 0) then temp[njm] += $", {integer_to_letters(techa)} {string_plural(obj_ini.role[100][16], techa)}"; +if (old_dudes > 0) then temp[njm] += $", {integer_to_letters(old_dudes)} {string_plural(obj_ini.role[100][14], old_dudes)}"; +if (apotha > 0) then temp[njm] += $", {integer_to_letters(apotha)} {string_plural(obj_ini.role[100][15], apotha)}"; +if (libra > 0) then temp[njm] += $", {integer_to_letters(libra)} {string_plural(obj_ini.role[100,17], libra)}"; +if (coda > 0) then temp[njm] += $", {integer_to_letters(coda)} Codiciery"; +if (lexa > 0) then temp[njm] += $", {integer_to_letters(lexa)} Lexicanum."; vih=string_pos(",",temp[njm]); temp[njm]=string_delete(temp[njm],vih,1); -if (honoh>0) then temp[njm]+=" You have an Honour Guard which contains "+string(honoh)+" souls."; +if (honoh>0) then temp[njm]+=$"\n\nHonour Guard, having the {integer_to_letters(honoh)} most veteran {string_plural("marine", honoh)} of your chapter serving in it."; + for(var company=0; company<10; company++){ njm+=1; com+=1; @@ -1579,7 +1580,7 @@ for(var company=0; company<10; company++){ if (com==9) then word="ninth"; if (com==10) then word="tenth"; if (com>=1){ - if (veter+termi+stand+dread+tact+assa+deva+rhino+raider+standard+scou+whirl>0) then temp[njm]="You have a "+string(word)+" company. It has"; + if (veter+termi+stand+dread+tact+assa+deva+rhino+raider+standard+scou+whirl>0) then temp[njm]="You have the "+string(word)+" company. It has"; else{temp[njm]="";} } @@ -1621,10 +1622,12 @@ for(var company=0; company<10; company++){ } } -temp[59]="CLASSIFICATION: SECTOR LOGISTICAE#++++++++++DATE: "+string(temp[30])+"#++++++++AUTHOR: MASTER ADEPT "+string(temp[31])+"#++++++++++++RE: INTRODUCTORY MISSIVE#+++++RECIPIENT: CHAPTER MASTER "+string(temp[32])+"##++THOUGHT: "+string(temp[33])+"++##I see you have made it unscathed, your grace. Death comes with you as it should! The enemy is on the horizon. Thy chapter is mighty and only waits for your word to wreak havoc upon our enemies.##Your chapter contains-#"; -temp[60]=string(temp[59])+string(temp[34])+string(temp[35])+"##"+string(temp[36])+"##"+string(temp[37])+"##"+string(temp[38])+"##"+string(temp[39])+"##"+string(temp[40])+"##"+string(temp[41])+"##"+string(temp[42])+"##"+string(temp[43])+"##"+string(temp[44])+"##"+string(temp[45]); +temp[59] = $"CLASSIFICATION: SECTOR LOGISTICAE#++++++++++DATE: {temp[30]}#++++++++AUTHOR: MASTER ADEPT {temp[31]}#++++++++++++RE: INTRODUCTORY MISSIVE#+++++RECIPIENT: CHAPTER MASTER {temp[32]}##++THOUGHT: {temp[33]}++##I see you have made it unscathed, your grace. Death comes with you as it should! The enemy is on the horizon. Thy chapter is mighty and only waits for your word to wreak havoc upon our enemies.##Your chapter contains-"; + +temp[60] = $"{temp[59]}\n\n{temp[34]}\n\n{temp[35]}##{temp[36]}##{temp[37]}##{temp[38]}##{temp[39]}##{temp[40]}##{temp[41]}##{temp[42]}##{temp[43]}##{temp[44]}##{temp[45]}"; + -temp[61]="##Your armamentarium contains some spare equipment- "; +temp[61]="\n\nYour armamentarium contains some spare equipment- \n"; for(var u=1; u<=30; u++){ if (obj_ini.equipment[u]!="") then temp[61]+=string(obj_ini.equipment_number[u])+" "+string(obj_ini.equipment[u])+", "; if (obj_ini.equipment[u]=="") and (obj_ini.equipment[u-1]!=""){ @@ -1693,10 +1696,10 @@ if (hunt>0){ // show_message(temp[62]); // 61 : equipment // 62 : ships -var lol=160; +var lol=240; draw_set_font(fnt_small); vih=string_height(string_hash_to_newline(string(temp[60])+string(temp[61])+string(temp[62]))); -vih-=210;vih=(vih/lol)+1; +vih-=260;vih=(vih/lol)+1; if (floor(vih)=1){ for(var i=0; i<4000; i++){ - if (string_height(string_hash_to_newline(temp[65]))>210){ + if (string_height(string_hash_to_newline(temp[65]))>260){ lig=string_length(temp[65]); temp[65]=string_delete(temp[65],lig-1,1); } @@ -1726,7 +1729,7 @@ remov=string_length(string(temp[65]))+1; if (vih>=2){ temp[66]=string_delete(temp[66],1,remov); for(var i=0; i<4000; i++){ - if (string_height(string_hash_to_newline(temp[66]))>130){ + if (string_height(string_hash_to_newline(temp[66]))>lol){ lig=string_length(temp[66]); temp[66]=string_delete(temp[66],lig-1,1); } From 68aa75275f93ae1084db4afd5bdc664c4581abc6 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 3 Nov 2024 04:32:12 +0300 Subject: [PATCH 03/14] All string functions in one file --- ChapterMaster.yyp | 8 +- .../scr_convert_to_string.gml | 15 --- .../scr_convert_to_string.yy | 11 -- .../scr_string_functions.gml | 110 ++++++++++++++++++ scripts/string_reverse/string_reverse.gml | 20 ---- scripts/string_reverse/string_reverse.yy | 11 -- scripts/string_rpos/string_rpos.gml | 29 ----- scripts/string_rpos/string_rpos.yy | 11 -- .../string_to_integer/string_to_integer.gml | 47 -------- .../string_to_integer/string_to_integer.yy | 11 -- 10 files changed, 111 insertions(+), 162 deletions(-) delete mode 100644 scripts/scr_convert_to_string/scr_convert_to_string.gml delete mode 100644 scripts/scr_convert_to_string/scr_convert_to_string.yy delete mode 100644 scripts/string_reverse/string_reverse.gml delete mode 100644 scripts/string_reverse/string_reverse.yy delete mode 100644 scripts/string_rpos/string_rpos.gml delete mode 100644 scripts/string_rpos/string_rpos.yy delete mode 100644 scripts/string_to_integer/string_to_integer.gml delete mode 100644 scripts/string_to_integer/string_to_integer.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index e8dac67a17..9e6009eaae 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -792,7 +792,6 @@ {"id":{"name":"scr_music","path":"scripts/scr_music/scr_music.yy",},}, {"id":{"name":"spr_artificer_colors2","path":"sprites/spr_artificer_colors2/spr_artificer_colors2.yy",},}, {"id":{"name":"spr_bionic_eye_2","path":"sprites/spr_bionic_eye_2/spr_bionic_eye_2.yy",},}, - {"id":{"name":"string_reverse","path":"scripts/string_reverse/string_reverse.yy",},}, {"id":{"name":"clean_tags","path":"scripts/clean_tags/clean_tags.yy",},}, {"id":{"name":"spr_weapon_powfist4","path":"sprites/spr_weapon_powfist4/spr_weapon_powfist4.yy",},}, {"id":{"name":"is_specialist","path":"scripts/is_specialist/is_specialist.yy",},}, @@ -808,9 +807,7 @@ {"id":{"name":"scr_colors_initialize","path":"scripts/scr_colors_initialize/scr_colors_initialize.yy",},}, {"id":{"name":"scr_shader_initialize","path":"scripts/scr_shader_initialize/scr_shader_initialize.yy",},}, {"id":{"name":"spr_sal_mk6_helm","path":"sprites/spr_sal_mk6_helm/spr_sal_mk6_helm.yy",},}, - {"id":{"name":"string_to_integer","path":"scripts/string_to_integer/string_to_integer.yy",},}, {"id":{"name":"spr_weapon_boarding","path":"sprites/spr_weapon_boarding/spr_weapon_boarding.yy",},}, - {"id":{"name":"string_rpos","path":"scripts/string_rpos/string_rpos.yy",},}, {"id":{"name":"spr_bionics_hand","path":"sprites/spr_bionics_hand/spr_bionics_hand.yy",},}, {"id":{"name":"explode_script","path":"scripts/explode_script/explode_script.yy",},}, {"id":{"name":"relative_direction","path":"scripts/relative_direction/relative_direction.yy",},}, @@ -935,7 +932,7 @@ {"id":{"name":"scr_enemy_ai_d","path":"scripts/scr_enemy_ai_d/scr_enemy_ai_d.yy",},}, {"id":{"name":"scr_enemy_ai_e","path":"scripts/scr_enemy_ai_e/scr_enemy_ai_e.yy",},}, {"id":{"name":"scr_mission_reward","path":"scripts/scr_mission_reward/scr_mission_reward.yy",},}, - {"id":{"name":"scr_convert_to_string","path":"scripts/scr_convert_to_string/scr_convert_to_string.yy",},}, + {"id":{"name":"scr_string_functions","path":"scripts/scr_string_functions/scr_string_functions.yy",},}, {"id":{"name":"scr_income","path":"scripts/scr_income/scr_income.yy",},}, {"id":{"name":"scr_apothecary_ship","path":"scripts/scr_apothecary_ship/scr_apothecary_ship.yy",},}, {"id":{"name":"scr_apothecary_ground","path":"scripts/scr_apothecary_ground/scr_apothecary_ground.yy",},}, @@ -964,7 +961,6 @@ {"id":{"name":"scr_audience","path":"scripts/scr_audience/scr_audience.yy",},}, {"id":{"name":"spr_ba_mk7_helm","path":"sprites/spr_ba_mk7_helm/spr_ba_mk7_helm.yy",},}, {"id":{"name":"spr_intelligence_icon","path":"sprites/spr_intelligence_icon/spr_intelligence_icon.yy",},}, - {"id":{"name":"scr_truncate_string_width","path":"scripts/scr_truncate_string_width/scr_truncate_string_width.yy",},}, {"id":{"name":"spr_dread_heavy_bolter","path":"sprites/spr_dread_heavy_bolter/spr_dread_heavy_bolter.yy",},}, {"id":{"name":"spr_purity_seal","path":"sprites/spr_purity_seal/spr_purity_seal.yy",},}, {"id":{"name":"scr_zoom","path":"scripts/scr_zoom/scr_zoom.yy",},}, @@ -1001,7 +997,6 @@ {"id":{"name":"action_another_room","path":"scripts/action_another_room/action_another_room.yy",},}, {"id":{"name":"action_color","path":"scripts/action_color/action_color.yy",},}, {"id":{"name":"action_draw_ellipse","path":"scripts/action_draw_ellipse/action_draw_ellipse.yy",},}, - {"id":{"name":"scr_string","path":"scripts/scr_string/scr_string.yy",},}, {"id":{"name":"action_if_number","path":"scripts/action_if_number/action_if_number.yy",},}, {"id":{"name":"action_if_variable","path":"scripts/action_if_variable/action_if_variable.yy",},}, {"id":{"name":"spr_medicine_icon","path":"sprites/spr_medicine_icon/spr_medicine_icon.yy",},}, @@ -1022,7 +1017,6 @@ {"id":{"name":"__view_set_internal","path":"scripts/__view_set_internal/__view_set_internal.yy",},}, {"id":{"name":"__init_view","path":"scripts/__init_view/__init_view.yy",},}, {"id":{"name":"__init_global","path":"scripts/__init_global/__init_global.yy",},}, - {"id":{"name":"scr_string_plural","path":"scripts/scr_string_plural/scr_string_plural.yy",},}, {"id":{"name":"__global_object_depths","path":"scripts/__global_object_depths/__global_object_depths.yy",},}, {"id":{"name":"sReplaceColor","path":"shaders/sReplaceColor/sReplaceColor.yy",},}, {"id":{"name":"fnt_cul_14","path":"fonts/fnt_cul_14/fnt_cul_14.yy",},}, diff --git a/scripts/scr_convert_to_string/scr_convert_to_string.gml b/scripts/scr_convert_to_string/scr_convert_to_string.gml deleted file mode 100644 index 96db4c3e33..0000000000 --- a/scripts/scr_convert_to_string/scr_convert_to_string.gml +++ /dev/null @@ -1,15 +0,0 @@ -function scr_convert_company_to_string(company_num, possessive = false, flavour=false){ - var _company_num = company_num; - var _suffixes = ["st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "th"]; - var _flavours = ["Veteran", "Battle", "Battle", "Battle", "Battle", "Reserve", "Reserve", "Reserve", "Reserve", "Scout"]; - var _str_company = possessive ? "Company's" : "Company"; - - if (_company_num < 1) || (_company_num > 10) { - return ""; - } else { - var _flavour_text = flavour ? _flavours[_company_num - 1] : ""; - _company_num = string(_company_num) + _suffixes[_company_num - 1]; - var _converted_string = string_join(" ", _company_num, _flavour_text, _str_company); - return _converted_string; - } -} diff --git a/scripts/scr_convert_to_string/scr_convert_to_string.yy b/scripts/scr_convert_to_string/scr_convert_to_string.yy deleted file mode 100644 index b152abef7c..0000000000 --- a/scripts/scr_convert_to_string/scr_convert_to_string.yy +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType": "GMScript", - "resourceVersion": "1.0", - "name": "scr_convert_to_string", - "isCompatibility": false, - "isDnD": false, - "parent": { - "name": "Scripts", - "path": "folders/Scripts.yy", - }, -} \ No newline at end of file diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index 6dd74d242b..853bc1840d 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -101,3 +101,113 @@ function integer_to_letters(_integer) { return string_trim(_num_str); } + +function string_reverse(argument0) { + /* + Reverse String + Reverse a string with ease + + Argument0 - String + */ + + var str,length,i,out,char; + str=argument0 + out="" + length=string_length(argument0) + for(i=0;i 10) { + return ""; + } else { + var _flavour_text = flavour ? _flavours[_company_num - 1] : ""; + _company_num = string(_company_num) + _suffixes[_company_num - 1]; + var _converted_string = string_join(" ", _company_num, _flavour_text, _str_company); + return _converted_string; + } +} + +function string_to_integer(argument0) { + + // Argument0: string + + // This script converts a word or longer string into an integer, with each letter + // corresponding to a value from 1-26. The purpose of this is to allow a marine's + // name to generate a semi-unique variable for the future display of veterency + // decorations when inspected in management. Whether it is odd, from 0-9, and so + // on can determine what shows on their picture at certain experience values. + + var lol,m1,val; + lol=argument0;val=0; + m1=string_length(lol); + + repeat(m1){ + if (string_lower(string_char_at(lol,0))="a") then val+=1; + if (string_lower(string_char_at(lol,0))="b") then val+=2; + if (string_lower(string_char_at(lol,0))="c") then val+=3; + if (string_lower(string_char_at(lol,0))="d") then val+=4; + if (string_lower(string_char_at(lol,0))="e") then val+=5; + if (string_lower(string_char_at(lol,0))="f") then val+=6; + if (string_lower(string_char_at(lol,0))="g") then val+=7; + if (string_lower(string_char_at(lol,0))="h") then val+=8; + if (string_lower(string_char_at(lol,0))="i") then val+=9; + if (string_lower(string_char_at(lol,0))="j") then val+=10; + if (string_lower(string_char_at(lol,0))="k") then val+=11; + if (string_lower(string_char_at(lol,0))="l") then val+=12; + if (string_lower(string_char_at(lol,0))="m") then val+=13; + if (string_lower(string_char_at(lol,0))="n") then val+=14; + if (string_lower(string_char_at(lol,0))="o") then val+=15; + if (string_lower(string_char_at(lol,0))="p") then val+=16; + if (string_lower(string_char_at(lol,0))="q") then val+=17; + if (string_lower(string_char_at(lol,0))="r") then val+=18; + if (string_lower(string_char_at(lol,0))="s") then val+=19; + if (string_lower(string_char_at(lol,0))="t") then val+=20; + if (string_lower(string_char_at(lol,0))="u") then val+=21; + if (string_lower(string_char_at(lol,0))="v") then val+=22; + if (string_lower(string_char_at(lol,0))="w") then val+=23; + if (string_lower(string_char_at(lol,0))="x") then val+=24; + if (string_lower(string_char_at(lol,0))="y") then val+=25; + if (string_lower(string_char_at(lol,0))="z") then val+=26; + lol=string_delete(lol,0,1); + } + return(val); + + +} \ No newline at end of file diff --git a/scripts/string_reverse/string_reverse.gml b/scripts/string_reverse/string_reverse.gml deleted file mode 100644 index 2afe22d872..0000000000 --- a/scripts/string_reverse/string_reverse.gml +++ /dev/null @@ -1,20 +0,0 @@ -function string_reverse(argument0) { - /* - Reverse String - Reverse a string with ease - - Argument0 - String - */ - - var str,length,i,out,char; - str=argument0 - out="" - length=string_length(argument0) - for(i=0;i Date: Sun, 3 Nov 2024 06:39:13 +0300 Subject: [PATCH 04/14] Capitalize arg to int to word func --- scripts/scr_string_functions/scr_string_functions.gml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index 853bc1840d..2fbe09f197 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -70,7 +70,7 @@ function string_truncate(_text, _max_width) { } } -function integer_to_letters(_integer) { +function integer_to_letters(_integer, _capitalize = false) { var _ones = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; var _teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; var _tens = ["", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; @@ -99,7 +99,13 @@ function integer_to_letters(_integer) { } } - return string_trim(_num_str); + _num_str = string_trim(_num_str); + + if (_capitalize) { + string_upper_first(_num_str); + } + + return _num_str; } function string_reverse(argument0) { From ed60ebd4c708709cc38cb814774ef83d321dd736 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 3 Nov 2024 07:01:49 +0300 Subject: [PATCH 05/14] Place handle_exception() into most catch --- objects/obj_controller/Draw_0.gml | 8 ++++---- objects/obj_star/Draw_0.gml | 2 +- scripts/JsonFileListLoader/JsonFileListLoader.gml | 4 ++-- scripts/UIRenderComponents/UIRenderComponents.gml | 2 +- scripts/scr_add_artifact/scr_add_artifact.gml | 2 +- scripts/scr_cheatcode/scr_cheatcode.gml | 3 --- scripts/scr_company_order/scr_company_order.gml | 2 +- scripts/scr_has_adv/scr_has_adv.gml | 2 +- scripts/scr_has_disadv/scr_has_disadv.gml | 2 +- scripts/scr_librarium/scr_librarium.gml | 2 +- scripts/scr_random_event/scr_random_event.gml | 2 +- scripts/scr_string_functions/scr_string_functions.gml | 2 +- .../scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml | 2 +- 13 files changed, 16 insertions(+), 19 deletions(-) diff --git a/objects/obj_controller/Draw_0.gml b/objects/obj_controller/Draw_0.gml index 935220b230..1b20b40b28 100644 --- a/objects/obj_controller/Draw_0.gml +++ b/objects/obj_controller/Draw_0.gml @@ -3,7 +3,7 @@ try{ scr_ui_manage(); } catch(_exception){ - show_debug_message(_exception); + handle_exception(_exception); manage = 0; menu = 0; @@ -11,21 +11,21 @@ try{ try{ scr_ui_advisors(); } catch(_exception){ - show_debug_message(_exception); + handle_exception(_exception); manage = 0; menu = 0; } try{ scr_ui_diplomacy(); } catch(_exception){ - show_debug_message(_exception); + handle_exception(_exception); manage = 0; menu = 0; } try{ scr_ui_settings(); } catch(_exception){ - show_debug_message(_exception); + handle_exception(_exception); manage = 0; menu = 0; } diff --git a/objects/obj_star/Draw_0.gml b/objects/obj_star/Draw_0.gml index 5b78b7a7e6..09c928ea39 100644 --- a/objects/obj_star/Draw_0.gml +++ b/objects/obj_star/Draw_0.gml @@ -55,7 +55,7 @@ if (!global.load && (obj_controller.zoomed || in_camera_view(star_box_shape()))) var faction_sprite = obj_img.force[owner]; draw_sprite_ext(faction_sprite,faction_index,xx+(panel_width/2)-30,yy+25, 0.60, 0.60, 0, c_white, 1); } catch(_exception){ - show_debug_message("{0}", _exception); + handle_exception(_exception); } } else { draw_sprite_ext(faction_sprite,faction_index,xx+(panel_width/2)-30,yy+25, 0.60, 0.60, 0, c_white, 1); diff --git a/scripts/JsonFileListLoader/JsonFileListLoader.gml b/scripts/JsonFileListLoader/JsonFileListLoader.gml index 41e48cd161..f3126e3475 100644 --- a/scripts/JsonFileListLoader/JsonFileListLoader.gml +++ b/scripts/JsonFileListLoader/JsonFileListLoader.gml @@ -50,8 +50,8 @@ function JsonFileListLoader() constructor { result.is_success = true; debugl($"Successfully loaded {item_total} values from {relative_file_path}"); - } catch (_ex) { - debugl($"Could not load data from {relative_file_path}: {_ex.message}."); + } catch (_exception) { + handle_exception(_exception); result.values = {}; // do not return incomplete/invalid data } finally { if (is_undefined(file_buffer) == false) { diff --git a/scripts/UIRenderComponents/UIRenderComponents.gml b/scripts/UIRenderComponents/UIRenderComponents.gml index 851086e513..673e9bf60c 100644 --- a/scripts/UIRenderComponents/UIRenderComponents.gml +++ b/scripts/UIRenderComponents/UIRenderComponents.gml @@ -185,7 +185,7 @@ function UISpriteRendererComponent(owner, name) : UIRenderComponent(owner, name) alpha ) } catch(_exception){ - show_debug_message(_exception.message); + handle_exception(_exception); } img_index = (img_index + img_speed) % __spr_frames; } diff --git a/scripts/scr_add_artifact/scr_add_artifact.gml b/scripts/scr_add_artifact/scr_add_artifact.gml index 1554213584..7331929c5e 100644 --- a/scripts/scr_add_artifact/scr_add_artifact.gml +++ b/scripts/scr_add_artifact/scr_add_artifact.gml @@ -380,7 +380,7 @@ function corrupt_artifact_collectors(last_artifact){ } } catch( _exception){ - show_debug_message(_exception.message); + handle_exception(_exception); } } diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 7a7b733f75..6513e1809f 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -283,9 +283,6 @@ function scr_cheatcode(argument0) { } } } catch(_exception) { - log_into_file(_exception.longMessage); - log_into_file(_exception.script); - log_into_file(_exception.stacktrace); show_debug_message(_exception.longMessage); } } \ No newline at end of file diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 261b1c8150..74abf8c686 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -13,7 +13,7 @@ function temp_marine_variables(co, unit_num){ break; } } catch( _exception) { - show_debug_message("{0}",_exception); + handle_exception(_exception); unit.squad="none"; } } diff --git a/scripts/scr_has_adv/scr_has_adv.gml b/scripts/scr_has_adv/scr_has_adv.gml index 5ffc07caf8..9d5dc204ce 100644 --- a/scripts/scr_has_adv/scr_has_adv.gml +++ b/scripts/scr_has_adv/scr_has_adv.gml @@ -11,7 +11,7 @@ function scr_has_adv(advantage){ result = array_contains(obj_ini.adv, advantage); } } catch (_exception){ - show_debug_message(_exception); + handle_exception(_exception); result = false; } return result; diff --git a/scripts/scr_has_disadv/scr_has_disadv.gml b/scripts/scr_has_disadv/scr_has_disadv.gml index e35b372c99..5336dd8c39 100644 --- a/scripts/scr_has_disadv/scr_has_disadv.gml +++ b/scripts/scr_has_disadv/scr_has_disadv.gml @@ -11,7 +11,7 @@ function scr_has_disadv(disadvantage){ result = array_contains(obj_ini.dis, disadvantage); } } catch (_exception){ - show_debug_message(_exception); + handle_exception(_exception); result = false; } return result; diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index 63cdd3e5c2..c1563abd64 100644 --- a/scripts/scr_librarium/scr_librarium.gml +++ b/scripts/scr_librarium/scr_librarium.gml @@ -228,7 +228,7 @@ function scr_librarium(){ try{ artif_descr = obj_ini.artifact_struct[menu_artifact].description(); } catch( _exception){ - show_debug_message(_exception.message); + handle_exception(_exception); } tooltip = ""; tooltip_other = ""; diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 630108550c..b3fa026ab9 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -295,7 +295,7 @@ function scr_random_event(execute_now) { evented = true; } catch(_exception){ - show_debug_message("{0} \n hulk error",_exception); + handle_exception(_exception); } } } diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index 2fbe09f197..6dd6a356c9 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -18,7 +18,7 @@ function string_upper_first(_string) { return _modified_string; } catch(_exception) { - log_into_file(_exception.longMessage); + handle_exception(_exception); log_into_file(_exception.script); log_into_file(_exception.stacktrace); show_debug_message(_exception.longMessage); diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index bd9f4f6d21..faad67eb1c 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -102,7 +102,7 @@ function UnitQuickFindPanel() constructor{ } } }catch(_exception){ - show_debug_message(_exception.message); + handle_exception(_exception); } } update_mission_log(); From 9155496953512499c467ba3312a8193dea528908 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 3 Nov 2024 07:28:31 +0300 Subject: [PATCH 06/14] Fix some error in the string functions --- .../scr_string_functions/scr_string_functions.gml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index 6dd6a356c9..f9c2013349 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -5,13 +5,11 @@ function string_upper_first(_string) { try { - var _first_char; - var _modified_string; + var _first_char = string_char_at(_string, 1); + var _modified_string = _string; - _first_char = string_char_at(_string, 1); - _first_char = string_upper( _first_char ); + _first_char = string_upper(_first_char); - _modified_string = _string; _modified_string = string_delete(_modified_string, 1, 1); _modified_string = string_insert(_first_char, _modified_string, 1); @@ -19,9 +17,6 @@ function string_upper_first(_string) { } catch(_exception) { handle_exception(_exception); - log_into_file(_exception.script); - log_into_file(_exception.stacktrace); - show_debug_message(_exception.longMessage); } } @@ -102,7 +97,7 @@ function integer_to_letters(_integer, _capitalize = false) { _num_str = string_trim(_num_str); if (_capitalize) { - string_upper_first(_num_str); + _num_str = string_upper_first(_num_str); } return _num_str; From dde63f0da7600e4f2beefa4f5145a5d040a858b6 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 3 Nov 2024 22:31:41 +0300 Subject: [PATCH 07/14] Wrapping up welcome message and string function edits --- objects/obj_controller/Create_0.gml | 178 +++++++++--------- .../scr_string_functions.gml | 21 ++- 2 files changed, 105 insertions(+), 94 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index ced3b42ece..d43c1ac7ed 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1478,10 +1478,12 @@ temp[31]=string_upper(adept_name);// Adept name temp[32]=string_upper(obj_ini.name[0][0]);// Master name temp[33]=string_upper(scr_thought());// Thought of the day -// Starts the vars for the 4 pages of intro +// +// Game start welcoming message +// var njm=34,com=0,vih=0,word="",masta=0,forga=0,chapla=0,apa=0,liba=0,techa=0,libra=0,coda=0,lexa=0,apotha=0,old_dudes=0; -var honoh=0,termi=0,veter=0,capt=0,chap=0,apoth=0,stand=0,dread=0,tact=0,assa=0,deva=0,rhino=0,speeder=0,raider=0,standard=0,bike=0,scou=0,whirl=0,pred=0; +var honoh=0,termi=0,veter=0,capt=0,chap=0,apoth=0,stand=0,dread=0,champ=0,tact=0,assa=0,deva=0,rhino=0,speeder=0,raider=0,standard=0,bike=0,scou=0,whirl=0,pred=0,lib=0,serg=0,vet_serg=0; for(var mm=0; mm<=100; mm++){ if (obj_ini.role[com,mm]=="Chapter Master") then masta=1; if (obj_ini.role[com,mm]=="Forge Master") then forga=1; @@ -1510,21 +1512,21 @@ vih=string_pos(",",temp[njm]); temp[njm]=string_delete(temp[njm],vih,1); njm+=1; temp[njm] = "Specialist branches staffed by"; -if (techa > 0) then temp[njm] += $", {integer_to_letters(techa)} {string_plural(obj_ini.role[100][16], techa)}"; -if (old_dudes > 0) then temp[njm] += $", {integer_to_letters(old_dudes)} {string_plural(obj_ini.role[100][14], old_dudes)}"; -if (apotha > 0) then temp[njm] += $", {integer_to_letters(apotha)} {string_plural(obj_ini.role[100][15], apotha)}"; -if (libra > 0) then temp[njm] += $", {integer_to_letters(libra)} {string_plural(obj_ini.role[100,17], libra)}"; -if (coda > 0) then temp[njm] += $", {integer_to_letters(coda)} Codiciery"; -if (lexa > 0) then temp[njm] += $", {integer_to_letters(lexa)} Lexicanum."; +if (techa > 0) then temp[njm] += $", {techa} {string_plural(obj_ini.role[100][16], techa)}"; +if (old_dudes > 0) then temp[njm] += $", {old_dudes} {string_plural(obj_ini.role[100][14], old_dudes)}"; +if (apotha > 0) then temp[njm] += $", {apotha} {string_plural(obj_ini.role[100][15], apotha)}"; +if (libra > 0) then temp[njm] += $", {libra} {string_plural(obj_ini.role[100,17], libra)}"; +if (coda > 0) then temp[njm] += $", {coda} {string_plural("Codiciery")}"; +if (lexa > 0) then temp[njm] += $", {lexa} {string_plural("Lexicanum")}."; vih=string_pos(",",temp[njm]); temp[njm]=string_delete(temp[njm],vih,1); -if (honoh>0) then temp[njm]+=$"\n\nHonour Guard, having the {integer_to_letters(honoh)} most veteran {string_plural("marine", honoh)} of your chapter serving in it."; +if (honoh>0) then temp[njm]+=$"\n\nHonour Guard, having the {honoh} most veteran {string_plural("marine", honoh)} of your chapter serving in it."; for(var company=0; company<10; company++){ - njm+=1; - com+=1; + njm++; + com++; fisted=0; techa=0; termi=0; @@ -1534,6 +1536,7 @@ for(var company=0; company<10; company++){ apoth=0; stand=0; dread=0; + champ=0; tact=0; assa=0; deva=0; @@ -1545,20 +1548,29 @@ for(var company=0; company<10; company++){ scou=0; whirl=0; pred=0; + lib=0; + serg=0; + vet_serg=0; for(var mm=1; mm<=400; mm++){ - if (obj_ini.role[com,mm]==obj_ini.role[100][4]) then termi+=1; if (obj_ini.role[com,mm]==obj_ini.role[100][3]) then veter+=1; - if (obj_ini.role[com,mm]=="Venerable "+string(obj_ini.role[100][6])) then dread+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][4]) then termi+=1; if (obj_ini.role[com,mm]==obj_ini.role[100][5]) then capt+=1; - if (obj_ini.role[com,mm]==obj_ini.role[100][14]) then chap+=1; - if (obj_ini.role[com,mm]==obj_ini.role[100][15]) then apoth+=1; - if (obj_ini.role[com,mm]==obj_ini.role[100][16]) then techa+=1; - if (obj_ini.role[com,mm]==obj_ini.role[100][11]) then standard+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][6]) then dread+=1; + if (obj_ini.role[com,mm]=="Venerable "+string(obj_ini.role[100][6])) then dread+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][7]) then champ+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][8]) then tact+=1; - if (obj_ini.role[com,mm]==obj_ini.role[100][10]) then assa+=1; if (obj_ini.role[com,mm]==obj_ini.role[100][9]) then deva+=1; - if (obj_ini.role[com,mm]==obj_ini.role[100][6]) then dread+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][10]) then assa+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][11]) then standard+=1; if (obj_ini.role[com,mm]==obj_ini.role[100][12]) then scou+=1; + + if (obj_ini.role[com,mm]==obj_ini.role[100][14]) then chap+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][15]) then apoth+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][16]) then techa+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][17]) then lib+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][18]) then serg+=1; + if (obj_ini.role[com,mm]==obj_ini.role[100][19]) then vet_serg+=1; } for(vih=1; vih<=100; vih++){ if (obj_ini.veh_role[com,vih]=="Land Raider") then raider+=1; @@ -1569,50 +1581,35 @@ for(var company=0; company<10; company++){ if (obj_ini.veh_role[com,vih]=="Whirlwind") then whirl+=1; } - if (com==1) then word="first"; - if (com==2) then word="second"; - if (com==3) then word="third"; - if (com==4) then word="fourth"; - if (com==5) then word="fifth"; - if (com==6) then word="sixth"; - if (com==7) then word="seventh"; - if (com==8) then word="eighth"; - if (com==9) then word="ninth"; - if (com==10) then word="tenth"; - if (com>=1){ - if (veter+termi+stand+dread+tact+assa+deva+rhino+raider+standard+scou+whirl>0) then temp[njm]="You have the "+string(word)+" company. It has"; + if (com > 0){ + if (veter+termi+stand+dread+tact+assa+deva+rhino+raider+standard+scou+whirl>0) then temp[njm]=$"{integer_to_letters(com, true, true)} company made of"; else{temp[njm]="";} } - if (capt==1) then temp[njm]+=", "+string(capt)+" "+string(obj_ini.role[100][5]); - if (chap==1) then temp[njm]+=", "+string(chap)+" "+string(obj_ini.role[100][14]); - if (chap>1) then temp[njm]+=", "+string(chap)+" "+string(obj_ini.role[100][14])+"s"; - if (apoth==1) then temp[njm]+=", "+string(apoth)+" "+string(obj_ini.role[100][15]); - if (apoth>1) then temp[njm]+=", "+string(apoth)+" "+string(obj_ini.role[100][15])+"s"; - if (techa==1) then temp[njm]+=", "+string(techa)+" "+string(obj_ini.role[100][16]); - if (techa>1) then temp[njm]+=", "+string(techa)+" "+string(obj_ini.role[100][16])+"s"; + if (capt > 0) then temp[njm] += $", {capt} {string_plural(obj_ini.role[100][5], capt)}"; + if (chap > 0) then temp[njm] += $", {chap} {string_plural(obj_ini.role[100][14], chap)}"; + if (apoth > 0) then temp[njm] += $", {apoth} {string_plural(obj_ini.role[100][15], apoth)}"; + if (techa > 0) then temp[njm] += $", {techa} {string_plural(obj_ini.role[100][16], techa)}"; + if (standard > 0) then temp[njm] += $", {standard} {string_plural(obj_ini.role[100][11], standard)}"; + if (champ > 0) then temp[njm] += $", {champ} {string_plural(obj_ini.role[100][7], champ)}"; + if (lib > 0) then temp[njm] += $", {lib} {string_plural(obj_ini.role[100][17], lib)}"; + + if (serg > 0) then temp[njm] += $", {serg} {string_plural(obj_ini.role[100][18], serg)}"; + if (vet_serg > 0) then temp[njm] += $", {vet_serg} {string_plural(obj_ini.role[100][19], vet_serg)}"; + if (termi > 0) then temp[njm] += $", {termi} {string_plural(obj_ini.role[100][4], termi)}"; + if (veter > 0) then temp[njm] += $", {veter} {string_plural(obj_ini.role[100][3], veter)}"; + if (tact > 0) then temp[njm] += $", {tact} {string_plural(obj_ini.role[100][8], tact)}"; + if (assa > 0) then temp[njm] += $", {assa} {string_plural(obj_ini.role[100][10], assa)}"; + if (deva > 0) then temp[njm] += $", {deva} {string_plural(obj_ini.role[100][9], deva)}"; + if (scou > 0) then temp[njm] += $", {scou} {string_plural(obj_ini.role[100][12], scou)}"; + if (dread > 0) then temp[njm] += $", {dread} {string_plural(obj_ini.role[100][6], dread)}"; - if (standard==1) then temp[njm]+=", "+string(standard)+" "+string(obj_ini.role[100][11])+"s"; - if (termi>0) then temp[njm]+=", "+string(termi)+" "+string(obj_ini.role[100][4])+"s"; - if (veter>0) then temp[njm]+=", "+string(veter)+" "+string(obj_ini.role[100][3])+"s"; - if (tact>0) then temp[njm]+=", "+string(tact)+" "+string(obj_ini.role[100][8])+"s"; - if (assa>0) then temp[njm]+=", "+string(assa)+" "+string(obj_ini.role[100][10])+"s"; - if (deva>0) then temp[njm]+=", "+string(deva)+" "+string(obj_ini.role[100][9])+"s"; - if (scou>0) then temp[njm]+=", "+string(scou)+" "+string(obj_ini.role[100][12])+"s"; - if (dread==1) then temp[njm]+=", "+string(dread)+" "+string(obj_ini.role[100][6])+""; - if (dread>1) then temp[njm]+=", "+string(dread)+" "+string(obj_ini.role[100][6])+"s"; - if (raider==1) then temp[njm]+=", "+string(raider)+" Land Raider"; - if (raider>1) then temp[njm]+=", "+string(raider)+" Land Raiders"; - if (pred==1) then temp[njm]+=", "+string(pred)+" Predator"; - if (pred>1) then temp[njm]+=", "+string(pred)+" Predators"; - if (whirl==1) then temp[njm]+=", "+string(whirl)+" Whirlwind"; - if (whirl>1) then temp[njm]+=", "+string(whirl)+" Whirlwinds"; - if (rhino==1) then temp[njm]+=", "+string(rhino)+" Rhino"; - if (rhino>1) then temp[njm]+=", "+string(rhino)+" Rhinos"; - if (speeder==1) then temp[njm]+=", "+string(speeder)+" Land Speeder"; - if (speeder>1) then temp[njm]+=", "+string(speeder)+" Land Speeders"; - if (bike==1) then temp[njm]+=", "+string(bike)+" Attack Bike"; - if (bike>1) then temp[njm]+=", "+string(raider)+" Attack Bikes"; + if (raider > 0) then temp[njm] += $", {raider} {string_plural("Land Raider", raider)}"; + if (pred > 0) then temp[njm] += $", {pred} {string_plural("Predator", pred)}"; + if (whirl > 0) then temp[njm] += $", {whirl} {string_plural("Whirlwind", whirl)}"; + if (rhino > 0) then temp[njm] += $", {rhino} {string_plural("Rhino", rhino)}"; + if (speeder > 0) then temp[njm] += $", {speeder} {string_plural("Land Speeder", speeder)}"; + if (bike > 0) then temp[njm] += $", {bike} {string_plural("Attack Bike", bike)}"; if (string_length(temp[njm])>0) then temp[njm]+="."; @@ -1628,8 +1625,8 @@ temp[60] = $"{temp[59]}\n\n{temp[34]}\n\n{temp[35]}##{temp[36]}##{temp[37]}##{te temp[61]="\n\nYour armamentarium contains some spare equipment- \n"; -for(var u=1; u<=30; u++){ - if (obj_ini.equipment[u]!="") then temp[61]+=string(obj_ini.equipment_number[u])+" "+string(obj_ini.equipment[u])+", "; +for(var u=0; u<=30; u++){ + if (obj_ini.equipment[u]!="") then temp[61]+=$"{obj_ini.equipment_number[u]} {string_plural(obj_ini.equipment[u], obj_ini.equipment_number[u])}, "; if (obj_ini.equipment[u]=="") and (obj_ini.equipment[u-1]!=""){ temp[61]=string_delete(temp[61],string_length(temp[61]),3); temp[61]+="."; @@ -1641,30 +1638,30 @@ temp[62]="##Your fleet contains "; var bb=0,sk=0,glad=0,hunt=0,ships=0,bb_names="",sk_names="",glad_names="",hunt_names=""; codex[0]="";codex_discovered[0]=0; -for(var mm=1; mm<=30; mm++){ +for(var mm=0; mm<=30; mm++){ if (obj_ini.ship[mm]!=""){ - ships+=1; - if (obj_ini.ship_class[mm]=="Battle Barge"){ - bb+=1; - bb_names+=", "+string(obj_ini.ship[mm]); + ships++; + if (obj_ini.ship_class[mm] == "Battle Barge") { + bb++; + bb_names += $", {obj_ini.ship[mm]}"; } - if (obj_ini.ship_class[mm]=="Strike Cruiser"){ - sk+=1; - sk_names+=", "+string(obj_ini.ship[mm]); + if (obj_ini.ship_class[mm] == "Strike Cruiser") { + sk++; + sk_names += $", {obj_ini.ship[mm]}"; } - if (obj_ini.ship_class[mm]=="Gladius"){ - glad+=1; - glad_names+=", "+string(obj_ini.ship[mm]); + if (obj_ini.ship_class[mm] == "Gladius") { + glad++; + glad_names += $", {obj_ini.ship[mm]}"; } - if (obj_ini.ship_class[mm]=="Hunter"){ - hunt+=1; - hunt_names+=", "+string(obj_ini.ship[mm]); + if (obj_ini.ship_class[mm] == "Hunter") { + hunt++; + hunt_names += $", {obj_ini.ship[mm]}"; } } codex[mm]=""; codex_discovered[mm]=0; } -temp[62]+=string(ships)+" warships.#"; +temp[62]+=string(ships)+$" {string_plural("warship")}.#"; vih=string_pos(",",bb_names); bb_names=string_delete(bb_names,vih,1); @@ -1675,23 +1672,26 @@ glad_names=string_delete(glad_names,vih,1); vih=string_pos(",",hunt_names); hunt_names=string_delete(hunt_names,vih,1); -if (obj_ini.fleet_type != ePlayerBase.home_world) or (bb==1) then temp[62]+="Your flagship is the Battle Barge "+string(obj_ini.ship[1])+". "; -if (obj_ini.fleet_type==ePlayerBase.home_world) and (bb>1){ - temp[62]+="There are "+string(bb)+" Battle Barges; "+string(bb_names)+". "; +if (obj_ini.fleet_type != ePlayerBase.home_world || bb == 1) + temp[62] += $"Your flagship is the Battle Barge {obj_ini.ship[1]}. "; +if (obj_ini.fleet_type == ePlayerBase.home_world && bb > 1) { + temp[62] += $"There are {bb} {string_plural("Battle Barge")}; {bb_names}. "; } -temp[62]+="#"; -if (sk>0){ - temp[62]+="There are "+string(sk)+" Strike Cruisers; "+string(sk_names)+". "; - temp[62]+="#"; +temp[62] += "#"; +if (sk > 0) { + temp[62] += $"There are {sk} {string_plural("Strike Cruiser")}; {sk_names}. "; + temp[62] += "#"; } -if (glad>0){ - temp[62]+="There are "+string(glad)+" Gladius Escorts; "+string(glad_names)+". "; - temp[62]+="#"; +if (glad > 0) { + temp[62] += $"There are {glad} {string_plural("Gladius Escort")}; {glad_names}. "; + temp[62] += "#"; } -if (hunt>0){ - temp[62]+="There are "+string(hunt)+" Hunter Escorts; "+string(hunt_names)+"."; - temp[62]+="#"; +if (hunt > 0) { + temp[62] += $"There are {hunt} {string_plural("Hunter Escort")}; {hunt_names}."; + temp[62] += "#"; } + + // show_message(temp[61]); // show_message(temp[62]); // 61 : equipment diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index f9c2013349..c9d8619fde 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -65,14 +65,12 @@ function string_truncate(_text, _max_width) { } } -function integer_to_letters(_integer, _capitalize = false) { - var _ones = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; +function integer_to_letters(_integer, _capitalize_first = false, _possessive = false) { + var _ones = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; var _teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; var _tens = ["", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; var _thousands = ["", "thousand", "million", "billion"]; - if (_integer == 0) return "zero"; // Handle zero - var _num_str = ""; var _num_int = floor(_integer); @@ -96,7 +94,20 @@ function integer_to_letters(_integer, _capitalize = false) { _num_str = string_trim(_num_str); - if (_capitalize) { + // Convert to possessive ordinal form if needed + if (_possessive) { + if (_num_int == 1) { + _num_str = "first"; + } else if (_num_int == 2) { + _num_str = "second"; + } else if (_num_int == 3) { + _num_str = "third"; + } else { + _num_str = $"{_num_str}th"; // Default for all other numbers + } + } + + if (_capitalize_first) { _num_str = string_upper_first(_num_str); } From 5b410b714d8a099969f688aa4858e28fd04ab4af Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 3 Nov 2024 22:45:43 +0300 Subject: [PATCH 08/14] Rework how ordinal function options works --- .../scr_string_functions.gml | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index c9d8619fde..9b5cb070df 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -65,14 +65,26 @@ function string_truncate(_text, _max_width) { } } -function integer_to_letters(_integer, _capitalize_first = false, _possessive = false) { - var _ones = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; - var _teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; - var _tens = ["", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; - var _thousands = ["", "thousand", "million", "billion"]; +function integer_to_letters(_integer, _capitalize_first = false, _ordinal = false) { + var _ones = []; + var _teens = []; + var _tens = []; + var _thousands = []; + + if (_ordinal) { + _ones = ["zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"]; + _teens = ["tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth"]; + _tens = ["", "tenth", "twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth"]; + _thousands = ["", "thousandth", "millionth", "billionth"]; + } else { + _ones = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; + _teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; + _tens = ["", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; + _thousands = ["", "thousand", "million", "billion"]; + } var _num_str = ""; - var _num_int = floor(_integer); + var _num_int = floor(real(_integer)); if (_num_int < 10) { _num_str += _ones[_num_int]; @@ -94,19 +106,6 @@ function integer_to_letters(_integer, _capitalize_first = false, _possessive = f _num_str = string_trim(_num_str); - // Convert to possessive ordinal form if needed - if (_possessive) { - if (_num_int == 1) { - _num_str = "first"; - } else if (_num_int == 2) { - _num_str = "second"; - } else if (_num_int == 3) { - _num_str = "third"; - } else { - _num_str = $"{_num_str}th"; // Default for all other numbers - } - } - if (_capitalize_first) { _num_str = string_upper_first(_num_str); } From 9422530e9ed7ca618264524018fa2e85c5e3e201 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 4 Nov 2024 22:13:37 +0300 Subject: [PATCH 09/14] fix: check for count before plural --- objects/obj_controller/Create_0.gml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index d43c1ac7ed..72ab556daa 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1516,8 +1516,8 @@ if (techa > 0) then temp[njm] += $", {techa} {string_plural(obj_ini.role[100][16 if (old_dudes > 0) then temp[njm] += $", {old_dudes} {string_plural(obj_ini.role[100][14], old_dudes)}"; if (apotha > 0) then temp[njm] += $", {apotha} {string_plural(obj_ini.role[100][15], apotha)}"; if (libra > 0) then temp[njm] += $", {libra} {string_plural(obj_ini.role[100,17], libra)}"; -if (coda > 0) then temp[njm] += $", {coda} {string_plural("Codiciery")}"; -if (lexa > 0) then temp[njm] += $", {lexa} {string_plural("Lexicanum")}."; +if (coda > 0) then temp[njm] += $", {coda} {string_plural("Codiciery", coda)}"; +if (lexa > 0) then temp[njm] += $", {lexa} {string_plural("Lexicanum", lexa)}."; vih=string_pos(",",temp[njm]); temp[njm]=string_delete(temp[njm],vih,1); From 23035b2ec2bacc3364663557b7eb37f5383ed357 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 4 Nov 2024 23:19:05 +0300 Subject: [PATCH 10/14] Renamer integer_to_letters into integer_to_words --- objects/obj_controller/Create_0.gml | 2 +- scripts/scr_string_functions/scr_string_functions.gml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 72ab556daa..1da47b1cd6 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1582,7 +1582,7 @@ for(var company=0; company<10; company++){ } if (com > 0){ - if (veter+termi+stand+dread+tact+assa+deva+rhino+raider+standard+scou+whirl>0) then temp[njm]=$"{integer_to_letters(com, true, true)} company made of"; + if (veter+termi+stand+dread+tact+assa+deva+rhino+raider+standard+scou+whirl>0) then temp[njm]=$"{integer_to_words(com, true, true)} company made of"; else{temp[njm]="";} } diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index 9b5cb070df..3cb1c637bf 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -65,7 +65,7 @@ function string_truncate(_text, _max_width) { } } -function integer_to_letters(_integer, _capitalize_first = false, _ordinal = false) { +function integer_to_words(_integer, _capitalize_first = false, _ordinal = false) { var _ones = []; var _teens = []; var _tens = []; @@ -93,11 +93,11 @@ function integer_to_letters(_integer, _capitalize_first = false, _ordinal = fals } else if (_num_int < 100) { _num_str += _tens[floor(_num_int / 10)] + (_num_int % 10 != 0 ? " " + _ones[_num_int % 10] : ""); } else if (_num_int < 1000) { - _num_str += _ones[floor(_num_int / 100)] + " hundred" + (_num_int % 100 != 0 ? " " + integer_to_letters(_num_int % 100) : ""); + _num_str += _ones[floor(_num_int / 100)] + " hundred" + (_num_int % 100 != 0 ? " " + integer_to_words(_num_int % 100) : ""); } else { for (var _i = 0; _num_int > 0; _i += 1) { if (_num_int % 1000 != 0) { - var _part = integer_to_letters(_num_int % 1000); + var _part = integer_to_words(_num_int % 1000); _num_str = _part + " " + _thousands[_i] + (_num_str != "" ? " " : "") + _num_str; } _num_int = floor(_num_int / 1000); From 6034c7bee6f767362f288cd9e7c099b0f14b2928 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Mon, 4 Nov 2024 23:46:11 +0300 Subject: [PATCH 11/14] JSDoc to all string functions, minor var name changes --- .../scr_string_functions.gml | 88 +++++++++++-------- 1 file changed, 51 insertions(+), 37 deletions(-) diff --git a/scripts/scr_string_functions/scr_string_functions.gml b/scripts/scr_string_functions/scr_string_functions.gml index 3cb1c637bf..ebbb784f14 100644 --- a/scripts/scr_string_functions/scr_string_functions.gml +++ b/scripts/scr_string_functions/scr_string_functions.gml @@ -1,8 +1,7 @@ /// @function string_upper_first /// @description Capitalizes the first character in a string. -/// @param {string} _string The string to be modified. -/// @returns {string} Modified string. - +/// @param {string} _string +/// @returns {string} function string_upper_first(_string) { try { var _first_char = string_char_at(_string, 1); @@ -22,6 +21,9 @@ function string_upper_first(_string) { /// @function string_plural /// @description This function formats a string into a plural form by adding affixes following common rules. +/// @param {string} _string +/// @param {real} _variable (Optional) Variable to check if more than 1 before converting to plural. +/// @returns {string} Modified string. function string_plural(_string, _variable = 2) { if (_variable < 2) { return _string; @@ -45,26 +47,32 @@ function string_plural(_string, _variable = 2) { /// @function string_truncate /// @description Truncates a string to fit within a specified pixel width, appending "..." if the string was truncated. -/// @param {string} _text The string to be truncated. -/// @param {int} _max_width The maximum allowable pixel width for the string. -/// @returns {string} Original or truncated string. -function string_truncate(_text, _max_width) { +/// @param {string} _string +/// @param {real} _max_width The maximum allowable pixel width for the string. +/// @returns {string} +function string_truncate(_string, _max_width) { var _ellipsis = "..."; var _ellipsis_width = string_width(_ellipsis); - var _text_width = string_width(_text); + var _text_width = string_width(_string); if (_text_width > _max_width) { - var i = string_length(_text); + var i = string_length(_string); while (_text_width + _ellipsis_width > _max_width && i > 0) { i--; - _text = string_delete(_text, i+1, 1); - _text_width = string_width(_text + _ellipsis); + _string = string_delete(_string, i+1, 1); + _text_width = string_width(_string + _ellipsis); } - return _text + _ellipsis; + return _string + _ellipsis; } else { - return _text; + return _string; } } +/// @function integer_to_words +/// @description Converts an integer to an english word. +/// @param {real} _integer +/// @param {bool} _capitalize_first Capitalize first letter of the resulting word? +/// @param {bool} _ordinal Use ordinal form? +/// @returns {string} function integer_to_words(_integer, _capitalize_first = false, _ordinal = false) { var _ones = []; var _teens = []; @@ -113,26 +121,28 @@ function integer_to_words(_integer, _capitalize_first = false, _ordinal = false) return _num_str; } -function string_reverse(argument0) { - /* - Reverse String - Reverse a string with ease - - Argument0 - String - */ - +/// @function string_reverse +/// @description Returns the string written backwards. +/// @param {string} _string +/// @returns {string} +function string_reverse(_string) { var str,length,i,out,char; - str=argument0 + str=_string out="" - length=string_length(argument0) - for(i=0;i Date: Mon, 4 Nov 2024 23:57:48 +0300 Subject: [PATCH 12/14] Fix page count display, add mixin tag --- objects/obj_controller/Create_0.gml | 29 +++++++++++---------- scripts/scr_ui_advisors/scr_ui_advisors.gml | 5 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 1da47b1cd6..5c36cf2e2c 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1698,25 +1698,26 @@ if (hunt > 0) { // 62 : ships var lol=240; draw_set_font(fnt_small); -vih=string_height(string_hash_to_newline(string(temp[60])+string(temp[61])+string(temp[62]))); -vih-=260;vih=(vih/lol)+1; +welcome_pages=string_height(string_hash_to_newline(string(temp[60])+string(temp[61])+string(temp[62]))); +welcome_pages-=260; +welcome_pages=(welcome_pages/lol)+1; -if (floor(vih)=1){ +if (welcome_pages>=1){ for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[65]))>260){ lig=string_length(temp[65]); @@ -1726,7 +1727,7 @@ if (vih>=1){ } remov=string_length(string(temp[65]))+1; -if (vih>=2){ +if (welcome_pages>=2){ temp[66]=string_delete(temp[66],1,remov); for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[66]))>lol){ @@ -1738,7 +1739,7 @@ if (vih>=2){ remov=string_length(string(temp[65])+string(temp[66]))+1; // show_message(remov); -if (vih>=3){ +if (welcome_pages>=3){ temp[67]=string_delete(temp[67],1,remov); for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[67]))>lol){ @@ -1749,8 +1750,8 @@ if (vih>=3){ } remov=string_length(string(temp[65])+string(temp[66])+string(temp[67]))+1; -if (vih<4) then temp[68]=""; -if (vih>=4){ +if (welcome_pages<4) then temp[68]=""; +if (welcome_pages>=4){ temp[68]=string_delete(temp[68],1,remov); for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[68]))>lol){ @@ -1761,8 +1762,8 @@ if (vih>=4){ } remov=string_length(string(temp[65])+string(temp[66])+string(temp[67])+string(temp[68]))+1; -if (vih<5) then temp[69]=""; -if (vih>=5){ +if (welcome_pages<5) then temp[69]=""; +if (welcome_pages>=5){ temp[69]=string_delete(temp[69],1,remov); for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[69]))>lol){ diff --git a/scripts/scr_ui_advisors/scr_ui_advisors.gml b/scripts/scr_ui_advisors/scr_ui_advisors.gml index 9eb118b5ed..f7a4dabb8a 100644 --- a/scripts/scr_ui_advisors/scr_ui_advisors.gml +++ b/scripts/scr_ui_advisors/scr_ui_advisors.gml @@ -1,4 +1,4 @@ - +/// @mixin obj_controller function scr_ui_advisors() { var xx, yy, blurp, eta, va; @@ -861,8 +861,7 @@ function scr_ui_advisors() { if (menu = 502) then draw_text_ext(xx + 370, yy + 72, string_hash_to_newline(string(temp[67])), -1, 660); if (menu = 503) then draw_text_ext(xx + 370, yy + 72, string_hash_to_newline(string(temp[68])), -1, 660); draw_set_halign(fa_center); - if (temp[68] = "") then draw_text(xx + 702, yy + 695, string_hash_to_newline(string(menu - 499) + "/4 (Press Any Key)")); - if (temp[68] != "") then draw_text(xx + 702, yy + 695, string_hash_to_newline(string(menu - 499) + "/4 (Press Any Key)")); + draw_text(xx + 702, yy + 695, $"{menu - 499}/{welcome_pages} (Press Any Key)"); draw_set_halign(fa_left); } From de1114f1397916344cf9000ccc1feadc87d3aa1c Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:18:52 +0300 Subject: [PATCH 13/14] New array function, edit how fleet is listed --- objects/obj_controller/Create_0.gml | 51 +++++++++---------- .../scr_array_functions.gml | 29 ++++++++++- 2 files changed, 51 insertions(+), 29 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 5c36cf2e2c..0be449939a 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1633,9 +1633,10 @@ for(var u=0; u<=30; u++){ } } + temp[62]="##Your fleet contains "; -var bb=0,sk=0,glad=0,hunt=0,ships=0,bb_names="",sk_names="",glad_names="",hunt_names=""; +var bb=0,sk=0,glad=0,hunt=0,ships=0,bb_names=[],sk_names=[],glad_names=[],hunt_names=[]; codex[0]="";codex_discovered[0]=0; for(var mm=0; mm<=30; mm++){ @@ -1643,52 +1644,46 @@ for(var mm=0; mm<=30; mm++){ ships++; if (obj_ini.ship_class[mm] == "Battle Barge") { bb++; - bb_names += $", {obj_ini.ship[mm]}"; + array_push(bb_names, string(obj_ini.ship[mm])); } if (obj_ini.ship_class[mm] == "Strike Cruiser") { sk++; - sk_names += $", {obj_ini.ship[mm]}"; + array_push(sk_names, string(obj_ini.ship[mm])); } if (obj_ini.ship_class[mm] == "Gladius") { glad++; - glad_names += $", {obj_ini.ship[mm]}"; + array_push(glad_names, string(obj_ini.ship[mm])); } if (obj_ini.ship_class[mm] == "Hunter") { hunt++; - hunt_names += $", {obj_ini.ship[mm]}"; + array_push(hunt_names, string(obj_ini.ship[mm])); } } codex[mm]=""; codex_discovered[mm]=0; } -temp[62]+=string(ships)+$" {string_plural("warship")}.#"; - -vih=string_pos(",",bb_names); -bb_names=string_delete(bb_names,vih,1); -vih=string_pos(",",sk_names); -sk_names=string_delete(sk_names,vih,1); -vih=string_pos(",",glad_names); -glad_names=string_delete(glad_names,vih,1); -vih=string_pos(",",hunt_names); -hunt_names=string_delete(hunt_names,vih,1); - -if (obj_ini.fleet_type != ePlayerBase.home_world || bb == 1) - temp[62] += $"Your flagship is the Battle Barge {obj_ini.ship[1]}. "; -if (obj_ini.fleet_type == ePlayerBase.home_world && bb > 1) { - temp[62] += $"There are {bb} {string_plural("Battle Barge")}; {bb_names}. "; +temp[62]+=string(ships)+$" {string_plural("warship")}-\n"; + +if (obj_ini.fleet_type != ePlayerBase.home_world || bb == 1) { + temp[62] += $"Your flagship, Battle Barge {obj_ini.ship[1]}."; + temp[62] += "\n"; + bb--; +} +if (bb > 0) { + temp[62] += $"{bb} {string_plural("Battle Barge")}: {array_to_string_order(bb_names)}."; + temp[62] += "\n"; } -temp[62] += "#"; if (sk > 0) { - temp[62] += $"There are {sk} {string_plural("Strike Cruiser")}; {sk_names}. "; - temp[62] += "#"; + temp[62] += $"{sk} {string_plural("Strike Cruiser")}: {array_to_string_order(sk_names)}."; + temp[62] += "\n"; } if (glad > 0) { - temp[62] += $"There are {glad} {string_plural("Gladius Escort")}; {glad_names}. "; - temp[62] += "#"; + temp[62] += $"{glad} {string_plural("Gladius Escort")}: {array_to_string_order(glad_names)}."; + temp[62] += "\n"; } if (hunt > 0) { - temp[62] += $"There are {hunt} {string_plural("Hunter Escort")}; {hunt_names}."; - temp[62] += "#"; + temp[62] += $"{hunt} {string_plural("Hunter Escort")}: {array_to_string_order(hunt_names)}."; + temp[62] += "\n"; } @@ -1696,7 +1691,7 @@ if (hunt > 0) { // show_message(temp[62]); // 61 : equipment // 62 : ships -var lol=240; +var lol=260; draw_set_font(fnt_small); welcome_pages=string_height(string_hash_to_newline(string(temp[60])+string(temp[61])+string(temp[62]))); welcome_pages-=260; diff --git a/scripts/scr_array_functions/scr_array_functions.gml b/scripts/scr_array_functions/scr_array_functions.gml index e62ea67b16..7c81f8846a 100644 --- a/scripts/scr_array_functions/scr_array_functions.gml +++ b/scripts/scr_array_functions/scr_array_functions.gml @@ -62,4 +62,31 @@ function array_to_string_list(_array) { } } return _string_list; -} \ No newline at end of file +} + +/// @function array_to_string_order +/// @description Converts an array into a string, with "," after each member and "and" before the last one. +/// @param {array} _strings_array An array of strings. +/// @return {string} +function array_to_string_order(_strings_array) { + var result = ""; + var length = array_length(_strings_array); + + // Loop through the array + for (var i = 0; i < length; i++) { + // Append the current string + result += _strings_array[i]; + + // Check if it's the last string + if (i < length - 1) { + // If it's the second last item, add " and " before the last one + if (i == length - 2) { + result += " and "; + } else { + result += ", "; + } + } + } + + return result; +} From b1f301fa0c38fc9f966b7990f78bbd1d04632856 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:46:02 +0300 Subject: [PATCH 14/14] Hopefully solve first characters getting deleted and text going over the limit --- objects/obj_controller/Create_0.gml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 0be449939a..ab1269eeaa 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1691,7 +1691,7 @@ if (hunt > 0) { // show_message(temp[62]); // 61 : equipment // 62 : ships -var lol=260; +var lol=240; draw_set_font(fnt_small); welcome_pages=string_height(string_hash_to_newline(string(temp[60])+string(temp[61])+string(temp[62]))); welcome_pages-=260; @@ -1716,7 +1716,7 @@ if (welcome_pages>=1){ for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[65]))>260){ lig=string_length(temp[65]); - temp[65]=string_delete(temp[65],lig-1,1); + temp[65]=string_delete(temp[65],lig,1); } } } @@ -1727,7 +1727,7 @@ if (welcome_pages>=2){ for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[66]))>lol){ lig=string_length(temp[66]); - temp[66]=string_delete(temp[66],lig-1,1); + temp[66]=string_delete(temp[66],lig,1); } } } @@ -1739,7 +1739,7 @@ if (welcome_pages>=3){ for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[67]))>lol){ lig=string_length(temp[67]); - temp[67]=string_delete(temp[67],lig-1,1); + temp[67]=string_delete(temp[67],lig,1); } } } @@ -1751,7 +1751,7 @@ if (welcome_pages>=4){ for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[68]))>lol){ lig=string_length(temp[68]); - temp[68]=string_delete(temp[68],lig-1,1); + temp[68]=string_delete(temp[68],lig,1); } } } @@ -1763,7 +1763,7 @@ if (welcome_pages>=5){ for(var i=0; i<4000; i++){ if (string_height(string_hash_to_newline(temp[69]))>lol){ lig=string_length(temp[69]); - temp[69]=string_delete(temp[69],lig-1,1); + temp[69]=string_delete(temp[69],lig,1); } } }