|
| 1 | +# Scripted Classes |
| 2 | + |
| 3 | +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: |
| 4 | + |
| 5 | +```haxe |
| 6 | +// Remember to import each class you want to reference in your script! |
| 7 | +import funkin.play.song.Song; |
| 8 | +
|
| 9 | +// Choose a name for your scripted class that will be unique |
| 10 | +// Also specify the class you are extending, we choose Song here. |
| 11 | +// This script's behaviors will extend the default behavior of the song. |
| 12 | +class BallisticSong extends Song { |
| 13 | + public function new() { |
| 14 | + // You have to call the super constructor for the class you are extending, which may have different parameters. |
| 15 | + // Check the specific documentation for more info. |
| 16 | + super('ballistic'); |
| 17 | + } |
| 18 | +} |
| 19 | +``` |
| 20 | + |
| 21 | +## List of Scriptable Classes |
| 22 | + |
| 23 | +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. |
| 24 | + |
| 25 | +- `funkin.play.song.Song` for providing unique behavior to custom songs, including playing cutscenes and other stuff. See [Scripted Songs](21-scripted-classes/21-01-scripted-songs.md). |
| 26 | + - See also [Video Cutscenes](21-scripted-classes/21-03-video-cutscenes.md), [Ingame Cutscenes](21-scripted-classes/21-04-ingame-cutscenes.md), and [Dialogue Cutscenes](21-scripted-classes/21-05-dialogue-cutscenes.md) |
| 27 | +- `funkin.play.character.BaseCharacter` for providing unique behavior to custom characters (such as playing custom animations in certain circumstances). See [Scripted Characters](21-scripted-classes/21-05-scripted-characters.md). |
| 28 | + - Note that you need to choose the correct subclass of this class for the animation type of your character! |
| 29 | + - `funkin.play.character.SparrowCharacter` is used for characters that have Sparrow spritesheet animations. |
| 30 | + - `funkin.play.character.MultiSparrowCharacter` is used for characters that have several Sparrow spritesheet animations to combine into one character. |
| 31 | + - `funkin.play.character.PackerCharacter` is used for characters that have Packer spritesheet animations. |
| 32 | + - `funkin.play.character.AnimateAtlasCharacter` is used for characters that have Adobe Animate texture atlases. |
| 33 | +- `funkin.play.stage.Stage` for 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](21-scripted-classes/24-06-scripted-stages.md). |
| 34 | +- `funkin.ui.story.Level` for providing unique behavior to levels in Story Mode. See [Scripted Story Levels](21-scripted-classes/25-07-scripted-story-levels.md). |
| 35 | +- `funkin.play.notes.notekind.NoteKind` for providing unique visuals and behavior to certain kinds of notes, which can then be placed in the Chart Editor. See [Custom Note Kinds](21-scripted-classes/26-00-custom-note-kinds.md). |
| 36 | +- `funkin.play.event.SongEvent` for creating custom Song Events, which you can place in the Chart Editor and which perform game actions when they are reached. See [Custom Song Events](21-scripted-classes/28-00-custom-note-kinds.md) |
| 37 | +- `funkin.ui.freeplay.charselect.PlayableCharacter` for providing unique behavior to custom playable characters. See [Scripted Playable Characters](21-scripted-classes/25-10-scripted-playable-characters.md) |
| 38 | +- `funkin.ui.freeplay.FreeplayStyle` for defining the sprites and colors used by the Freeplay menu when a given character is selected. See [WIP] |
| 39 | +- `funkin.play.notes.notestyle.NoteStyle` for modifying the behavior of custom note styles. See [WIP] |
| 40 | +- `funkin.play.cutscene.dialogue.Conversation` for providing unique behavior to custom dialogue conversations. See [Dialogue Cutscenes](21-scripted-classes/21-05-dialogue-cutscenes.md) |
| 41 | +- `funkin.play.cutscene.dialogue.DialogueBox` for providing unique behavior to custom dialogue boxes used in conversations. See [Dialogue Cutscenes](21-scripted-classes/21-05-dialogue-cutscenes.md) |
| 42 | +- `funkin.play.cutscene.dialogue.Speaker` for providing unique behavior to custom speakers used in conversations. See [Dialogue Cutscenes](21-scripted-classes/21-05-dialogue-cutscenes.md) |
| 43 | +- `funkin.ui.freeplay.Album` for defining custom behavior for Freeplay Albums. See [WIP] |
| 44 | + |
| 45 | +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](30-scripted-modules/30-00-scripted-modules.md) for more information on how these work. |
| 46 | + |
| 47 | +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. |
| 48 | + |
| 49 | +- `funkin.graphics.FunkinSprite` for basic static or animated sprites. |
| 50 | +- `funkin.graphics.adobeanimate.FlxAtlasSprite` for generic sprites which use Adobe Animate texture atlases |
| 51 | +- `flixel.group.FlxSpriteGroup` for groups of sprites which are included inside a state and manipulated together |
| 52 | +- `funkin.ui.MusicBeatState` for groups of sprites which represents a given game state. Includes additional utilities for handling script events. |
| 53 | +- `funkin.ui.MusicBeatSubState` for groups of sprites representing a substate of an existing state |
| 54 | +- `flixel.addons.display.FlxRuntimeShader` for custom GLSL shaders |
| 55 | +- `funkin.play.stage.Bopper` for sprites which will play an idle animation to the beat of the music when they are part of a Stage. |
| 56 | +- `flixel.FlxSprite` for basic static or animated sprites. Use this only if you can't use FunkinSprite. |
| 57 | +- `flixel.FlxState` for basic groups of sprites which represent a given game state. Use this only if you can't use MusicBeatState. |
| 58 | +- `flixel.FlxSubState` for groups of sprites representing a substate of an existing state |
0 commit comments