-
Notifications
You must be signed in to change notification settings - Fork 5
Character and Chart scripts
As of 0.5.0, you can provide a script with characters or charts. You can use scripts to add custom features and such to the game while only having it effect one song. As of 0.9.0, scripts can be stored in their own folders inside of mods/scripts and can provide custom options(See Arrow Options for a config example) To add a script, you just put a script.hscript in the character or song's folder
HScript allows the game to run haxe code while the game is running, apart from being dynamicly typed(Not requiring you to specify types), it's really close to Haxe, which itself is a bit like JS syntax if you're used to it.
You can find more about hscript here, Haxe here and haxeFlixel here.
Most Flixel classes are exposed to song and character hscripts. Many things should hopefully be easy to port from hardcoded to BR HScript.
Game:
- TitleState
- Character
- debug - If the game is in debug mode or not
- makeRangeArray - Alias for numberArray(max:Int, ?min = 0), Makes array filled with numbers(?)
=(0.5.1+)
- PlayState
=(0.6.0+)
- Alphabet
- Note
- EmptyCharacter
- HealthIcon
=(0.10.0+)
- FinishSubState
- SESettings (The game's options)
- Global (Global variables for scripts to share between eachother, Reset every song)
- Version (The version of the game)
Haxe:
=(0.7.1+)
=(0.11+)
Flixel:
- FlxG (Many subclasses/functions are disallowed for security reasons)
- FlxMath
- FlxEase
- FlxTween
- FlxAngle
- FlxTimer
- FlxSound
- FlxGroup
- FlxTrail
- FlxSprite
- FlxAnimation
- FlxBaseAnimation
=(0.6.0+)
=(0.10.0+)
=(0.11+)
- Type
- FlxAxes
- File/FileSystem (Combined)
All methods contain a reference to the character as the first argument
Method | Description |
---|---|
startSong () | Called when the song starts |
endSong () | Called when the song ends |
initScript () | Called when script is initialised |
update (elapsed) | Called every update |
playAnim (animName) | Called when an animation is about to be played |
noteHitSelf (char,note) | Called when a note is hit by the character |
noteHitOpponent (char,note) | Called when a note is hit by the opponent |
(0.6.0) --------------------- | Below are methods available after this version |
addChars() | Called after BF is added |
addDad() | Called after opponent is added |
addGF() | Called after GF is added |
addUI() | Called after UI is added |
strumNoteLoad (arrow,charID) | Called when a strumNote is loading, can be used to replace textures |
strumNoteAdd (arrow,charID) | Called when a strumNote is added |
noteCreate (note,rawNote) | Called on note creation, can be used to make custom notes with note.type. rawNote is the rawJson note the game processes, this is called before any textures are loaded |
noteAdd (note,rawNote) | Called after the note is finished loading |
(0.6.1) --------------------- | Below are methods available after this version |
keyShit (pressArray, holdArray) | Called when keyShit is called |
keyShitAfter (pressArray, holdArray, hitArray) | Called after the notes are hit in keyshit, hitArray is a array of the presses corrasponding to the notes hit |
(0.10.0) -------------------- | Below are methods available after this version |
stepHit (curStep) | Called when every step |
beatHit (curBeat) | Called when every beat |
All methods contain a reference to playState as the first argument
Method | Description |
---|---|
startSong () | Called when the song starts |
generateSong () | Called when the song is done being generated |
endSong () | Called when the song ends |
initScript () | Called when script is initialised |
update (elapsed) | Called every update |
beatHit () | Called when a beat is hit |
stepHit () | Called when a step is hit |
strumNoteAdd (Note,Player) | Called when a strumNote is added. Player is 0.5.1+, True is if it's player strumline, false is not |
noteHit/noteHitDad (char,note) | Called when a note is hit |
noteMiss (char,note) | Called when the player misses with a note (0.8.0 and below: Runs it whenever the player misses) |
noteCreate (note,rawNote) | Called on note creation, can be used to make custom notes with note.type. rawNote is the rawJson note the game processes called before the texture is loaded |
(0.6.0) --------------------- | Below are methods available after this version |
addChars () | Called after BF is added |
addDad () | Called after opponent is added |
addGF () | Called after GF is added |
addUI () | Called after UI is added |
playAnim (anim,char) | Called when a character plays an animation, char is the character that played this animation |
noteAdd (note,rawNote) | Called after the note is finished loading |
afterStage () | Called after the stage is loaded, Only for the stage hscript. |
(0.6.1) --------------------- | Below are methods available after this version |
keyShit (pressArray, holdArray) | Called when keyShit is called |
keyShitAfter (pressArray, holdArray, hitArray) | Called after the notes are hit in keyshit, hitArray is a array of the presses corrasponding to the notes hit |
(0.7.1) --------------------- | Below are methods available after this version |
startCountdownFirst () | Called after the camera is centered but before the arrows are added and the countdown. Use playCountdown to control the countdown manually, make sure to use playstate.startCountdown() to start the countdown |
startCountdown () | Called right before the timer for the countdown is started |
startTimerStep (loopCount) | Called every on every step in the timer |
(0.8.1) --------------------- | Below are methods available after this version |
miss (char,direction) | Called when the player misses without a notes |
(0.10.0) --------------------- | Below are methods available after this version |
pauseCreate (this/Pause Menu) | Called when the pause menu is created |
pause (this/Pause Menu) | Called after the pause menu is created |
pauseUpdate (this/Pause Menu) | Called every update inside of the pause menu |
pauseResume (this/Pause Menu) | Called when the pause menu starts the countdown to the game |
(0.11.0) --------------------- | Below are methods available after this version |
susHit (note) | Called when a note is held on SE Input |
susHitDad (note) | Called when a note is held by the opponent on SE Input |
updateAfter (elapsed) | Called at the end of the update function |
Characters have to be accessed using PlayState.CHAR(0.5.1+), however you can use these if you want easier access:
Method | Arguments | Description |
---|---|---|
charGet | (charId, field) | charId is the character's ID, field is the field to access, charGet(0,"curCharacter") would return BF's character name |
charGet | (charId, field, value) | charId is the character's ID, field is the field to access, Value is the what to set it to |
charAnim | (charId, anim) | charId is the character's ID, anim is the animation to play |
For charId: 0=BF,1=Opponent,2=GF
You can use BRtools to load sprites and play sounds without having to worry about the chart or character's folder path.
Available methods:
Method | Arguments | Description |
---|---|---|
BRtools.loadFlxSprite | (x, y, PATH) | Loads a png and returns a FlxSprite, example: spacebarthing = BRtools.loadFlxSprite(0,0,"sprites/spacebar.png");
|
BRtools.loadSparrowSprite | (x, y, PATH, ANIMATION, LOOP, FPS) | Loads a xml and png, example: spacebarthing = BRtools.loadSparrowSprite(0,0,"sprites/spacebar","spacepress",true);
|
BRtools.playSound | (PATH, VOLUME) | Plays a sound, example: BRtools.playSound("sounds/Alarm.ogg",1);
|
BRtools.cacheSound/Sprite | (PATH) | loads a sound/sprite into memory. Example BRtools.cacheSprite("sprites/spacebar.png");
|
BRtools.loadSparrowFrames | (PATH) | Loads and returns a FlxAtlasFrames object, can be used to replace the frames of an object if desired. Example: OBJECT.frames = BRtools.loadSparrowFrames("sprites/object")
|
(0.6.0) -------------- | Below are methods available after this version | |
BRTools.getPath | (PATH) | Returns the hscript's path with the path provided concatenated |
BRTools.loadGraphic | (PATH) | Returns a FlxGraphic |
BRTools.loadText | (PATH) | Returns a string containing the file's contents |
BRTools.unloadSprite/Sound/Text/Xml | (PATH) | Removes object from the objects array |
(0.9.0) ------------- | Below are methods available after this version | |
BRtools.getSetting | (OptionName) | Returns a option's value if your script has a populated options.json |
(0.11.0) ------------- | Below are methods available after this version | |
BRtools.loadSound | (PATH) | Loads and returns a Sound object, example: BRtools.loadSound("sounds/Alarm.ogg");
|