An Explanation of Triggers

Talk about the level designer. Read about tips and tricks and share ideas.

Moderator: Level Moderator

An Explanation of Triggers

Thumbs up x1

Postby AwesomeJRFD » April 10th, 2013, 4:19 pm


An Explanation of Triggers
By AwesomeJRFD and Raz





Have you seen this screen when opening a trigger item's properties?

Image
This is a trigger panel. With it you can make cool stuff happen, like moving items, weather, teleportation, and some other cool effects.


Advanced users have made:
Item shops
Calculators
Remakes of classic games
Bosses
And a bunch of other cool stuff.






General:


Triggers are an ASM based event system. This means that when a trigger is activated (by touching it, pressing it, killing an enemy, collecting coins, etc), it runs each function (event) from top to bottom in order. They use variables, which are a letter or word that stores an integer number.

Runouw wrote:At the moment there are about 37 trigger functions in total to pick from. Triggers are meant to function very similar to ASSEMBLY code and each instruction occurs immediately after the previous one finishes executing. You are now able to pick instructions that do branching and goto statements and set global and local variables which let you make really advanced levels.


Triggers run at 128 functions per frame.




Vocabulary:


Words and phrases that will be used in this tutorial:





Trigger Types:






Coordinates:


You may have learned that in a coordinate plane, Y values increase as they go up. In programming, and therefore in Last Legacy and Super Mario 63, the opposite is true, as shown in this picture:
Image


There are two kinds of coordinates:


Tile Coordinates:


Each unit shown on the in-game grid is a Tile Coordinate and tiles are aligned to them.

You can toggle the visibility of the grid in "View -> Display Grid".


Item Coordinates:


Each Tile Coordinate is 32 Item Coordinates. Each grid space is 32 * 32 Item Coordinates.

When moving stuff using triggers:




Tags:


Tags are "names" you can give to items. You can use them to identify specifically which items you want a trigger function to act upon.

For example, if you tag an Enemy Crab "Bob", and have a trigger function move items with the tag "Bob" 64 Item Coordinates along the X axis, that Enemy Crab you tagged "Bob" will move 64 Item Coordinates along the X axis.

- Multiple items can have the same tag.
- "this" and "self" refer to the item in which the trigger was activated.

In a function, Copy the tag from another item to reference/do something with it here.



Variables:


Stores 32bit integer value (-2147483648 through 2147483648. If you go past the limit, the value will wrap around).

Types of Variables:


Special global variables:
  • "g_COINS" = Amount of Squares collected.
  • "g_PLAYER_NAME" = Player's name. Only works in Story Mode levels since there is no way to change it in the designer. "Hero" by default.



Functions:


Image
Press this "Add New Function" button to add a function, and you will be presented with a drop-down menu that looks sort of like the one below. Click on a button to see what type of functions are listed in that category.


Image
Image
Image
Image
Image
Image
Image
Image
Image

Function List:


ImageFlow Control
"Flow Control" functions are for altering how the code runs and the order in which the compiler reads it.

ImageBranch If...
The compiler will skip to the line you specify when this command is run if a specified variable meets certain conditions.

If statement is true, will jump and continue executing code from input line. Otherwise ignores this function.



ImageGo to
The compiler will skip to the line you specify when this command is run.

Jump and continue executing code from input line.

ImageSleep
This will stop the compiler at the current line for a duration of the specified number of frames, then it will continue.
- Changing the game setting so 60 frames per second will NOT change how sleep works.

Will pause (sleep) this thread for X amount of frames (30 frames = 1 second)



ImageExit
Stops the trigger.

Will stop this thread immediately.

ImageSleep until not touched
Pauses the compiler at this line until the player is no longer touching the item from which the line is run.
- onHit triggers only.

Invisible Hitboxes:

Will pause (sleep) this thread until player is no longer touching this.

Platforms:



Will pause (sleep) this thread until:

timeOut#-of-frames pass OR: offDuration#-of-frames pass after player jumps off platform.


