Friday Night Funkin' Cookbook
Friday Night Funkin' CookbookExpertScripted States

Scripted States

Reading time: 1.5 minute

Creating scripted states is the most powerful thing in the modding framework, it basically lets you create entirely custom... things. Be it a menu, object, or entirely different game!

Creating a custom menu

A typical custom MusicBeatState (Menu) might look like this:

package kade.menucore.states;

import flixel.FlxSprite;
import flixel.text.FlxText;

import funkin.ui.MusicBeatState;
import funkin.ui.FullScreenScaleMode;

class MenuSwitch extends MusicBeatState {

    public function new():Void {
        super();
    }

    public override function create():Void {
        super.create();

        var bg = new FlxSprite();
        // ... bg code
        add(bg);

        var chooseBlackBar = new FlxSprite(0, 0);
        // ... black bar code
        add(chooseBlackBar);

        var choose = new FlxText(Math.max(FullScreenScaleMode.gameNotchSize.x, 6), 2, FlxG.width, "CHOOSE THE VERSION");
        // ... choose text code
        add(choose);

        var topRightText = new FlxText(0, 15, FlxG.width / 2, "");
        // ... top right text code
        add(topRightText);

        // Middle black bar of bg
        var blackBar = new FlxSprite(0, 0);
        // ... middle bar code
        add(blackBar);

        // ...
    }

    public override function update(elapsed:Float):Void {
        super.update(elapsed);
    }
}

Looking at this code, it looks scarily similar to the actual source code of the game - and that's the point. You're basically given the tools to create your own states, in which you control entirely. This allows for custom menus, and different games entirely.

The limit really, is your imagination.

For community examples of custom states/objects/helpers, check out here


Contributors:
Kade-gtihub
Last modified:
Created:
Category:  Expert
Tags: