From 498af57dd6d068faf95ae665d577dce1d5b97e37 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Wed, 19 Apr 2023 03:04:40 +0200 Subject: [PATCH] enable scripts during playtest option --- assets/songs/dadbattle/scripts/test.hx | 3 +++ source/funkin/editors/charter/Charter.hx | 9 ++++++++ source/funkin/game/PlayState.hx | 26 +++++++++++++----------- source/funkin/options/Options.hx | 1 + 4 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 assets/songs/dadbattle/scripts/test.hx diff --git a/assets/songs/dadbattle/scripts/test.hx b/assets/songs/dadbattle/scripts/test.hx new file mode 100644 index 00000000..5e8a495c --- /dev/null +++ b/assets/songs/dadbattle/scripts/test.hx @@ -0,0 +1,3 @@ +function update(elapsed) { + dad.angle += 25; +} \ No newline at end of file diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 45e61f5d..246c548e 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -177,6 +177,12 @@ class Charter extends UIState { onSelect: _chart_playtest_opponent_here }, null, + { + label: 'Enable scripts during playtesting', + onSelect: _chart_enablescripts, + icon: Options.charterEnablePlaytestScripts ? 1 : 0 + }, + null, { label: "Edit metadata information" } @@ -843,6 +849,9 @@ class Charter extends UIState { playtestChart(0, true); inline function _chart_playtest_opponent_here(_) playtestChart(Conductor.songPosition, true, true); + function _chart_enablescripts(t) { + t.icon = (Options.charterEnablePlaytestScripts = !Options.charterEnablePlaytestScripts) ? 1 : 0; + } function _playback_metronome(t) { t.icon = (Options.charterMetronomeEnabled = !Options.charterMetronomeEnabled) ? 1 : 0; diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index cc0d09d1..8d40e1be 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -550,19 +550,21 @@ class PlayState extends MusicBeatState var camPos:FlxPoint = new FlxPoint(0, 0); - switch(SONG.meta.name) { - // case "": - // ADD YOUR HARDCODED SCRIPTS HERE! - default: - for(content in [ - Paths.getFolderContent('songs/${SONG.meta.name.toLowerCase()}/scripts', true, fromMods ? MODS : BOTH), - Paths.getFolderContent('data/charts/', true, fromMods ? MODS : BOTH)]) { - for(file in content) { - var ext = Path.extension(file).toLowerCase(); - if (Script.scriptExtensions.contains(ext)) - scripts.add(Script.create(file)); + if (!chartingMode || Options.charterEnablePlaytestScripts) { + switch(SONG.meta.name) { + // case "": + // ADD YOUR HARDCODED SCRIPTS HERE! + default: + for(content in [ + Paths.getFolderContent('songs/${SONG.meta.name.toLowerCase()}/scripts', true, fromMods ? MODS : BOTH), + Paths.getFolderContent('data/charts/', true, fromMods ? MODS : BOTH)]) { + for(file in content) { + var ext = Path.extension(file).toLowerCase(); + if (Script.scriptExtensions.contains(ext)) + scripts.add(Script.create(file)); + } } - } + } } add(comboGroup); diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx index ba27502e..a4b38c30 100644 --- a/source/funkin/options/Options.hx +++ b/source/funkin/options/Options.hx @@ -53,6 +53,7 @@ class Options public static var charterMetronomeEnabled:Bool = false; public static var charterShowSections:Bool = true; public static var charterShowBeats:Bool = true; + public static var charterEnablePlaytestScripts:Bool = true; /** * PLAYER 1 CONTROLS