Sleep until on ground
This will stop the compiler at the current line until the player touches the ground.

Will sleep thread until the player is touching the ground.




ImageMath
In the "Math" section, you can manipulate variables using calculations.

ImageSet
Will set a variable to a specified number or variable.

Sets a given var to an integer or value of another var.

ImageAdd
Will set a variable to the sum of two numbers or variables.

Sets given var to sum of 2 ints/vars (a = b + c).

ImageSubtract
Will set a variable to the difference of two numbers or variables.

Sets given var to difference of 2 ints/vars (a = b - c).




ImageGame
In the "Game" section, you can find various functions which alter gameplay.

ImageGravity
Changes the orientation of the player's gravity to the specified angle.
- Gravity strength is not implemented as of the current version.
- Only affects the player.

Will set universal gravity to new variables input in this function.

ImageTime control
Slows down game events and animations to a specified percentage.
- WARNING: ONCE SET, IT WILL STAY SET WHEN EXITING THE LEVEL UNTIL IT IS SET BACK TO 100.
- Does not affect "Sleep" function.

Changes the speed of time to the percentage given

ImageBegin Cinema
Activates Cinema Mode, in which the player is frozen, but everything else moves normally.
- Useful for cutscenes.

Will change the gameplay to cinema mode. Character is paused/cannot be controlled/hurt, time flow is not affected.

ImageEnd Cinema
Stops Cinema Mode and game returns to normal.

Will turn off cinema mode

ImageMove Camera
Moves the camera to specified absolute or relative coordinates.
- Relative coordinates do not work currently.
If "use tag"" is checked, Instead of using x and y coordinates, will lock onto given item (and will follow if the item moves). x and y will specify the relative offset from item
You can also set Absolute Zoom (50% = zoomed out) (50% - 400%) or Relative Zoom (-50% = zoomed out) (-50% - 300%).
"Speed:" (Speed easing factor) will determine how quickly or slowly the camera moves to its new position. Higher numbers means slower movement (1 = instant).

Recenters camera to specified location.

ImageCamera Off
Resets camera to player and default zoom.

Resets the camera back to default settings of 100% zoom, 0 offset from character.

ImageSet Music
Changes music to specified theme.
- You cannot skip to a different point in a current song. You must set the music to "(no music)" and change back to change position in a song.
- "Start Position: " defines at which point of the song to start playing. It currently only takes integers.

List of music:
  • (no music)
  • Adventure Theme
  • Void Meadow
  • Cathedral
  • Charge
  • Desert Castle
  • Boss Battle
  • Amyxo
  • Espionage
  • Final Break
  • Icy Dungeon
  • Marcia Minor
  • Desert Theme
  • Techno Cave
  • Twisted Polka
  • Winter Theme
  • Smooth Jazz
  • In a Spirit's Presence
  • Sanctuary Echo - A capella
  • Sanctuary Echo - Orchestral
  • Inspirational Rock
  • Dark March
  • Ambient Wind SFX Loop
  • Final Theme
  • Town Theme - Valtameri
  • Overworld
  • Overworld - Piano
  • Gflat March
  • Floating Digital Clouds
  • Lava

Changes current background music.

Play Sound
Plays a specified sound from the game.
- Go to the Complete ID List for a list of all of the sounds you can currently play using this trigger.
- You can also specify the volume, from 0.1 to 3.0.

Plays the Sound Effect.

ImageMove Character
Moves the player to specified absolute or relative coordinates.
Can also set absolute or relative speed.
- Relative xspeed does not work currently.

Moves (teleports) the main character.




ImageWeather
In the "Weather" section, you can find various weather effects.

ImageSet Rain
Make it rain with a specified strength.
- Warning: This function is leaky and you may get wet.

Changes the strength of rain. Set it to 0 to turn off rain.

ImageSet Snow
Let it snow with a specified strength.

Changes the strength of snow. Set it to 0 to turn off snow.

