Functions (TeaScript)

AudioSet
This function allows you to play sound effects, or play/stop music. This function can be called through both level scripts and global/map scripts.

To load a sound effect:

To play a sound effect:

To stop a sound effect:

To play music:

To stop music:

BErase
Erases a bitmap, iterator, or text object when called.

Note: If you only want to temporarily hide the object, modify the object's hide property instead of using this function.

BmpCreate
This function can create a highly customizable bitmap object, but needs an NPC as the bitmap's source.

'''Use this function with caution! Performance issues may occur if too many bitmaps are created at once, and the game may crash if sx, sy, sw, and/or sh, are invalid.'''

BSet
This function is used to modify object configuration flags. The usage of this function is so complex it needs its own page, BSet (TeaScript).

EXEScript
This function is used to execute a script. When this function is called, the given script will immediately be executed and the original script will be halted until the execution of the given script completes. This can be used to call world map/global scripts. This function can be called through both level scripts and global/map scripts.

Debug
This function will output a string to the debug box. It will only work in the editor, and will not do anything in game mode. It is recommended to delete these functions after debugging for better performance. You can find the debug box by opening the debug menu and double clicking the object count.

FXCreate
This function is used to create an effect.

HUDSet
This function allows you to draw your own HUD. The function serves different purposes with the first parameter. Remember the HUD must must be initialized before adding any text or bitmaps.

To erase previous HUD data and initialize the HUD system:

To disable the custom HUD system and erase all the previous custom HUD data.

To add a bitmap to the HUD: The image source must be in a file called 'scflash.png'.

To add text to the HUD:

ItrCreate
Creates an iterator. This iterator can let you cycle between objects in a given rectangular area.

ItrNext
Continues through an iterator that was created prior. Returns the index (permanent ID) of the found object. Use this index in classes, for example  or. If the iterator is finished, this function returns 0.

You must destroy the iterator with BErase(0, ITERATOR_ID) or else the iterators won't work anymore until you restart the game. If the game does not crash but iterators stop working, it means you have an iterator leak because you forgot to berase an iterator after its usage (it occurs when more than 128 iterators exists simultaneously)

KeyPress
This function returns the user input data. This can be used to check a keyboard key, mouse cursor, and player keys being held.

LMove
This function is used to move layers.

LSet
This function is used to change the visibility of a layer. This function can be called through both level scripts and global/map scripts.

To Show/Hide/Toggle a layer:

To change the alpha value of a layer:

LSpin
This function is used to rotate layers. This function only affect NPCs and Blocks. This function can be called through both level scripts and global/map scripts.

NCreate
This function is used to spawn an NPC. The function returns the permanent id of the spawned NPC. Note that the spawned NPC becomes active until the next frame.

NCreateGroup
This function can create a group of NPCs when called. It works similarly to the NPC's HoldGenerator.

NKill
This function will destroy an NPC when called if all parameters are met.

PlayNote
This function is used to play midi notes. The first time this command is used, the game stutters for a few frames. It is recommended to use call  at the beginning of the level to avoid any stutters.

Here is a simplified way to play a note. Use this chart to identify your instruments.

Here is a simplified way to play a percussion note. Use this chart to identify your instruments.

SCSet
This function allows you to change or check the starcoin acquisition status.

To get a starcoin:

To check a starcoin acquisition status:

To clear a starcoin status:

To clear all starcoins status in a certain level:

ShowMsg
This function shows a message using a message box. RGB, quake, break, and alpha message formats are supported. This function can be called through both level scripts and global/map scripts.

Sleep
This function is used to pause the script for a number of frames.

Sleep only be used in scripts called through an event.

SpEvent
This function is used to trigger special events.

SysShowInput
Will show a message box that has a text box. This textbox can be read and stored

SysShowMsg
Will show a message box with default options.

TClear
This function clears and deletes timers, such as timers done for events.

TCreate
This function is used to call an event/create an event timer. This function can be called through both level scripts and global/map scripts.

TCreateEx
This function is used to execute a script after the set delay and pass parameters to the said script.

TxtCreate
This function is used to create a text object.