From ea8e2ba35d6c36ef51cc30d96b26b901fbf63878 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Fri, 4 Nov 2022 19:55:29 +0100 Subject: [PATCH] some hscript stuff!! --- assets/data/charts/test/modchart.hx | 1 + assets/data/scripts/pixel.hx | 19 ++++++++----------- buildnumber.txt | 2 +- source/funkin/scripting/HScript.hx | 6 ++++++ source/funkin/scripting/Script.hx | 15 +++++++++++++++ source/funkin/scripting/ScriptPack.hx | 2 ++ 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/assets/data/charts/test/modchart.hx b/assets/data/charts/test/modchart.hx index a7886b1f..26fcdcd0 100644 --- a/assets/data/charts/test/modchart.hx +++ b/assets/data/charts/test/modchart.hx @@ -1,3 +1,4 @@ function create() { importScript("data/scripts/pixel"); + pixelNotesForBF = false; } \ No newline at end of file diff --git a/assets/data/scripts/pixel.hx b/assets/data/scripts/pixel.hx index 55fd1a61..3ca47f1f 100644 --- a/assets/data/scripts/pixel.hx +++ b/assets/data/scripts/pixel.hx @@ -1,17 +1,12 @@ -import funkin.system.Paths; +public var pixelNotesForBF = true; +public var pixelNotesForDad = true; var daPixelZoom = 6; -// function onStrumCreation(event) { -// event.cancel(); -// var strum = event.strum; -// strum.loadGraphic(Paths.image('stages/school/arrows-pixels'), true, 17, 17); -// strum.animation.add("scroll", [6 + strum.ID]); -// } - -var song = PlayState.SONG.song.toLowerCase(); function onNoteCreation(event) { - if (song == "test" && event.note.mustPress) return; + if (event.note.mustPress && !pixelNotesForBF) return; + if (!event.note.mustPress && !pixelNotesForDad) return; + event.cancel(); var note = event.note; @@ -27,7 +22,9 @@ function onNoteCreation(event) { note.updateHitbox(); } function onStrumCreation(event) { - if (song == "test" && event.player == 1) return; + if (event.player == 1 && !pixelNotesForBF) return; + if (event.player == 0 && !pixelNotesForDad) return; + event.cancel(); var strum = event.strum; diff --git a/buildnumber.txt b/buildnumber.txt index 4d642625..5afb033c 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1102 \ No newline at end of file +1104 \ No newline at end of file diff --git a/source/funkin/scripting/HScript.hx b/source/funkin/scripting/HScript.hx index 3a87ef62..cc44026a 100644 --- a/source/funkin/scripting/HScript.hx +++ b/source/funkin/scripting/HScript.hx @@ -17,6 +17,8 @@ class HScript extends Script { var parser = new hscript.Parser(); parser.allowJSON = parser.allowMetadata = parser.allowTypes = true; interp.errorHandler = _errorHandler; + interp.staticVariables = Script.staticVariables; + interp.variables.set("trace", this.trace); try { expr = parser.parseString(code, fileName); @@ -79,4 +81,8 @@ class HScript extends Script { Logs.logText(Std.string(v)) ], TRACE); } + + public override function setPublicMap(map:Map) { + this.interp.publicVariables = map; + } } \ No newline at end of file diff --git a/source/funkin/scripting/Script.hx b/source/funkin/scripting/Script.hx index 598dc0dd..8826e271 100644 --- a/source/funkin/scripting/Script.hx +++ b/source/funkin/scripting/Script.hx @@ -9,6 +9,13 @@ import openfl.utils.Assets; * Class used for scripting. */ class Script extends FlxBasic implements IFlxDestroyable { + /** + * Use "static var thing = true;" in hscript to use those!! + * are reset every mod switch so once youre done with them make sure to make them null!! + */ + public static var staticVariables:Map = []; + + public static function getDefaultVariables():Map { return [ // Haxe related stuff @@ -128,6 +135,14 @@ class Script extends FlxBasic implements IFlxDestroyable { curScript = oldScript; } + /** + * HSCRIPT ONLY FOR NOW + * Sets the "public" variables map for ScriptPack + */ + public function setPublicMap(map:Map) { + + } + /** * Hot-reloads the script, if possible */ diff --git a/source/funkin/scripting/ScriptPack.hx b/source/funkin/scripting/ScriptPack.hx index b8f89540..0ea425de 100644 --- a/source/funkin/scripting/ScriptPack.hx +++ b/source/funkin/scripting/ScriptPack.hx @@ -6,6 +6,7 @@ import funkin.scripting.events.CancellableEvent; class ScriptPack extends Script { public var scripts:Array