Set Darkness
Creates a darkness effect with a specified strength.
- There is a circle of light around:
  • Player
  • Delta Orb (+ rolling)
  • Delta Negate Orb (+ rolling) (less light than Delta Orb)
  • Weapon/turret projectile
  • Enemies (not dependent on size)
  • Torch
  • Brick Fireplace
  • Invisible Light Source

Adds a darkness effect that makes it difficult to see from far away from the character.

Spawn Earthquake
Causes an earthquake with the specified magnitude/strength and duration.

Shakes the screen




ImageText
The "Text" section includes various ways of displaying text.
-Some HTML 4 is allowed.
- {$g_VARIABLENAME} in a text box with the a global variable in place of "g_VARIABLENAME" will display that global variable.

Known working HTML tags (Stuff in brackets "[]" are known working parameter types. Known working parameters are separated by "|"):
  • <p [align="left|center|right"]></p>
  • <b></b>
  • <i></i>
  • <u></u>
  • <font [size="" width="" color="" face=""]></font>
  • <a [href="" target="_blank" letterspacing=""]></a>
  • <img [src="" width="" height=""]></img> (currently broken)

ImageScreen Text
Displays text similar to the way signs display text. Freezes the character.
- Type (0-12) determines the color and texture of the background behind the text.

Pauses character and attaches text covering the screen.

ImageSubtitle Text On
A text covers the screen that does not pause the character. Can be in different parts of the screen.
- Type (0-3) determines the position of the subtitle on the screen.
- "Alpha:" determines the opacity of the white background behind the text.
- Turns off when trigger runs out.

Does not pause character. Will remain until "subtitle off" is called the thread ends. Only 1 subtitle per thread/trigger can be active at once.

ImageSubtitle Text Off
Turns off the subtitle currently being displayed from that trigger.

Removes any subtitle text this thread attached.


Dialog Text
Same as Screen Text, but displays as a dialog at the bottom of the screen, so you can still see the level.

Pauses character and shows dialog.




ImageItem
Various functions (Currently only 1) for manipulating items can be found in the "Item" section.

ImageMove Item
Moves a specified item to absolute or relative coordinates.
- "Chars stick to" determines whether the player or enemies move with the item when standing on it. If a platform is moved, characters on it will move with it.

Moves any items with the given linkage.

Scale Item
Alters the X scale, Y scale, and/or rotation of a specified item with absolute or relative values.
- Only works on items that are already scaleable and rotatable.
- Works on all disabled items.

Changes the scaling and/or rotation of a rotatable/scale-able item with a given linkage.

Teleport Enemy
Teleports the specified enemy to specified coordinates.

Teleports an enemy with the given linkage. Absolute: sets the item's x,y to that. Relative: increases it by x,y.

Create Item Drop
Spawns an item at specified coordinates or coordinates relative to specified item.
- Go to the Complete ID List for a list of all of the item drops you can create.

Creates an item drop at either x and y, or at given tag's position plus offset of x and y.

Dissolve Effect
Pauses the compiler for a specified number of frames, fades a specified item's alpha value to 1, then continues the compiler.
- Sets the items alpha to 100 before it starts fading.
- It is recommended to move the item away from the scene right afterwards, because it doesn't dissolve completely to 0, despite what the description says.

Makes the item's alpha fade to 0.

Set Color
This trigger has yet to be programmed




ImageTile
Various functions (Currently only 1) for manipulating tiles can be found in the "Tile" section.

ImageEdit Tiles
Changes a tile(s) at a specified location.
- When in a tile layer, find the coordinates of the tile you want to change. Place the new tile somewhere, highlight it, and copy it. Go back to the trigger and paste the copied tile in the "tile data:" field.
- "Back Layer" checkbox: If true, alters the tiles in the back layer.

Select & Copy the new tiles and Paste into the tile data and then choose the x and y (in units of tiles, from to-left)




ImageSpecial
The "Special" section includes various functions for controlling other Triggers and Platforms.

ImageTurn On Trigger
Enables a specified trigger to be activated.

If given the tag of a trigger, will allow the trigger to be activated (does not actually activate it).

