• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Asset - Scripts Simple string_split script

Status
Not open for further replies.

Appsurd

Member
Introduction

Appsurd presents you the superuseful and handy script: string_split(substr, str, ignoreEmptyStrings) ! It works on GMS 2.3+. The script returns an array which contains the splitted string. You may also choose a substring which is longer than one character! Of course the script is well-commented and you may use it for free. If you want to give us credits (not obligatory) please refer to our name Appsurd!

When is it useful?

• The script can be used to split a long string retreived from a server containing several different things.
• In a level editor, when the user wants to saves the level, this is saved in a long string. With string_split(substr,str) you can split this long string into smaller bits which you can use thereafter.
• Many more things which we would like to hear from you!

Download

The script can be downloaded FOR FREE from YoyoGames's marktplace: https://marketplace.yoyogames.com/assets/4069/simple-string_split-script

Example

Create Event
GML:
var str = "Hello world!";

var splitted_string = string_split(" ",str,false);
Draw Event
GML:
for(i=0; i<array_length(splitted_string); i+=1)
{
  draw_text(10,10+20*i,splitted_string[i]);
}
Result
Code:
Hello
world!
Conclusion

If you have any improvements or if you found a bug, please tell us so we can improve it! Rating and sharing will be appreciated! :)
 
Last edited:

Appsurd

Member
Some minor tweaks in the example above and in the Marketplace. The script, however, hasn't changed.
And please rate it if you like it!
 
Status
Not open for further replies.
Top