This repository was archived by the owner on Jan 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Script API 0: What is a Script?
lunarcleint edited this page Nov 6, 2022
·
4 revisions
A script is a file with hscript code inside it, it must have one of these file extensions ["hx", "hscript", "hsc", "hxs"].
It is important to know that these Haxe syntaxes are not supported in hscript:
- package
- import (there is another function that emulates the purpose of this function)
- classes
- typedefs
- metadata
-
var name:StringThis will either be the file name, or "stage" if its a stage. -
function new()Called when script is created. -
function destroy()Called when script is destroyed. -
function update(elapsed:Float)A function that is called every frame. -
function trace(_)This function will trace any objects you put in it,trace("hi", "t") //prints hi,t -
function import(path:String, ?as:Null<String>)Will import as the haxe function would work, this only imports classes. It is important to treat the haxe classes you import carefully since they maybe be turned into another type depending on the platform. -
function addScript(scriptName:String):DynamicThis will add any script inscripts/, this functions also returnsgetScript(scriptName) -
function getScript(scriptName:String):DynamicThis will give the script's local functions and variables as a Dynamic object. -
ScriptReturna shortcut to the enum ScriptReturn
See more on Preset Variables: Script API 1: All Preset Variables
There are 4 types of scripts you can run:
- Song Scripts: These are any scripts in the folder of the current song you are playing (it will run all of them even if inside another folder)
- Stage Scripts: These are scripts in the
/stagesfolder with the exact same name as the stage's json, will have the script name "stage" - Character Scripts: These scripts run whenever any character is created in PlayState, same file name as json
- Global Scripts: These are any scripts inside the folder
scripts/globaland any folders in there too