ImageTurn Off Trigger
Disables a specified trigger.

If given the tag of a trigger, will prevent the trigger from being able to be activated again (Does not stop a currently running thread).

ImageActivate Trigger
Activates a specified trigger.
- Does not matter whether that trigger is "on" or "off"

If given the tag of a trigger, will activate the trigger's function (regardless of if it is on/off).

ImageStop Trigger
Stops a specified trigger if it is running.

If given the tag of a currently-running trigger thread, will immediately stop it.

ImagePlay Platform
Specified platform starts moving along its path if it's not already.

If given the tag of a platform not in motion, will cause platform to move (if paused/not started moving).

ImagePause Platform
Pauses a specified platform at its current location.

If given the tag of a platform in motion, will pause the platform in it's current place.

ImageReset Platform
Moves a platform back to its starting position and pauses it.

If given the tag of a platform, will reset it back to the beginning (and pauses it there).




Image// comment
"//comment" allows you to store a message in the trigger that has no effect on what the code does.

Enter any desired comment here (has no effect outside level designer).



"Secret" Functions:


Open Shop:
Code: Select all
llitem:6;0;0;64;64;0;1;openshop,1

Opens the shop. You can change the shop type by changing the last "1" in the code above.
Shop types:
  1. Default shop
  2. Empty shop
  3. Masamune shop
  4. Lightning Rod shop
  5. Winged Boots Shop

Open Enchanter:
Code: Select all
llitem:6;0;0;64;64;0;1;openenchant

Opens the Enchanter.

Set Post Filter:
Code: Select all
llitem:6;0;0;64;64;0;1;setpostfilter,0

Runouw wrote:I've decided to reveal an unfinished trigger function because it's going to be useful to many people.

This isn't an official feature in the game yet because it's a non-essential function. The flashplayer games are meant to load quickly and post-effects like rain, snow, and global color transforms were deemed "too laggy" of a feature to put in the core story levels. Also, programming the menus for it in the level designer is very taxing on time when development needs to be spent on more important things.

Anyway, for those of you who like code editing, here is the Set Post Filter function.
Code: Select all
llitem:6;322;1451;64;64;0;1;setpostfilter,100/100/100/100/0/0/0/0/0/0/-100/0

This example uses a saturation = -100, which turns the whole level monochrome.

The order of the color modifiers are the following (all require a "/" to separate them):
  • redMultiplier
  • greenMultiplier
  • blueMultiplier
  • alphaMultiplier
  • redOffset
  • greenOffset
  • blueOffset
  • alphaOffset
  • brightness
  • contrast
  • saturation
  • hue
For reference, the values do the same exact thing as if you applied a color transform an item, but instead, it applies it to the whole screen.


Semaphore V:
Code: Select all
llitem:6;0;0;64;64;0;1;v

WARNING: DOES NOT WORK. WILL CRASH GAME IF OPENED.

Semaphore P
Code: Select all
llitem:6;0;0;64;64;0;1;p

WARNING: DOES NOT WORK. WILL CRASH GAME IF OPENED.




Anything we missed? Please tell us!
Last edited by Raz on January 17th, 2016, 1:07 pm, edited 49 times in total.
Reason: Updated from the LL site's version. The other forum is pointless.
Image
User avatar
AwesomeJRFD
Honorary Member

 
Posts: 836
Joined: November 11th, 2010, 2:06 pm
Location: Sixteenth Dimension: Hyperspace

Runouw Votes Winner
Best Thread (An Explanation of Triggers) in Runouw Votes Summer 2013

Thumbs Up given: 50 times
Thumbs Up received: 38 times

Re: An Explanation Of Triggers

Postby -BY » April 10th, 2013, 8:09 pm

I've been waiting for someone to do that, though. This could help pretty much every beginner and more advanced designer. I look forward to see it finished.

If someone of you needs to edit the other ones post with more explanations or whatever, don't mind asking one of the lemons.
Image

Big thank you to FrozenFire who created this masterpiece. : )
User avatar
-BY
Honorary Member

 
Posts: 900
Joined: May 23rd, 2012, 11:43 pm
Location: 298

