diff options
author | Emma Miler <27428383+emma-miler@users.noreply.github.com> | 2022-02-07 00:28:10 +0100 |
---|---|---|
committer | Barichello <artur@barichello.me> | 2022-02-12 15:45:10 -0300 |
commit | 94f7f68bf9153d39fcdb38d614f1774cdb2fc33f (patch) | |
tree | 53fc9eff2ca3e294b0d19b11cd4a355203b7cdf7 /Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut | |
parent | 7e11339956c4e51a9d3901e963de0b8d5562f9d8 (diff) | |
download | NorthstarMods-94f7f68bf9153d39fcdb38d614f1774cdb2fc33f.tar.gz NorthstarMods-94f7f68bf9153d39fcdb38d614f1774cdb2fc33f.zip |
Server-side code for chathooks
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut b/Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut index a6044762b..1c5096609 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut @@ -348,16 +348,23 @@ string function GetMapDisplayDesc( string mapname ) return "#" + mapname + "_CLASSIC_DESC" } -string function StringReplace( string baseString, string searchString, string replaceString ) +string function StringReplace( string baseString, string searchString, string replaceString, bool replaceAll = false, bool caseInsensitive = false ) { - var findResult = baseString.find( searchString ) - - if ( findResult != null ) + bool loopedOnce = false + string source = caseInsensitive ? baseString.tolower() : baseString + var findResult = source.find( searchString ) + while ( findResult != null && !(loopedOnce && !replaceAll)) { string part1 = baseString.slice( 0, findResult ) string part2 = baseString.slice( findResult + searchString.len(), baseString.len() ) baseString = part1 + replaceString + part2 + source = part1 + replaceString + part2 + + loopedOnce = true + findResult = source.find( searchString ) + print("LOOPED ONCE") + print(findResult) } return baseString |