From 73ce356d54bc2d1952b6e6bbf60c247f05e19141 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Wed, 30 Nov 2022 23:15:32 +0100 Subject: [PATCH] custom states --- buildnumber.txt | 2 +- source/funkin/scripting/ModState.hx | 7 +++++++ source/funkin/scripting/Script.hx | 9 +++++++-- source/funkin/system/MusicBeatState.hx | 7 +++++-- 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 source/funkin/scripting/ModState.hx diff --git a/buildnumber.txt b/buildnumber.txt index 57a2e3e3..9711409c 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1325 \ No newline at end of file +1326 \ No newline at end of file diff --git a/source/funkin/scripting/ModState.hx b/source/funkin/scripting/ModState.hx new file mode 100644 index 00000000..a39b439c --- /dev/null +++ b/source/funkin/scripting/ModState.hx @@ -0,0 +1,7 @@ +package funkin.scripting; + +class ModState extends MusicBeatState { + public function new(stateName:String) { + super(true, stateName); + } +} \ No newline at end of file diff --git a/source/funkin/scripting/Script.hx b/source/funkin/scripting/Script.hx index d21f9fab..fdb4e97f 100644 --- a/source/funkin/scripting/Script.hx +++ b/source/funkin/scripting/Script.hx @@ -32,10 +32,11 @@ class Script extends FlxBasic implements IFlxDestroyable { // Flixel related stuff "FlxG" => flixel.FlxG, "FlxSprite" => flixel.FlxSprite, - "FlxEase" => flixel.tweens.FlxEase, - "FlxTween" => flixel.tweens.FlxTween, + "FlxBasic" => flixel.FlxBasic, "FlxCamera" => flixel.FlxCamera, "state" => flixel.FlxG.state, + "FlxEase" => flixel.tweens.FlxEase, + "FlxTween" => flixel.tweens.FlxTween, "FlxSound" => flixel.system.FlxSound, "FlxAssets" => flixel.system.FlxAssets, "FlxMath" => flixel.math.FlxMath, @@ -53,6 +54,7 @@ class Script extends FlxBasic implements IFlxDestroyable { build: funkin.macros.BuildCounterMacro.getBuildNumber(), name: "Codename Engine" }, + "ModState" => funkin.scripting.ModState, "PlayState" => funkin.game.PlayState, "GameOverSubstate" => funkin.game.GameOverSubstate, "Note" => funkin.game.Note, @@ -68,8 +70,11 @@ class Script extends FlxBasic implements IFlxDestroyable { "Paths" => funkin.system.Paths, "Conductor" => funkin.system.Conductor, "CoolUtil" => funkin.system.CoolUtil, + "XMLUtil" => funkin.system.XMLUtil, "FunkinShader" => funkin.shaders.FunkinShader, "CustomShader" => funkin.shaders.CustomShader, + "FunkinText" => funkin.ui.FunkinText, + "Alphabet" => funkin.ui.Alphabet, ]; } /** diff --git a/source/funkin/system/MusicBeatState.hx b/source/funkin/system/MusicBeatState.hx index 154bef71..83491fc3 100644 --- a/source/funkin/system/MusicBeatState.hx +++ b/source/funkin/system/MusicBeatState.hx @@ -70,12 +70,15 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver public var scriptsAllowed:Bool = true; + public var scriptName:String = null; + inline function get_controls():Controls return PlayerSettings.player1.controls; - public function new(scriptsAllowed:Bool = true) { + public function new(scriptsAllowed:Bool = true, ?scriptName:String) { super(); this.scriptsAllowed = scriptsAllowed; + this.scriptName = scriptName; loadScript(); } @@ -83,7 +86,7 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver if (scriptsAllowed) { if (stateScript == null || stateScript is DummyScript) { var className = Type.getClassName(Type.getClass(this)); - var scriptName = className.substr(className.lastIndexOf(".")+1); + var scriptName = this.scriptName != null ? this.scriptName : className.substr(className.lastIndexOf(".")+1); stateScript = Script.create(Paths.script('data/states/${scriptName}')); stateScript.setParent(this);