Tips and Kliks #03: Important Conditions

Danni's picture

In order to make sense of how and when conditions are true and to use them to create the behaviors you want, it's good to know some of the most important ones. You'll find these under either the "Special" or "Storyboard Controls" categories when you go to create a new condition.

Always and Never

The simplest conditions are the ones that are either simply true or false: Always is always true, and Never is always false.

Always is extremely important as you need it for actions which should happen continuously. For example, you might always want the screen to scroll with your player character, or you might have a turret that should always point at its target. If you have your own custom movement system you might also want to keep objects moving. These are just a few examples of things which you would want to "always" happen, and for which using the "Always" condition is basically a requirement.

Note that Always only makes sense if you aren't placing it in an event with other conditions. In such cases, Always is unnecessary, because actions will repeat for as long as the conditions are true anyway.

Never is essentially the opposite of Always. Since Never is always false, and an event requires all its conditions to be true before it runs the actions, you might be wondering how the heck Never would ever be useful. Its use is not in running actions, but not running actions. More specifically, you can use Never to disable events for debugging purposes.

Start of frame/Start of level

"Start of frame" is only ever true once: at the very beginning of your level. Therefore, you can use it to perform any kind of setup you need. Common uses include playing music, making certain objects invisible (if you're on something older than MMF2), creating and/or positioning objects according to a set of rules, etc.

Only one action when event loops

An event's actions will keep happening every step of your game as long as the conditions are true, but what if you don't want that to happen? You add "Only one action when event loops" to the event. This condition is only true if the event's conditions were not true in the previous step.

Let's say you are making an arcade game where the player gets an extra life after reaching 50,000 points. Your first attempt at the conditions might look like this:

However, doing this will cause the game to flood the player with a constant stream of extra lives! Not what you want. Now let's add "Only one action when event loops":

This rewards the player with an extra life just once after obtaining enough points.

I should note that if the player's score somehow falls below 50,000 again, the player will become eligible for another extra life. If this isn't what you want, use "Run this event once" instead of "Only one action when event loops".

Comments

vampirkat's picture

thanx this is really coming in handy

I want to be the ULTIMATE TGF GODDESS :D I've noodled around with TGF but now wanna get it going how I want. I've copied the tips and added it to my other KNP/TGF tutorials I've collected :3

pensive-mosquitoes