Difference between revisions of "Version 2 Scripts New"
Jianmingyong (talk | contribs) m |
JappaWakka (talk | contribs) m (A little bit of polishing and correcting) |
||
| (31 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
== Introduction == | |||
Version 2 scripts were started in version 0.32 and will cease support in alpha version (v1.xx). Any script in Version 2 must have "version=2" as the first line of the script. | |||
Commands are procedures that are used to tell the game what to do.<br /> | |||
Constructs are functions that returns a value in the game. | |||
Commands are written as @Command.SubCommand.<br /> | |||
Constructs are written as <Construct.SubConstruct>. | |||
Commands and constructs are not case sensitive. | |||
== A General Note to all GameMode Scripters ( Must Read ) == | |||
# This page is currently updated as of v0.53.3 Script Library. | |||
# This page contains information that is similar to what you can see when typing @help(command). | |||
# The line number shown in the crash logs starts counting at the first non-empty line of a valid command or statement. However, any line after :while: statement are continuously counted until the end loop. If there are two repeating cycle within the while loop, the number of lines doubles. | |||
== Code Conventions == | |||
=== Header === | |||
The Header is used to define the ActionScript engine you want to use for the entire script. | |||
For each script file, the header must contain "version=2". | |||
=== Statement === | |||
A Statement is used to make comparisons between constructs and parameters or to make conditions for the script to run. | |||
There are a few Statements available in the game. | |||
* :if: | |||
* :else | |||
* :endif | |||
* :while: | |||
* :exitwhile | |||
* :endwhile | |||
* :select: | |||
* :when: | |||
* :endwhen | |||
* :end | |||
* :endscript | |||
* :return: | |||
For more infomation about Statements and their usage, proceed to [[Version_2_Scripts_New#Statement_2|here]]. | |||
=== Command Declaration === | |||
A Command is used to instruct the game with a set of procedures to run. They do not return any value. | |||
You can define a Command with: @Class.Subclass | |||
=== Construct Declaration === | |||
A Construct is used to instruct the game to return a value. They can be used with Commands and Statements. | |||
You can define construct with: <Class.Subclass> | |||
=== Temporary Global Variable === | |||
Global Variables are used when you want to use a variable on another script without having to redefine it again. | |||
Assignments:<br /> | |||
@Storage.set(str,Name,Text) | |||
@Storage.set(int,Name,Number) | |||
@Storage.set(sng,Name,Number) | |||
@Storage.set(dbl,Name,Number) | |||
@Storage.set(bool,Name,Boolean) | |||
Basic math:<br /> | |||
Addition: | |||
@Storage.update(int,Name,add,Value) | |||
@Storage.update(int,Name,+,Value) | |||
Subtraction: | |||
@Storage.update(int,Name,substract,Value) | |||
@Storage.update(int,Name,-,Value) | |||
Multiplication: | |||
@Storage.update(int,Name,multiply,Value) | |||
@Storage.update(int,Name,*,Value) | |||
Division: | |||
@Storage.update(int,Name,divide,Value) | |||
@Storage.update(int,Name,/,Value) | |||
String concatenation:<br /> | |||
@Storage.update(str,Name,add,Message) | |||
@Storage.update(str,Name,+,Message) | |||
Reading:<br /> | |||
@Text.show(<Storage.get(str,Name)>) | |||
@Text.show(<Storage.get(int,Name)>) | |||
== Version 2 Class == | |||
'''Important info / definition of certain things before we get started.''' | '''Important info / definition of certain things before we get started.''' | ||
By Default, the Argument Types are: | By Default, the Argument Types are: | ||
*Str ( | *Str ( Strings are defined as letters or symbols ) | ||
*Int ( Int are | *Int ( Int ''(Integer)'' are defined as [http://en.wikipedia.org/wiki/Integer Integer numbers] ) | ||
*Sng ( Sng are | *Sng ( Sng ''(Single)'' are defined as [http://en.wikipedia.org/wiki/Real_number Real numbers] ) | ||
*ItemCollection ( ItemCollection are | *ItemCollection ( ItemCollection are defined as {itemID|amount|price} ) | ||
*Bool ( Bool are | *Bool ( Bool ''(Boolean)'' are defined either as True & False or 1 & 0 ) | ||
*IntArr ( IntArr are | *IntArr ( IntArr are defined as an array of [http://en.wikipedia.org/wiki/Integer Integer numbers], usually with commas inbetween ) | ||
*StrArr ( StrArr are | *StrArr ( StrArr are defined as an array of letters or symbols, usually with commas inbetween ) | ||
*SngArr ( SngArr are | *SngArr ( SngArr are defined as an array of [http://en.wikipedia.org/wiki/Real_number Real numbers] ) | ||
*BoolArr ( BoolArr are | *BoolArr ( BoolArr are defined as an array of words such as True, False ) | ||
*PokemonData ( PokemonData are | *PokemonData ( PokemonData are defined as [[Pokemon_Code|Pokemon Code]] ) | ||
*Arr ( Arr are | *Arr ( Arr are defined as an array of something. ) | ||
For any '''Optional Argument''', it will be underlined and | For any '''Optional Argument''', it will be underlined and have a red color, for example "<span style="text-decoration: underline; color:red;">Str1,Str2,Str3,...</span>"<br /> | ||
For any '''Array Argument''', it will be surrounded by a grouped square bracket for example "<nowiki>[Str1,Int2,Int3,Int4,Int5],Int6...</nowiki>"<br /> | For any '''Array Argument''', it will be surrounded by a grouped square bracket, for example "<nowiki>[Str1,Int2,Int3,Int4,Int5],Int6...</nowiki>"<br /> | ||
== Commands == | == Commands == | ||
Commands are scripts that tells the game what to do. | Commands are scripts that tells the game what to do. A Command comes with a @ and usually with some arguments '''('''between Parantheses like these''')''' | ||
The table below is split into sections by Command.<br /> | The table below is split into sections by Command.<br /> | ||
You may use the sort feature to make it list | You may use the sort feature to make it list contents in alphanumeric order. | ||
<!-- | <!-- | ||
| Line 60: | Line 125: | ||
{{ScriptCommandV2|Battle|starttrainer| Type = Command | {{ScriptCommandV2|Battle|starttrainer| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|trainerFile|Str|1|False||}} | | Argument1 = {{ScriptArgumentV2|trainerFile|Str|1|False||}} | ||
| Description1 = | | Description1 = Plays the default reaction of a trainer. | ||
| Input1 = {{ScriptArgumentV2|trainerFile|Str|1|False||Input}} | | Input1 = {{ScriptArgumentV2|trainerFile|Str|1|False||Input}} | ||
}} | }} | ||
{{ScriptCommandV2|Battle|trainer| Type = Command | {{ScriptCommandV2|Battle|trainer| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|trainerFile|Str|1|False||}} | | Argument1 = {{ScriptArgumentV2|trainerFile|Str|1|False||}},{{ScriptArgumentV2|additionalTrainerData|Str|2|True||}} | ||
| Description1 = | | Description1 = Start a battle with a trainer. | ||
| Input1 = {{ScriptArgumentV2|trainerFile|Str|1|False||Input}} | | Input1 = {{ScriptArgumentV2|trainerFile|Str|1|False||Input}}<br />{{ScriptArgumentV2|additionalTrainerData|Str|2|True||Input}} | ||
}} | }} | ||
{{ScriptCommandV2|Battle|wild| Type = Command | {{ScriptCommandV2|Battle|wild| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|pokemonData|PokemonData|1|False||}},{{ScriptArgumentV2|musicloop|Str|1|True||}} | | Argument1 = {{ScriptArgumentV2|pokemonData|PokemonData|1|False||}},{{ScriptArgumentV2|musicloop|Str|1|True||}} | ||
| Description1 = | | Description1 = Starts a wild battle. | ||
| Input1 = {{ScriptArgumentV2|pokemonData|PokemonData|1|False||Input}}<br />{{ScriptArgumentV2|musicloop|Str|1|True||Input}} | | Input1 = {{ScriptArgumentV2|pokemonData|PokemonData|1|False||Input}}<br />{{ScriptArgumentV2|musicloop|Str|1|True||Input}} | ||
| Argument2 = {{ScriptArgumentV2|pokemonID|Int|1|False||}},{{ScriptArgumentV2|level|Int|2|False||}},{{ScriptArgumentV2|shiny|Int|3|True|-1|}},{{ScriptArgumentV2|musicloop|Str|1|True||}},{{ScriptArgumentV2|introtype|Int|4|True|0-10|}} | | Argument2 = {{ScriptArgumentV2|pokemonID|Int|1|False||}},{{ScriptArgumentV2|level|Int|2|False||}},{{ScriptArgumentV2|shiny|Int|3|True|-1|}},{{ScriptArgumentV2|musicloop|Str|1|True||}},{{ScriptArgumentV2|introtype|Int|4|True|0-10|}} | ||
| Line 80: | Line 145: | ||
{{ScriptCommandV2|Battle|setvar| Type = Command | {{ScriptCommandV2|Battle|setvar| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|varName|Str|1|False||}},{{ScriptArgumentV2|varValue|Str|2|False||}} | | Argument1 = {{ScriptArgumentV2|varName|Str|1|False||}},{{ScriptArgumentV2|varValue|Str|2|False||}} | ||
| Description1 = Sets a battle | | Description1 = Sets a battle variable. | ||
| Input1 = {{ScriptArgumentV2|varName|Str|1|False||Input}}<br />{{ScriptArgumentV2|varValue|Str|2|False||Input}} | | Input1 = {{ScriptArgumentV2|varName|Str|1|False||Input}}<br />{{ScriptArgumentV2|varValue|Str|2|False||Input}} | ||
}} | }} | ||
{{ScriptCommandV2|Battle|resetvars| Type = Command | {{ScriptCommandV2|Battle|resetvars| Type = Command | ||
| Description1 = Reset all battle | | Description1 = Reset all battle variable. | ||
}} | }} | ||
| Line 101: | Line 166: | ||
{{ScriptCommandV2|Camera|reset| Type = Command | {{ScriptCommandV2|Camera|reset| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|}} | |||
| Description1 = Resets the camera to the default setting. | | Description1 = Resets the camera to the default setting. | ||
| Input1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|Input}} | |||
}} | }} | ||
| Line 141: | Line 208: | ||
{{ScriptCommandV2|Camera|togglethirdperson| Type = Command | {{ScriptCommandV2|Camera|togglethirdperson| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|}} | |||
| Description1 = Toggles the third person camera. | | Description1 = Toggles the third person camera. | ||
| Input1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|Input}} | |||
}} | }} | ||
{{ScriptCommandV2|Camera|activatethirdperson| Type = Command | {{ScriptCommandV2|Camera|activatethirdperson| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|}} | |||
| Description1 = Activates the third person camera. | | Description1 = Activates the third person camera. | ||
| Input1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|Input}} | |||
}} | |||
{{ScriptCommandV2|Camera|deactivethirdperson| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|}} | |||
| Description1 = Deactivates the third person camera. | |||
| Input1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|Input}} | |||
}} | }} | ||
{{ScriptCommandV2|Camera|deactivatethirdperson| Type = Command | {{ScriptCommandV2|Camera|deactivatethirdperson| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|}} | |||
| Description1 = Deactivates the third person camera. | | Description1 = Deactivates the third person camera. | ||
| Input1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|Input}} | |||
}} | |||
{{ScriptCommandV2|Camera|setthirdperson| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|thirdPerson|Bool|1|False||}},{{ScriptArgumentV2|doCameraUpdate|Bool|2|True|True|}} | |||
| Description1 = Set the camera to third person camera. | |||
| Input1 = {{ScriptArgumentV2|thirdPerson|Bool|1|False||Input}}<br />{{ScriptArgumentV2|doCameraUpdate|Bool|2|True|True|Input}} | |||
}} | }} | ||
{{ScriptCommandV2|Camera|fix| Type = Command | {{ScriptCommandV2|Camera|fix| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|}} | |||
| Description1 = Fixes the camera to the current position. | | Description1 = Fixes the camera to the current position. | ||
| Input1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|Input}} | |||
}} | }} | ||
{{ScriptCommandV2|Camera|defix| Type = Command | {{ScriptCommandV2|Camera|defix| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|}} | |||
| Description1 = Defixes the camera so that it clips behind the player again. | | Description1 = Defixes the camera so that it clips behind the player again. | ||
| Input1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|Input}} | |||
}} | }} | ||
{{ScriptCommandV2|Camera|togglefix| Type = Command | {{ScriptCommandV2|Camera|togglefix| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|}} | |||
| Description1 = Sets the fix state of the camera to the opposite of the current state. | | Description1 = Sets the fix state of the camera to the opposite of the current state. | ||
| Input1 = {{ScriptArgumentV2|doCameraUpdate|Bool|1|True|True|Input}} | |||
}} | |||
{{ScriptCommandV2|Camera|update| Type = Command | |||
| Description1 = Update the camera. | |||
}} | |||
{{ScriptCommandV2|Camera|setfocus| Type = Command | |||
}} | |||
{{ScriptCommandV2|Camera|setfocustype| Type = Command | |||
}} | |||
{{ScriptCommandV2|Camera|setfocusid| Type = Command | |||
}} | }} | ||
{{ScriptCommandV2|Camera|resetfocus| Type = Command | |||
}} | }} | ||
{{ScriptCommandV2|Camera|settoplayerfacing| Type = Command | |||
}} | |||
}} | |||
=== @Chat === | === @Chat === | ||
| Line 374: | Line 487: | ||
| Description1 = Adds the given amount of items to the player's inventory. | | Description1 = Adds the given amount of items to the player's inventory. | ||
| Input1 = {{ScriptArgumentV2|ItemID|Int|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}} | | Input1 = {{ScriptArgumentV2|ItemID|Int|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}} | ||
| Argument2 = {{ScriptArgumentV2|ItemName|Str|1|False||}},{{ScriptArgumentV2|Amount|Int|2|True|1|}} | |||
| Input2 = {{ScriptArgumentV2|ItemName|Int|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}} | |||
}} | }} | ||
| Line 380: | Line 495: | ||
| Description1 = Removes the given amount of items from the player's inventory. Displays a message afterwards, if "showMessage" is true. | | Description1 = Removes the given amount of items from the player's inventory. Displays a message afterwards, if "showMessage" is true. | ||
| Input1 = {{ScriptArgumentV2|ItemID|Int|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}}<br />{{ScriptArgumentV2|showMessage|Bool|1|True|True|Input}} | | Input1 = {{ScriptArgumentV2|ItemID|Int|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}}<br />{{ScriptArgumentV2|showMessage|Bool|1|True|True|Input}} | ||
| Argument2 = {{ScriptArgumentV2|ItemName|Str|1|False||}},{{ScriptArgumentV2|Amount|Int|2|True|1|}},{{ScriptArgumentV2|showMessage|Bool|1|True|True|}} | |||
| Input2 = {{ScriptArgumentV2|ItemName|Str|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}}<br />{{ScriptArgumentV2|showMessage|Bool|1|True|True|Input}} | |||
}} | }} | ||
| Line 386: | Line 503: | ||
| Description1 = Clears all items with the given ID from the player's inventory. Clears the whole inventory if ItemID is empty. | | Description1 = Clears all items with the given ID from the player's inventory. Clears the whole inventory if ItemID is empty. | ||
| Input1 = {{ScriptArgumentV2|ItemID|Int|1|True||Input}} | | Input1 = {{ScriptArgumentV2|ItemID|Int|1|True||Input}} | ||
| Argument2 = {{ScriptArgumentV2|ItemName|Str|1|True||}} | |||
| Input2 = {{ScriptArgumentV2|ItemName|Int|1|True||Input}} | |||
}} | }} | ||
{{ScriptCommandV2|Item| | {{ScriptCommandV2|Item|messagegive| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|ItemID|Int|1|False||}},{{ScriptArgumentV2|Amount|Int|2|True|1|}} | | Argument1 = {{ScriptArgumentV2|ItemID|Int|1|False||}},{{ScriptArgumentV2|Amount|Int|2|True|1|}} | ||
| Description1 = Displays a message for getting the specified amount of items. | | Description1 = Displays a message for getting the specified amount of items. | ||
| Input1 = {{ScriptArgumentV2|ItemID|Int|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}} | | Input1 = {{ScriptArgumentV2|ItemID|Int|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}} | ||
| Argument2 = {{ScriptArgumentV2|ItemName|Str|1|False||}},{{ScriptArgumentV2|Amount|Int|2|True|1|}} | |||
| Input2 = {{ScriptArgumentV2|ItemName|Str|1|False||Input}}<br />{{ScriptArgumentV2|Amount|Int|2|True|1|Input}} | |||
}} | }} | ||
| Line 439: | Line 560: | ||
=== @Music === | === @Music === | ||
{{ScriptCommandTableV2|Command| | {{ScriptCommandTableV2|Command| | ||
{{ScriptCommandV2|Music|setmusicloop|{{ScriptArgumentV2|musicFile|Str|1|False||}}|Sets the map musicloop to a new musicfile.|{{ScriptArgumentV2|musicFile|Str|1|True||Input}}| | {{ScriptCommandV2|Music|play| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|musicFile|Str|1|False||}} | |||
| Description1 = Changes the currently playing music to a new one. | |||
| Input1 = {{ScriptArgumentV2|musicFile|Str|1|True||Input}} | |||
}} | |||
{{ScriptCommandV2|Music|setmusicloop| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|musicFile|Str|1|False||}} | |||
| Description1 = Sets the map musicloop to a new musicfile. | |||
| Input1 = {{ScriptArgumentV2|musicFile|Str|1|True||Input}} | |||
}} | |||
{{ScriptCommandV2|Music|stop| Type = Command | |||
| Description1 = Stops the music playback. | |||
}} | |||
{{ScriptCommandV2|Music| | {{ScriptCommandV2|Music|pause| Type = Command | ||
| Description1 = Pauses the music playback. | |||
}} | |||
{{ScriptCommandV2|Music| | {{ScriptCommandV2|Music|resume| Type = Command | ||
| Description1 = Resumes the music playback. | |||
}} | |||
}} | }} | ||
| Line 549: | Line 686: | ||
=== @Pokedex === | === @Pokedex === | ||
{{ScriptCommandTableV2|Command| | {{ScriptCommandTableV2|Command| | ||
{{ScriptCommandV2|Pokedex|setautodetect|{{ScriptArgumentV2|autodetect|Bool|1|False||}}|Sets if the Pokédex registers seen Pokémon in wild or trainer battles.|{{ScriptArgumentV2|autodetect|Bool|1|False||Input}} | |||
{{ScriptCommandV2|Pokedex|setautodetect| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|autodetect|Bool|1|False||}} | |||
| Description1 = Sets if the Pokédex registers seen Pokémon in wild or trainer battles. | |||
| Input1 = {{ScriptArgumentV2|autodetect|Bool|1|False||Input}} | |||
}} | |||
}} | }} | ||
| Line 555: | Line 698: | ||
=== @Pokemon === | === @Pokemon === | ||
{{ScriptCommandTableV2|Command| | {{ScriptCommandTableV2|Command| | ||
{{ScriptCommandV2| | |||
{{ScriptCommandV2| | {{ScriptCommandV2|Pokemon|cry| Type = Command | ||
{{ScriptCommandV2| | | Argument1 = {{ScriptArgumentV2|pokemonID|Int|1|False||}} | ||
{{ | | Description1 = Plays the cry of the given Pokémon. | ||
{{ScriptCommandV2| | | Input1 = {{ScriptArgumentV2|pokemonID|Int|1|False||Input}} | ||
{{ScriptCommandV2| | }} | ||
{{ScriptCommandV2| | |||
{{ScriptCommandV2| | {{ScriptCommandV2|Pokemon|remove| Type = Command | ||
| Argument1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||}} | |||
| Description1 = Removes the Pokémon at the given party index. | |||
| Input1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||Input}} | |||
}} | |||
{{ScriptCommandV2|Pokemon|add| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|insertIndex|Int|1|True|Pokemon Count|}},{{ScriptArgumentV2|pokemonData|PokemonData|1|False||}} | |||
| Description1 = Adds the Pokémon to the player's party. | |||
| Input1 = {{ScriptArgumentV2|insertIndex|Int|1|True|Pokemon Count|Input}}<br />{{ScriptArgumentV2|pokemonData|PokemonData|1|True||Input}} | |||
| Argument2 = {{ScriptArgumentV2|pokemonID|Int|1|False||}},{{ScriptArgumentV2|level|Int|2|False||}},{{ScriptArgumentV2|method|Str|1|True|random reason|}},{{ScriptArgumentV2|ballID|Int|3|True|5|}},{{ScriptArgumentV2|location|Str|2|True|Current location|}},{{ScriptArgumentV2|isEgg|Bool|1|True|False|}},{{ScriptArgumentV2|trainerName|Str|3|True|Current TrainerName|}} | |||
| Description2 = Adds the Pokémon with the given arguments to the player's party. | |||
| Input2 = {{ScriptArgumentV2|pokemonID|Int|1|False||Input}}<br />{{ScriptArgumentV2|level|Int|2|False||Input}}<br />{{ScriptArgumentV2|method|Str|1|True|random reason|Input}}<br />{{ScriptArgumentV2|ballID|Int|3|True|5|Input}}<br />{{ScriptArgumentV2|location|Str|2|True|Current location|Input}}<br />{{ScriptArgumentV2|isEgg|Bool|1|True|False|Input}}<br />{{ScriptArgumentV2|trainerName|Str|3|True|Current TrainerName|Input}} | |||
}} | |||
{{ScriptCommandV2|Pokemon|setadditionalvalue| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||}},{{ScriptArgumentV2|data|Str|1|False||}} | |||
| Description1 = Set the additional data for a Pokémon in the player's party. | |||
| Input1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||Input}}<br />{{ScriptArgumentV2|data|Str|1|False||Input}} | |||
}} | |||
{{ScriptCommandV2|Pokemon|setadditionaldata| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||}},{{ScriptArgumentV2|data|Str|1|False||}} | |||
| Description1 = Set the additional data for a Pokémon in the player's party. | |||
| Input1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||Input}}<br />{{ScriptArgumentV2|data|Str|1|False||Input}} | |||
}} | |||
{{ScriptCommandV2|Pokemon|setnickname| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||}},{{ScriptArgumentV2|nickName|Str|1|False||}} | |||
| Description1 = Set the nick name for a Pokémon in the player's party. | |||
| Input1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||Input}}<br />{{ScriptArgumentV2|nickName|Str|1|False||Input}} | |||
}} | |||
{{ScriptCommandV2|Pokemon|setstat| Type = Command | |||
| Argument1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||}},{{ScriptArgumentV2|statName|Str|1|False||}},{{ScriptArgumentV2|statValue|Int|2|False||}} | |||
| Description1 = Set the value of a stat for a Pokémon in the player's party. | |||
| Input1 = {{ScriptArgumentV2|pokemonIndex|Int|1|False||Input}}<br />{{ScriptArgumentV2|statName|Str|1|False||Input}}<br />{{ScriptArgumentV2|statValue|Int|2|False||Input}} | |||
}} | |||
{{ScriptCommandV2|pokemon|clear||||False}} | {{ScriptCommandV2|pokemon|clear||||False}} | ||
{{ScriptCommandV2|pokemon|removeattack||||False}} | {{ScriptCommandV2|pokemon|removeattack||||False}} | ||
| Line 600: | Line 781: | ||
{{ScriptCommandV2|pokemon|clone||||False}} | {{ScriptCommandV2|pokemon|clone||||False}} | ||
}} | }} | ||
=== @Radio === | === @Radio === | ||
| Line 1,082: | Line 1,262: | ||
== | == Statement == | ||
Statement do a comparison between a given parameter and a construct. | |||
=== :if: === | === :if: === | ||
Latest revision as of 20:30, 22 January 2021
Introduction
Version 2 scripts were started in version 0.32 and will cease support in alpha version (v1.xx). Any script in Version 2 must have "version=2" as the first line of the script.
Commands are procedures that are used to tell the game what to do.
Constructs are functions that returns a value in the game.
Commands are written as @Command.SubCommand.
Constructs are written as <Construct.SubConstruct>.
Commands and constructs are not case sensitive.
A General Note to all GameMode Scripters ( Must Read )
- This page is currently updated as of v0.53.3 Script Library.
- This page contains information that is similar to what you can see when typing @help(command).
- The line number shown in the crash logs starts counting at the first non-empty line of a valid command or statement. However, any line after :while: statement are continuously counted until the end loop. If there are two repeating cycle within the while loop, the number of lines doubles.
Code Conventions
Header
The Header is used to define the ActionScript engine you want to use for the entire script. For each script file, the header must contain "version=2".
Statement
A Statement is used to make comparisons between constructs and parameters or to make conditions for the script to run.
There are a few Statements available in the game.
- :if:
- :else
- :endif
- :while:
- :exitwhile
- :endwhile
- :select:
- :when:
- :endwhen
- :end
- :endscript
- :return:
For more infomation about Statements and their usage, proceed to here.
Command Declaration
A Command is used to instruct the game with a set of procedures to run. They do not return any value.
You can define a Command with: @Class.Subclass
Construct Declaration
A Construct is used to instruct the game to return a value. They can be used with Commands and Statements.
You can define construct with: <Class.Subclass>
Temporary Global Variable
Global Variables are used when you want to use a variable on another script without having to redefine it again.
Assignments:
@Storage.set(str,Name,Text) @Storage.set(int,Name,Number) @Storage.set(sng,Name,Number) @Storage.set(dbl,Name,Number) @Storage.set(bool,Name,Boolean)
Basic math:
Addition: @Storage.update(int,Name,add,Value) @Storage.update(int,Name,+,Value)
Subtraction: @Storage.update(int,Name,substract,Value) @Storage.update(int,Name,-,Value)
Multiplication: @Storage.update(int,Name,multiply,Value) @Storage.update(int,Name,*,Value)
Division: @Storage.update(int,Name,divide,Value) @Storage.update(int,Name,/,Value)
String concatenation:
@Storage.update(str,Name,add,Message) @Storage.update(str,Name,+,Message)
Reading:
@Text.show(<Storage.get(str,Name)>) @Text.show(<Storage.get(int,Name)>)
Version 2 Class
Important info / definition of certain things before we get started.
By Default, the Argument Types are:
- Str ( Strings are defined as letters or symbols )
- Int ( Int (Integer) are defined as Integer numbers )
- Sng ( Sng (Single) are defined as Real numbers )
- ItemCollection ( ItemCollection are defined as {itemID|amount|price} )
- Bool ( Bool (Boolean) are defined either as True & False or 1 & 0 )
- IntArr ( IntArr are defined as an array of Integer numbers, usually with commas inbetween )
- StrArr ( StrArr are defined as an array of letters or symbols, usually with commas inbetween )
- SngArr ( SngArr are defined as an array of Real numbers )
- BoolArr ( BoolArr are defined as an array of words such as True, False )
- PokemonData ( PokemonData are defined as Pokemon Code )
- Arr ( Arr are defined as an array of something. )
For any Optional Argument, it will be underlined and have a red color, for example "Str1,Str2,Str3,..."
For any Array Argument, it will be surrounded by a grouped square bracket, for example "[Str1,Int2,Int3,Int4,Int5],Int6..."
Commands
Commands are scripts that tells the game what to do. A Command comes with a @ and usually with some arguments (between Parantheses like these)
The table below is split into sections by Command.
You may use the sort feature to make it list contents in alphanumeric order.
@Battle
|
@Camera
|
@Chat
|
@Daycare
|
@Entity
|
@Environment
|
@Item
|
@Level
|
@Music
|
@NPC
|
@Options
|
@Player
|
@Pokedex
|
@Pokemon
|
@Radio
|
@Register
|
@Screen
|
@Script
|
@Sound
|
@Storage
|
@Text
|
@Title
|
Constructs
Constructs are script that return a specific values in game. It is used with commands or switches.
They can even be used in trainer files. Constructs always have a subconstruct. All combinations will be listed below.
Constructs that return numbers such as <Pokemon.level(int)> may be used in mathematical functions including:
+: Addition -: Subtraction /: Division *: Multiplication ^: Exponent %: Percent =: Equals >: Greater Than <: Less Than m: Mod (ex. 25m4=1) r: Root(ex. 27r3=3)
The table is split into sections by Construct.
Battle
|
Camera
|
Daycare
|
Entity
|
Environment
|
Inventory
|
Level
|
Math
|
NPC
|
Phone
|
Player
|
Pokedex
|
Pokemon
|
Radio
|
Register
|
Rival
|
Storage
|
System
|
Statement
Statement do a comparison between a given parameter and a construct.
:if:
If you want to make the script run by certain condition, :if: will do the job.
Typical Usage:
:if:Conditions @Command.Subcommand(Argument Types) :endif
:if:Conditions @Command.Subcommand(Argument Types) :else @Command.Subcommand(Argument Types) :endif
Conditions
There are some valid condition that you can use.
The script will run if a value that returns from the constructs match the value given.
<Construct.SubConstruct(Argument Types)>=value <Construct.SubConstruct(Argument Types)>>value <Construct.SubConstruct(Argument Types)><value
The script will run if a value that returns from the constructs does not match the value given.
<not><Construct.SubConstruct(Argument Types)>=value <not><Construct.SubConstruct(Argument Types)>>value <not><Construct.SubConstruct(Argument Types)><value
The script will run if two or more value that returns from the constructs match the value given.
<Construct.SubConstruct(Argument Types)>=value <and> <Construct.SubConstruct(Argument Types)>>value <and> <Construct.SubConstruct(Argument Types)><value
The script will run if at least one value that returns from the constructs match the value given.
<Construct.SubConstruct(Argument Types)>=value <or> <Construct.SubConstruct(Argument Types)>>value <or> <Construct.SubConstruct(Argument Types)><value
FAQ:
1. Can I use <and> and <or> at the same line? (E.g: <Construct.SubConstruct(Argument Types)>=value <or> <Construct.SubConstruct(Argument Types)>=value <and> <Construct.SubConstruct(Argument Types)>=value )
Ans: No. This is because the script does not support it. Also, the script will not understand what condition you are trying to say so I recommend to start a new :if: switches so that it will work the way you want it to be.
2. Can I use <not> with <and> or <or> at the same line? (E.g: <not><Construct.SubConstruct(Argument Types)>=value <or> <Construct.SubConstruct(Argument Types)>=value )
Ans: Yes. The script will be able to handle this.
3. Why it didn't work? Why it skip the condition defined?
Ans: This is probably your own typo mistake. If you are sure that it isn't report the bug.
:select:
If you want to make the script run by selecting certain condition, :select: will do the job.
Typical Usage:
:select:<Construct.SubConstruct(Argument Types)> :when:Value @Command.Subcommand(Argument Types) :endwhen
Value
This field is to define the possible value that the construct given so that the script will run when condition is met.
Define the possible values that the construct will return.
:when:value1 ... :when:value2 ... :when:valuei
If you want to have multiple value as you intended to let them do the same thing, you can use " ; "
:when:value1;value2;value3...;valuei ... :when:value1;value2;value3...;valuei
After you define the values in each condition, use " :endwhen " to properly close the :select: switches.
FAQ:
1. Why it didn't work? Why it skip the condition defined?
Ans: This is probably your own typo mistake. If you are sure that it isn't, report the bug.
@options.show()
If you want to let player choose a certain options to choose from, @Options.show() will do the job.
Typical Usage:
@options.show(option1,option2,optioni) :when:Option1 @Command.Subcommand(Argument Types) :endwhen
Option
This field is to define the possible option that you define in @options.show() so that the script will run when player choose the options.
Define the possible option that you define in @options.show().
:when:option1 ... :when:option2 ... :when:optioni
If you want to have multiple value as you intended to let them do the same thing, you can use " ; "
:when:option1;option2;optioni
After you define all the options in each condition, use " :endwhen " to properly close the @options.show() switches.
FAQ:
1. Why it didn't work? Why it skip the condition defined?
Ans: This is probably your own typo mistake. If you are sure that it isn't, report the bug.
:while:
If you want to loop a certain command until it met the condition, this will do the job.
Typical Usage:
:while:Conditions @Command.Subcommand(Argument Types) ... @Command.Subcommand(Argument Types) :endwhile
FAQ:
1. How to manually stop the loop when you know that the condition will never be met?
Ans: Insert without quotation marks " :exitwhile " before :endwhile to stop the loop prematurely.
2. How come it didn't loop? How come it stop prematurely despite :exitwhile is not used?
Ans: This is a bug. Unfortunately, if this happens, please ensure that your script is correct before filling a bug report.
3. Can I stack :while: switches? Ans: No. Nilllzz officially said it is not possible.
:endscript
If you want to stop all script prematurely, this shall do the job.
Typical Usage:
@Command.Subcommand(Argument Types) ... ... :endscript
FAQ:
1. How come it didn't work?
Ans: Unfortunately, even I myself do not know what is intended for it to work. You might need to ask Nilllzz by creating a new thread in the community support thread.
:return:
More of a script function that return a value.
Typical Usage:
:return:True :end
Once you use <System.return>, it will return True.
Comments
To add some comments in your script like what programmer does, you can use " # " a hash at the start of the line.
Typical Usage:
# This is a comment that says nothing @Command.Subcommand(Argument Types) # <= Unfortunately, hash at here do not work. # @Command.Subcommand(Argument Types) <= It will not run this script at all :D
FAQ:
1. Can it support multiple line without keep using # all the time?
Ans: Unfortunately, no.
:end
To end the current running script, this will do ithe job
Typical Usage:
@Command.Subcommand(Argument Types) :end
Reserved Registers
Reserved Registers are registers that are reserved in the P3D engine and cannot be replaced by other events.
pokegear_card_radio # Give Player PokéGear Radio
pokegear_card_GTS # Give Player GTS Card
phone_contact_### # Add Phone Contact ID ###
pokegear_card_minimap # Give PokéNav MiniMap Card
pokegear_card_frontier # Give PokéNav Frontier Emblem Card
| Game Folder | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Content | ContentPacks | GameModes | Saves | Screenshots | Game Executable | ||||||||||||||
| Pokemon | Data | ContentPack Folder | GameMode folder | Savegame folder | Version History | ||||||||||||||
| Data | Maps | Moves | Items | Scripts | Control Files | Content | GameMode.dat | Party.dat | Player.dat | Options.dat | |||||||||
| poke | battle | structures | V1 | V2 | trainer | worldmap | |||||||||||||