Scripted Classes
Funkin's implementation of HScript uses a system of scripted classes. To create a scripted class, create an .hxc file in your mods/mymod/scripts/ folder, and, using Haxe syntax, create a new class which extends the base class for the type of object you are scripting, like so:
// Remember to import each class you want to reference in your script!
import funkin.play.song.Song;
// Choose a name for your scripted class that will be unique
// Also specify the class you are extending, we choose Song here.
// This script's behaviors will extend the default behavior of the song.
class BallisticSong extends Song {
public function new() {
// You have to call the super constructor for the class you are extending, which may have different parameters.
// Check the specific documentation for more info.
super('ballistic');
}
}
List of Scriptable Classes
There is a predefined list of classes which the game has set up to be scriptable, and will automatically load and execute when relevant. More of these will be added in the future.
funkin.play.song.Songfor providing unique behavior to custom songs, including playing cutscenes and other stuff. See Scripted Songs.- See also Video Cutscenes, Ingame Cutscenes, and Dialogue Cutscenes
funkin.play.character.BaseCharacterfor providing unique behavior to custom characters (such as playing custom animations in certain circumstances). See Scripted Characters.- Note that you need to choose the correct subclass of this class for the animation type of your character!
funkin.play.character.SparrowCharacteris used for characters that have Sparrow spritesheet animations.funkin.play.character.MultiSparrowCharacteris used for characters that have several Sparrow spritesheet animations to combine into one character.funkin.play.character.PackerCharacteris used for characters that have Packer spritesheet animations.funkin.play.character.AnimateAtlasCharacteris used for characters that have Adobe Animate texture atlases.funkin.play.character.BaseCharacterhas empty stubs for all the rendering and animation handlers, and is only useful for people who want to reimplement their character's animation system by hand.
funkin.play.stage.Stagefor providing unique behavior to custom stages, such as creating custom moving props and defining when props animate or when sound effects play in sync with the stage. See Scripted Stages.funkin.ui.story.Levelfor providing unique behavior to levels in Story Mode. See Scripted Story Levels.funkin.play.notes.notekind.NoteKindfor providing unique visuals and behavior to certain kinds of notes, which can then be placed in the Chart Editor. See Custom Note Kinds.funkin.play.event.SongEventfor creating custom Song Events, which you can place in the Chart Editor and which perform game actions when they are reached. See Custom Song Eventsfunkin.ui.freeplay.charselect.PlayableCharacterfor providing unique behavior to custom playable characters. See Scripted Playable Charactersfunkin.ui.freeplay.FreeplayStylefor defining the sprites and colors used by the Freeplay menu when a given character is selected. See [WIP]funkin.play.notes.notestyle.NoteStylefor modifying the behavior of custom note styles. See [WIP]funkin.play.cutscene.dialogue.Conversationfor providing unique behavior to custom dialogue conversations. See Dialogue Cutscenesfunkin.play.cutscene.dialogue.DialogueBoxfor providing unique behavior to custom dialogue boxes used in conversations. See Dialogue Cutscenesfunkin.play.cutscene.dialogue.Speakerfor providing unique behavior to custom speakers used in conversations. See Dialogue Cutscenesfunkin.ui.freeplay.Albumfor defining custom behavior for Freeplay Albums. See [WIP]
There is also funkin.modding.module.Module for custom scripted Modules, which are scripts which receive events everywhere, rather than only in a specific context. See Scripted Modules for more information on how these work.
There are also scripted classes are also set up to be scriptable, but will only be useful if they're accessed from another script. Expect more of these to be added in the future.
funkin.graphics.FunkinSpritefor basic static or animated sprites.funkin.graphics.adobeanimate.FlxAtlasSpritefor generic sprites which use Adobe Animate texture atlasesflixel.group.FlxSpriteGroupfor groups of sprites which are included inside a state and manipulated togetherfunkin.ui.MusicBeatStatefor groups of sprites which represents a given game state. Includes additional utilities for handling script events.funkin.ui.MusicBeatSubStatefor groups of sprites representing a substate of an existing stateflixel.addons.display.FlxRuntimeShaderfor custom GLSL shadersfunkin.play.stage.Bopperfor sprites which will play an idle animation to the beat of the music when they are part of a Stage.flixel.FlxSpritefor basic static or animated sprites. Use this only if you can't use FunkinSprite.flixel.FlxStatefor basic groups of sprites which represent a given game state. Use this only if you can't use MusicBeatState.flixel.FlxSubStatefor groups of sprites representing a substate of an existing state