Reverse Sentence Order gamemaker


create event: 

msg = "one two three for five"; //string to split
reversed="";//initialize string
splits[0]="";//initialize array
splitBy = " "; //string to split the first string by
slot = 0;//starting slot
str2 = ""; //var to hold the current split we're working on building


for (var i = 1; i < (string_length(msg)+1); i++)
{
currStr = string_copy(msg, i, 1);//get character 1 by 1
if (currStr == splitBy)//split if [space] found
{
splits[slot] = str2; //add this split to the array of all splits
slot++;
str2 = "";
}
else
{
str2 = str2 + currStr;
splits[slot] = str2;//add last word
}
}
//add back to a new string

for(var i = slot; i >-1 ; i -= 1)//start a number of slots and reduce i by one each loop
{
reversed+=splits[i]+" ";
}


draw event:

draw_text(50,40,reversed);




How to build deeper, more robust relationships | Carole Robin (Stanford GSB professor, “Touchy Feely”)

Listen now (87 mins) | Brought to you by: • Eppo—Run reliable, impactful experiments • CommandBar—AI-powered user assistance for modern prod...

Contact Form

Name

Email *

Message *