Razzian Fighter

Thumbs Up given: 72 times
Thumbs Up received: 100 times

Re: An Explanation Of Triggers

Postby AwesomeJRFD » April 10th, 2013, 10:01 pm

blackyoshi wrote:I've been waiting for someone to do that, though. This could help pretty much every beginner and more advanced designer. I look forward to see it finished.

If someone of you needs to edit the other ones post with more explanations or whatever, don't mind asking one of the lemons.

I've been wanting to make this for a while, but I was reluctant to do so since it might be considered a dupe of Suyo's old topic (it's totally not because I'm lazy :3). Then Raz asked me to work with him on it, and it finally got started.

I'm currently working on an update to this with more descriptions, but it's getting late so I'll finish it tomorrow.
Image
User avatar
AwesomeJRFD
Honorary Member

 
Posts: 836
Joined: November 11th, 2010, 2:06 pm
Location: Sixteenth Dimension: Hyperspace

Runouw Votes Winner
Best Thread (An Explanation of Triggers) in Runouw Votes Summer 2013

Thumbs Up given: 50 times
Thumbs Up received: 38 times

Re: An Explanation Of Triggers

Postby ~MP3 Amplifier~ » April 12th, 2013, 12:06 pm

Great one, guys. Can't wait to read up more about this.

Tbh when I've been stuck on a trigger action I've gone into other levels into editing mode and seen how they've worked them, but this will save a lot of time. :P
"I treat everyone equally, depending on how much I like them." ~Me
The below image is a montage of my individual highest placing LDC creations, as a reminder to myself that level designing is a part of my life that I can't just leave behind

Image
I made this sig so credits to mee :amp smile:
User avatar
~MP3 Amplifier~
THE DARK LAMP

Error contacting Twitter
 
Posts: 4383
Joined: May 6th, 2011, 12:35 pm
Location: Maaars d(^_^)b

SM63 Level Designer Contest Winner
LDC #30: Finale/The Ultimate Battle

Thumbs Up given: 226 times
Thumbs Up received: 611 times

Re: An Explanation Of Triggers

Postby Raz » April 12th, 2013, 12:07 pm

We're going to update it but Awesome's Internet is being bad and he can't PM me the details
Karyete, Master of Civil Conversation
Disclaimer: none of these messages have been edited, context can be provided if needed (thanks discord!) but absolutely does not change anything about these messages and that he's too overly defensive and cocky to make situations better

Karyete: I don't have anything to say to you, I've been deliberately trying to not offend you for years, actually, but apparently everything I say to you is wrong. You come across as so aggressive that you successfully intimidated me into not wanting to talk to you
Karyete: Seriously, what is your problem? And not only that, you fail to even acknowledge you might be in some wrong here.
Karyete: Oooh it's you? Hello. Feel free to drop this right now. You're going to make yourself look like an idiot.
Karyete: We don't want to hear your opinion at this stage.
Karyete: You're not getting any apology, especially after now.
Karyete: You can stay up on your high horse, continue to twist the truth and act like an absolute child all you want. I refuse to give respect to a man who right now is picking up a dropped argument because he simply cannot fathom the idea that he might be in the wrong.
Karyete: How pathetic
User avatar
Raz
"quite easily the most manly man of all" --Raz

Error contacting Twitter
 
Posts: 4432
Joined: July 12th, 2010, 5:48 pm
Location: :-)

Razzian Fighter

Thumbs Up given: 40 times
Thumbs Up received: 367 times

Re: An Explanation Of Triggers

Postby Killswitch » April 12th, 2013, 5:48 pm

Image
This trigger allows you to create a delay in events, which is based in frames (30 frames = 1 second)


Finally. Thanks. Actually, you can change it to 60 frames per second in the options which can be found by right-clicking the window.
Killswitch
Prophet of Shadowsquid

 
Posts: 1185
Joined: October 27th, 2010, 1:26 am

A Good Start

