Overview
This guide is meant to give you the basic information you need when it comes to creating and using the different types of Loop events inside 001 Game Creator.
What are Loops?
Loops in 001 Game Creator works just like loops in other programming languages, where you take a variable and iterate it several times to do different functions. In this guide we’re going to go through all the different types of Loops found inside 001 Game Creator and learn the basics of how to use them in your own projects.
Numeric Loops
If you’re familiar with regular programming, a Numeric Loop is essentially a for int loop. It takes one variable that is the current number the loop is on right now. Every time the script inside the loop executes the last node, it starts again from the top with the variable increased by the amount put inside the Increment parameter of the loop node.
Example
Let’s say we want to check several variables inside a Table. We could either use a Table Axis Loop, or we could use a Numeric Loop to get the variable we set as the current axis inside the table.
This works the same way as the Numeric Loop, only backwards, meaning it’s going to count down instead of up.
Structure Loops
Actor Loops will loop through all actors of a selected Template within the selected map. You don’t have to select a Template and if you don’t, it will loop through every actor on the map.
Example
Let’s say we want to reduce the HP of all the actors in a map after a big explosion. We would then use an Actor Loop to save ourselves A LOT of time copy pasting the same event over and over again for each actor. Instead, we’ll make a loop and select Human from the Template, enter a variable and choose the map. Inside the loop, simply put a Change Health event and click the use value button and choose the variable name used in the loop. Now every Actor that fits the Human template will take that amount of damage.
The Endless Loop will run forever until you tell it to stop by using the Exit Loop event (explained below). The best way to know how to exit these loops is with a Comparison Branch to check if the desired value has been reached and then use the Exit Loop event to close the loop.
Exit Loops are used to close any loop if placed inside the loop script. Most of the time you’ll use this event when the desired value or effects have been reached.
Field Loops work similar to Actor Loop, except they don’t take a Template parameter. Instead it has a Spawner parameter. They will loop through all the fields inside an Interface and perform a script in the same way. If you select a Spawner, only the fields spawned from that Field will be looped through. If you want to loop through all the Fields, select (none).
Interface Loops go through every interface in your project and performs a script based on each of them.
Light Loops go through all the lights placed inside a map.
Example
We want to change the color of several lights to show the player they have done something correctly and can proceed in the level. Instead of copy pasting a lot of nodes, we can instead use a Light Loop to go through the lights in the scene. If you also add a Comparison Branch to check the ID of the light, you can have it be performed only on select lights. In this example we’d name those lights Alarm 0, Alarm, 1, Alarm 2 and so on. In the Comparison Branch, you can check if the Light(variable).Name CONTAINS Alarm and if it does, do the script.
WARNING
Some events related to Lights, especially Position and Change Radius can severely affect your performance, so use them with caution.
This will loop through every map in your project, similar to Interface Loops.
Example
Your game needs a Time of Day feature? Then Map Loops are to the rescue! You can loop through every map in your project, and set the Sun Color to the variable you specified in the loop node. This will in turn change the Sun color on all the maps.
Repeat Loops perform their script for the specified amount of times unless and Exit Loop node is used.
Example
We want to hurt an enemy for 5 damage, 5 times. Put a Change Health event inside the Repeat loop and write 5 in the Number of Times field.
A Speaker Loop goes through all the speakers in a map.
Example
We want all the sounds to become lower in our map. By doing a Speaker Loop, you can change the position of the Speaker to a higher Z value to make it sound like the sound is lower. This might not work as well in a 3D game (I haven’t tested it there).
Timer/Spawn Loops go through all the Timers in a map.
Example
We want to increase the time between ticks in our Timers. Inside of a Timer/Spawn Loop, put a Change Interval node and select your variable using the use value button. Then set the Time to whatever suits your needs.
Zone Loops go through all the zones inside a map. You could use this to resize or change the position of a Zone, enable blocking or disable the zones.
Table and Collection Loops
Collection Loop
Collection Loops go through all the elements inside a Collection. Collections are lists of things, such as the players inventory, the Areas of Equipment in your project or the members in a party.
Example
We want to show a list of all the items a player has, except for Weapons. First we create a Collection Loop event and set a variable. In the Collection parameter, write Actor(“main”).Items. Click OK to enter the loop node.
Table Axis Loop
This loop does the script inside on every cell inside an Axis. The parameters defines the starting position in the Table.
Table Loop
Does a script on all the cells within a Table. Use with caution. The variable parameters are used to find out the current cell co-ordinates.