![game maker studio 2 tutorial game maker studio 2 tutorial](https://img.itch.zone/aW1hZ2UvMTQ3MDMyLzcxNzE5NC5wbmc=/original/LELzn8.png)
_str = printf(message_gold, player_name, gold_amount) Message_lose = "%s's party is completely unconscious!" įrom the very start, the strings are in a much more readable and compressed format. Message_win = "%s's party won the battle!" Message_gold = "%s's party gained %s gold!" When using printf, I should have done this: If I did this with the printf function, it would have successfully done what I wanted as printf essentially stores template strings. This is because when I defined what message_gold included, it defined it with the current value of the variable. Instead, I got the same thing for Alex’s party. I was hoping it would show how much gold Joe’s party got. Then, I decided to execute the code exactly like this: Message_lose = player_name + "'s party is completely unconscious!" Message_win = player_name + "'s party won the battle!" Message_gold = player_name + "'s party gained " + string(gold_amount) + " gold!" Now let’s say we have some form of script that creates a ton of strings for our game. Var _string = "This is " + _str1 + " example " + _str2 + "." Īs that would give the exact same output of: This is an example string. Theoretically, an alternative and more common method would be to simply type this: This section of the tutorial primarily explains an alternative method and why printf is superior to the alternative method. That would also output this: This is an example string. Printf("This is %s example %s.", _str1, _str2) Let’s say that instead of having the literal values, I had two variables like so: The primary advantage of printf is the inclusion of variables. It would then return the output: This is an example string. For example, if I typed out this: printf("This is %s example %s.", "an", "string") Then the function will identify replacement indicators and replace them with the replacement values. Printf allows a developer to simply input a string as the first argument and the rest of the remaining argument spaces as replacement values.
GAME MAKER STUDIO 2 TUTORIAL HOW TO
This tutorial teaches how to create a simplified printf function in GMS2.
![game maker studio 2 tutorial game maker studio 2 tutorial](https://i.ytimg.com/vi/BdTNFvu3DcI/maxresdefault.jpg)
What does this tutorial teach? What is printf? The concepts explored in this tutorial are: