Functions (TeaScript)

From PGE Wiki
Jump to navigation Jump to search

NCreateGroup

This function can create a group of NPCs when called.

call ncreategroup(ID, X, Y, Xoffset, yoffset, NPCcount, angle, xsp, ysp, advanced)
Parameters Description
ID The ID of the NPC to be created.
X The X position of the spawn point.
Y` The Y position of the spawn point.
Xoffset Unknown. Seems to be related to a spawning ark.
Yoffset Unknown. Seems to be related to a spawning ark.
NPCcount The number of NPCs to be created.
angle Unknown. Seems to be related to a spawn angle.
Xsp The launch speed of each NPC. Each NPC spawned is launched at a fixed speed.
Ysp The Y speed of the NPCs launched.
advanced The advanced value of each NPC.

AudioSet

This function allows you to play sound effects, or play/stop music.

To load a sound effect:

call AudioSet(1, ID, Advanced, Filepath)
Parameters Description
ID The sound effect ID. Can be between 0-1024.
Advanced Whether only one 'copy' of this sound effect can be played in the same time.
Filepath The filename of the sound file. The sound file must be in the world map folder.

To play a sound effect:

call AudioSet(2, ID, 0, "")
Parameters Description
ID The ID of the sound effect. Can be between 0-1024.

To stop a sound effect:

call AudioSet(3, ID, 0, "")
Parameters Description
ID The ID of the sound effect. Can be between 0-1024.

To play music:

call AudioSet(11, FadeIn, 0, Filepath)
Parameters Description
FadeIn The duration of the fade-in effect in milliseconds.
FilePath The filename of the music file. The sound file must be in the world map folder.

To stop music:

call AudioSet(12, FadeOut, 0, "")
Parameters Description
FadeOut The duration of the fade-out effect in milliseconds.

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.

call EXEScript(ScriptName)
Parameters Description
ScriptName The script that should be executed.

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.

call Debug(String)
Parameters Description
String The string that should be outputted.


FXCreate

This function is used to create an effect.

call FXCreate(ID, X, Y, Xsp, Ysp, Frames, AnimationSpeed, Const, Gravity, Advanced)
Parameters Description
ID The effect-ID of the effect to create.
X The X-scene coordinate where the effect will be created.
Y The Y-scene coordinate where the effect will be created.
Xsp The X-speed of the effect.
Ysp The Y-speed of the effect.
Frames The number of frames the effect should last.
AnimationSpeed The number of frames each animation frame will last.
Const UNKNOWN, default 0
Gravity Should the effect be affected by Gravity?
  • 0: Yes
  • 1: No
Advanced UNKNOWN, default 0

HUDSet

This function allows you to draw your own HUD. The function serves different purposes with the first parameter.

To erase previous HUD data and initialize the HUD system:

call HUDSet("initialize", 0, 0, 0, 0, 0, 0, 0, 0, 0)

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

call HUDSet("destroy", 0, 0, 0, 0, 0, 0, 0, 0, 0)

To add a bitmap to the HUD:

call HUDSet("bitmap", ID, XSource, YSource, Width, Heigth, X, Y, Advanced, Color)

The image source must be in a file called 'scflash.png'.

Parameters Description
ID The ID used to identify the HUD bitmap (shares ID with non-HUD bitmaps).
XSource The X-position of the top-left point of the object in scflash.png.
YSource The Y-position of the top-left point of the object in scflash.png.
Width The width of the cropped bitmap.
Height The height of the cropped bitmap.
X The X-scene coordinate where the bitmap will be created.
Y The Y-scene coordinate where the bitmap will be created.
Advanced The advanced settings of the HUD bitmap.
  • 1000+(the number of chosen NPC) shows the chosen NPC graphic.
  • 5001 shows the NPC in player 1's item box.
  • 5002 shows the NPC in player 2's item box.
  • 6001 to 6003 shows the bitmap if the starcoin with that ID is acquired.
Color A certain color. The default value is -1 and type 0 to make the bitmap completely transparent.

To add text to the HUD:

call HUDSet("text", ID, X, Y, StartASCII, EndASCII, RowASCII, NPCID, Color, -1)
Parameters Description
ID The ID of the text. The function will create a new text if the ID is unused, otherwise it will overwrite the existing text.
X The x position of the text.
Y The y position of the text.
StartASCII The starting character code of the font.
EndASCII The last character code of the font.
RowASCII The number of characters in a row of the font image.
NPCID The ID of the NPC ID that contains the font used.
Color A certain color. The default value is -1 and type 0 to make the text completely transparent.

KeyPress

This function returns input data. This also can be used to check if a key is being held in statements that start with if or other similar terms.

KeyPress(ID)
Parameters Description
ID The ID of the input.
Mouse Desc.
1 Left Mouse Click
2 Right Mouse Click
-1 Mouse X-Coordinate
-2 Mouse Y-Coordinate
Player 1 Player 2 Desc.
-10 -20 Pause
-11 -21 Right
-12 -22 Left
-13 -23 Down
-14 -24 Up
-15 -25 Alt. Jump
-16 -26 Jump
-17 -27 Run
-18 -28 Alt Run
-19 -29 Select
Other Desc.
[ASCII VALUE] The ASCII value of the keyboard.

http://www.asciitable.com

LMove

This function is used to move layers.

call LMove(LayerName, Xsp, Ysp, Type)
Parameters Description
LayerName The name of the layer that you want to move.
Xsp The X-distance speed the layer should move (Xsp is difference between original and destination (i.e. value is 32, layer is moved 32 pixels from original coordinate) coordinates if shift movement was used)
Ysp The Y-distance the layer should move. (Xsp is difference between original and destination (i.e. value is 32, layer is moved 32 pixels from original coordinate) coordinates if shift movement was used)
Type The type of movement that the layer should use.
  • 0: Use speed movement. (The layer will move with the given direction)
  • 1: Use shift movement. (The layer will warp with the given direction)

LSet

This function is used to change the visibility of a layer

To Show/Hide/Toggle a layer:

call LSet(LayerName, Type, Smoke)
Parameters Description
LayerName The name of the layer that you want to change.
Type The type of layer visibility.
  • 1: Show
  • 2: Hide
  • 3: Toggle
Smoke Should there be smoke?
  • 0: Yes
  • 1: No

To change the alpha value of a layer:

call LSet(LayerName, 38, AlphaValue)
Parameters Description
LayerName The name of the layer that you want to change.
Alpha Value The alpha value of the layer. This value must be between 0-255.

LSpin

This function is used to rotate layers. This function only affect NPCs and Blocks.

call LSpin(LayerName, Xcenter, Ycenter, Speed)
Parameters Description
LayerName The name of the layer that you want to spin.
Xcenter The X-scene coordinate of the center of the circle.
Ycenter The Y-scene coordinate of the center of the circle.
Speed The spin speed. Positive values spin counterclockwise and negative values spin clockwise.

NCreate

This function is used to spawn an NPC. The function returns the permanent id of the spawned NPC.

call NCreate(ID, X, Y, Xsp, Ysp, Advance, CreationData)

'If you want the permanent id of the spawned NPC, do:
v(myVar) = NCreate(ID, X, Y, Xsp, Ysp, Advset, CreationData)

Note that the spawned NPC becomes active until the next frame.

Parameters Description
ID The NPC-ID that should be spawned.
X The X-coordinate of the spawned NPC.
Y The Y-coordinate of the spawned NPC.
Xsp The X-Speed of the spawned NPC.
Ysp The Y-Speed of the spawned NPC.
Advance The "advset" field of the spawned NPC.
CreationData Related to generators? UNKNOWN

PlayNote

This function is used to play a note.

call PlayNote(Command)
Parameters Description
Command The command can be:
  • To play a note
    • Volume*65536 + Flip*256 + 192 + Channel
  • To stop a note
    • Volume*65536 + Flip*256 +128 + Channel
  • To change the instrument
    • Patch*256 + 192 + Channel

Patch = ID of the instrument (0-127)

Volume = The volume of the note (0-100)

Flip = The pitch of the note (0-255)

Channel = The channel of the note (0-15) Default:0

ShowMsg

This function shows a message using a message box. RGB, quake, break, and alpha message formats are supported.

call ShowMsg(Message)
Parameters Description
Message The message that will be shown. It must be a string.

Sleep

This function is used to pause the script for a number of frames. It can only be used in scripts called through an event.

call sleep(Delay)
Parameters Description
Delay The number of frames the script should be paused.

SpEvent

This function is used to trigger special events.

call SpEvent(ID)
Parameters Description
ID The ID of the special event. Can be seen by right clicking the special event menu.
ID Name
0 None
1 Hurts the player.
2 Kills the player.
3 Hides the HUD.
4 Shows the HUD.
5 Hurts player 1 in battle mode.
6 Hurts player 2 in battle mode.
7 Adds a Mushroom to the map inventory.
8 Adds a Fire Flower to the map inventory.
9 Adds a Super Leaf to the map inventory.
10 Adds a Tanooki Suit to the map inventory.
11 Adds a Hammer Suit to the map inventory.
12 Adds an Ice Flower to the map inventory.
13 Adds a Frog Suit to the map inventory.
14 Adds a Starman to the map inventory.
15 Adds a P-Wing to the map inventory.
16 Adds a Hammer to the map inventory.
17 Adds a Cloud to the map inventory.
18 Adds a Shell Suit to the map inventory.
19 Adds a Propeller Mushroom to the map inventory.
20 Adds a Mini Mushroom to the map inventory.
21 Adds a Penguin Suit to the map inventory.
22 Disables the player's reserve.
23 Enables the player's reserve.
24 Adds a Music Box to the map inventory.
25 Adds a Warp Whistle to the map inventory.
26 Adds an Anchor to the map inventory.
27 Enables Wall Jumping for every player.
28 Disables Wall Jumping for every player.
29 Switches the power up system to modern style. (Revert to Super if hit)
30 Switches the power up system to classic/SMB1 style. (Revert to small if hit)
31 Adds a Green Yoshi to the map inventory.
32 Adds a Blue Yoshi to the map inventory.
33 Adds a Yellow Yoshi to the map inventory.
34 Adds a Red Yoshi to the map inventory.
35 Adds a Black Yoshi to the map inventory.
36 Adds a Purple Yoshi to the map inventory.
37 Adds a Pink Yoshi to the map inventory.
38 Adds a Cyan Yoshi to the map inventory.
39 Creates a POW Block shake effect.
40 Creates a Sledge Bro. shake effect.
41 Enables freezing objects when powering up/down.
42 Disables freezing objects when powering up/down.
43 Enables the ability to fall slower in midair if the spinjump button is held.
44 Disables the ability to fall slower in midair if the spinjump button is held.
45 Enables Yoshi's flutter jump.
46 Disables Yoshi's flutter jump.
47 Enables Ground Pound for Mario/Luigi.
48 Disables Ground Pound for Mario/Luigi.
49 Flips the screen horizontally.
50 Reverts the horizontal screen flip.
51 Flips the screen vertically.
52 Reverts the vertical screen flip.
53 Enables transparent fading in the lighting system.
54 Disables transparent fading in the lighting system.
55 Creates a Thwomp shake effect.
1045 Toggles the Yellow Switch Blocks.
1057 Toggles the Blue Switch Blocks.
1069 Toggles the Green Switch Blocks.
1073 Toggles the Red Switch Blocks.
1082 Toggles Black Switch Block behavior.
1089 Starts Stopwatch effects.
1090 Ends Stopwatch effects.
1095 Starts P-Switch effects.
1102 Ends P-Switch effects.
1115 Starts player invincibility effect.
1119 Ends player invincibility effect.
1126 Removes F.L.U.D.D from the player.
1135 Sets the F.L.U.D.D usage timer to 0.
1141 Clears the player's reserve box.
1148 Reverts the player back to small/normal.
2589 Clears all onscreen enemies as if the player finished a level.

SysShowInput

Will show a message box that has a text box.

call SysShowInput(Message, Title)

'If you want the written text, do:
str(myVar) = SysShowInput(Message, Title)
Parameters Description
Message The message that is shown in the message. Must be a string
Title The title that is shown in the message. Must be a string

SysShowMsg

Will show a message box with default options.

call SysShowMsg(Message, Type, Title)

'If you want the selected option, do:
v(myVar) = SysShowMsg(Message, Type, Title)
Parameters Description
Message The message that is shown in the message. Must be a string
Type The ID of the message box.
ID Options Available
0 "OK"
1 "OK" and "Cancel"
2 "Abort", "Retry", and "Cancel"
3 "Yes", "No", and "Cancel"
4 "Yes" and "No"
5 "Retry" and "Cancel"

This is the ID returned

Name Value
OK 1
Cancel 2
Abort 3
Retry 4
Ignore 5
Yes 6
No 7
Title The title that is shown in the message. Must be a string

TClear

call TClear(Type, EventName)
Parameters Description
Type The clear type
  • 0: To clear a specific timer.
  • 1: To clear all timers.
EventName If type is 0, then set the EventName to clear.

If type is 1, then set this to 0.

TCreate

This function is used to call an event/create an event timer.

call TCreate(EventName, Delay)
Parameters Description
EventName The event that should be called.
Delay The number of frames until the event is called.

TCreateEx

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

call TCreateEx(ScriptName, Delay, Param1, Param2, Param3)
Parameters Description
ScriptName The script that should be executed.
Delay The number of frames until the script is executed.
Param1 The value that should be passed to Sysval(Param1).
Param2 The value that should be passed to Sysval(Param2).
Param3 The value that should be passed to Sysval(Param3).

TxtCreate

This function is used to create a text object.

call TxtCreate(id, x, y, sasc, easc, cdata, lnum, fontid, flag, text)
Parameters Description
id The unique identifier of the text.
x x-position of the text.
y y-position of the text.
sasc the beginning ASCII code of the NPC image font.
easc the last ASCII code of the NPC image font.
cdata reserved.Type 0.
lnum the number of characters of a single row in the NPC image file.
fontid ID of the NPC used as the font.Use the numbers in the NPC image filename as the ID.
flag 0: coordinates will be oriented to the scene. 1: coordinates will be oriented to the screen.
text The text shown.