Thumbs Up given: 1309 times
Thumbs Up received: 28 times

Re: An Explanation Of Triggers

Postby Raz » April 12th, 2013, 5:53 pm

TIL
Karyete, Master of Civil Conversation
Disclaimer: none of these messages have been edited, context can be provided if needed (thanks discord!) but absolutely does not change anything about these messages and that he's too overly defensive and cocky to make situations better

Karyete: I don't have anything to say to you, I've been deliberately trying to not offend you for years, actually, but apparently everything I say to you is wrong. You come across as so aggressive that you successfully intimidated me into not wanting to talk to you
Karyete: Seriously, what is your problem? And not only that, you fail to even acknowledge you might be in some wrong here.
Karyete: Oooh it's you? Hello. Feel free to drop this right now. You're going to make yourself look like an idiot.
Karyete: We don't want to hear your opinion at this stage.
Karyete: You're not getting any apology, especially after now.
Karyete: You can stay up on your high horse, continue to twist the truth and act like an absolute child all you want. I refuse to give respect to a man who right now is picking up a dropped argument because he simply cannot fathom the idea that he might be in the wrong.
Karyete: How pathetic
User avatar
Raz
"quite easily the most manly man of all" --Raz

Error contacting Twitter
 
Posts: 4432
Joined: July 12th, 2010, 5:48 pm
Location: :-)

Razzian Fighter

Thumbs Up given: 40 times
Thumbs Up received: 367 times

Re: An Explanation Of Triggers

Postby AwesomeJRFD » April 12th, 2013, 7:07 pm

Killswitch wrote:Actually, you can change it to 60 frames per second in the options which can be found by right-clicking the window.

Actually, that doesn't affect Sleep functions. Sleep is always 30 frames per second.


I'm working on an overhaul to this post, but my internet connection dislikes me.
Last edited by AwesomeJRFD on July 20th, 2014, 12:07 pm, edited 1 time in total.
Image
User avatar
AwesomeJRFD
Honorary Member

 
Posts: 836
Joined: November 11th, 2010, 2:06 pm
Location: Sixteenth Dimension: Hyperspace

Runouw Votes Winner
Best Thread (An Explanation of Triggers) in Runouw Votes Summer 2013

Thumbs Up given: 50 times
Thumbs Up received: 38 times

Re: An Explanation Of Triggers

Postby CedarBranch » April 13th, 2013, 6:08 am

I love this thread. :awe:

Cannot wait for more work to get done.
Triple J here!
Image
Credit goes to FrozenFire/l.m
Other Stuff: show
AC:NL Info

Dream Address: 4400-3141-4504
Mayor: Triple J
Town Name: Quattom



My Super Mario Maker levels: viewtopic.php?f=77&t=46621&p=344256#p344256

My Youtube channel, if you could possibly bother: https://www.youtube.com/channel/UCuP5V8 ... subscriber

Brand-new Bomberman 64: The Second Attack Gameshark Codes!
Now on Dropbox! Active and updated irregularly.
User avatar
CedarBranch
Impulsive & ambitious

 
Posts: 1242
Joined: June 15th, 2012, 1:10 pm
Location: Reclusive. (At least I want to.)

Runouw Votes Winner
Voted "Best Level" with Essence of Time in Runouw Votes New Year 2014/15

Thumbs Up given: 384 times
Thumbs Up received: 108 times

Re: An Explanation Of Triggers

Postby AwesomeJRFD » April 13th, 2013, 1:21 pm

I just sent the updates. Now we play the waiting game. :3

EDIT: It's now up for everybody to see. Go learn some more trigger stuffs!
Image
User avatar
AwesomeJRFD
Honorary Member

 
Posts: 836
Joined: November 11th, 2010, 2:06 pm
Location: Sixteenth Dimension: Hyperspace

Runouw Votes Winner
Best Thread (An Explanation of Triggers) in Runouw Votes Summer 2013

Thumbs Up given: 50 times
Thumbs Up received: 38 times

Next

Return to Last Legacy Level Designer