-
Notifications
You must be signed in to change notification settings - Fork 6
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. 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:
- PlayState (0.5.1+)
- 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(?)
Haxe:
Flixel:
- FlxG (Many subclasses/functions are disallowed for security reasons)
- FlxMath
- FlxEase
- FlxTween
- FlxAngle
- FlxTimer
- FlxSound
- FlxGroup
- FlxTrail
- FlxSprite
- FlxAnimation
- FlxBaseAnimation
All methods contain a reference to the character as the first argument
-
startSong ()
-
endSong ()
-
initScript ()
-
new ()
-
update (elapsed)
-
playAnim (animName)
-
noteHitSelf (char,note)Called when a note is hit by the character
-
noteHitOpponent (char,note)Called when a note is hit by the opponent
All methods contain a reference to playState as the first argument
-
startSong () -
generateSong () -
endSong () -
initScript () -
update (elapsed) -
beatHit () -
stepHit () -
strumNoteAdd (Note,Player)- Called when a strumNote is added. Player(0.5.1+): True is if it's player strumline, false is not -
noteHit/noteHitDad (char,note)- Called when a note is hit -
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
For unknown reasons, characters cannot be modified/accessed through playState.CHAR, You have to use:
-
charGet(charId:Int,field:String), charId is the character's ID, field is the field to access,charGet(0,"curCharacter")would return BF's character name -
charGet(charId:Int, field:String, value:Dynamic), charId is the character's ID, field is the field to access, Value is the what to set it to. -
charAnim(charId:Int,anim:String), 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:
-
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(PATH),BRtools.cacheSprite(PATH)- loads a sound/sprite into memory. ExampleBRtools.cacheSprite("sprites/spacebar"); -
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")