Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.

Template Scripts

skellypupper edited this page Feb 13, 2023 · 11 revisions

There are a few different types of scripts you can use across edak engine, below are empty templates of the types of scripts you can utilize:

Custom Note

/* all optional */
function loadSprite() {
    // load your graphics for your note here
}

function propertyOverride() {
    // like loadSprite, but used to fix your note if it shows up incorrectly in the PlayState
}

function update(elapsed:Float) {
    // called every frame
}

Custom Substate

function create() {
    // required function that makes the substate, if there's an error, the substate will close itself
}

function update(elapsed:Float) {
    // optional: called every frame
}

Character

function create() {
    // required function that lets you make your character, if there's an error, it defaults to bf
}

function createPost() {
    // optional: called after Character#create is complete
}

function update(elpased:Float) {
    // called every frame, if used it overrides the default update functionality for the character
}

function dance() {
    // custom dance function, overrides default dance if set
}

Stage

function create() {
    // required function that lets you construct your stage, if there's an error, the default stage will be loaded instead
}

function reposCharacters() {
    // allows you to reposition characters as you please (totally not fe legacy)
    // bf, gf and dad are available "PlayState.boyfriend", "PlayState.gf", "PlayState.dad"
}

function stepHit(step:Int) {
    // called from the PlayState when a step is hit
    // great for dancing bg characters
}

function beatHit(beat:Int) {
    // called from the PlayState when a beat is hit
}

function update(elapsed:Float) {
    // blah blah blah, called every frame
}

Dialogue

function create() {
    // required function that creates your dialogue box, "dia.box" must be a FlxSprite or else the dialogue will close itself
}

function createPost() {
    // called after the dialogue class is initiated
}

function preLine(portrait:String, ?nextLine:String) {
   // called before the next text line starts
   // nextLine could be null if it's at the end of the dialogue
}

function update(elapsed:Float) {
    // called every frame
}

function finish() {
    // function to close out the dialogue box, if used you must call "dia.finishCallback();dia.kill();" in it!!
}

Song Script (yeah it's kinda like psych engine shut up)

/* nothing in this script type is required */
function onCreate() {
    // called after all song scripts are loaded
}

function onCutscene() {
    // cutscene code goes here, if you use this, call "game.startCountdown()"!
}

function onCreatePost() {
    // called after PlayState#create is complete
}

function onCountdownTick(tick:Int) {
   /* called for each tick on the countdown
      0 = 3
      1 = 2/Ready
      2 = 1/Set
      3 = Go!
      4 = song starting point (use onSongStart instead tbh)
   */
}

function onSongStart() {
    // called after the countdown is complete
}

function onUpdate(elapsed:Float) {
    // i think you get it at this point, called every frame
}

function onUpdatePost() {
    // called after PlayState#update is complete
}

function onGameOver() {
    // called when the player runs out of health or calls a reset
}

function onGameOverStart() {
    // called when the default game over substate opens
    // use "GameOverSubstate.instance"
}

function onGameOverUpdate(elapsed:Float) {
   // called every frame on the default game over substate
}

function onGameOverEnd() {
    // called when the end function is called in the default game over substate
}
 
function onPause() {
    // called when the player pauses the game
}

function onCamMove(char:String) {
    // called when a mustHitSection camera change is made
    // char is either "bf" or "dad"
}

function opponentNoteHit(direction:Int, note:Note) {
    // called when an opponent hits a note
}

function goodNoteHit(direction:Int, note:Note) {
    // ^ but for the player
}

function noteMiss(direction:Int, ?note:Note) {
    // ^ but if the player misses a note
    // note could be null if the player doesn't use ghost tapping
    // be sure to check for that!
}

function onComboPop(rating:String, combo:Int, ?msTiming:Float) {
    // called when a combo pops up
    // msTiming will be null if the rating is a miss
}

function onEndSong() {
    // called when the song's about to end, if you use this, call "game.endSong()"!
}

function onStepHit(step:Int) {
    // called when a step is hit
}

function onBeatHit(beat:Int) {
    // called when a beat is hit
}