From 5ddc5439ddc28c31e515ed0c84a357f9781ad787 Mon Sep 17 00:00:00 2001 From: TheZoroForce240 <86524550+TheZoroForce240@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:41:49 +0000 Subject: [PATCH 1/2] fix hscript call event not calling public/static functions also can now call character scripts --- source/funkin/game/PlayState.hx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 1b5bf86c9..047218341 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1365,7 +1365,26 @@ class PlayState extends MusicBeatState switch(event.name) { case "HScript Call": - scripts.call(event.params[0], event.params[1].split(',')); + var scriptPacks:Array = [scripts, stateScripts]; + for (strLine in strumLines.members) for (char in strLine.characters) scriptPacks.push(char.scripts); + + for (pack in scriptPacks) { + pack.call(event.params[0], event.params[1].split(',')); + //public functions + if (pack.publicVariables.exists(event.params[0])) { + var func = pack.publicVariables.get(event.params[0]); + if (func != null && Reflect.isFunction(func)) + Reflect.callMethod(null, func, event.params[1].split(',')); + } + } + + //static functions + if (Script.staticVariables.exists(event.params[0])) { + var func = Script.staticVariables.get(event.params[0]); + if (func != null && Reflect.isFunction(func)) + Reflect.callMethod(null, func, event.params[1].split(',')); + } + case "Camera Movement": curCameraTarget = event.params[0]; case "Add Camera Zoom": From f2f5622d3cc4ffa84d125104dcab5ee568dc2769 Mon Sep 17 00:00:00 2001 From: TheZoroForce240 <86524550+TheZoroForce240@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:47:40 +0000 Subject: [PATCH 2/2] cache args --- source/funkin/game/PlayState.hx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 047218341..506678395 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1367,14 +1367,15 @@ class PlayState extends MusicBeatState case "HScript Call": var scriptPacks:Array = [scripts, stateScripts]; for (strLine in strumLines.members) for (char in strLine.characters) scriptPacks.push(char.scripts); + var args:Array = event.params[1].split(','); for (pack in scriptPacks) { - pack.call(event.params[0], event.params[1].split(',')); + pack.call(event.params[0], args); //public functions if (pack.publicVariables.exists(event.params[0])) { var func = pack.publicVariables.get(event.params[0]); if (func != null && Reflect.isFunction(func)) - Reflect.callMethod(null, func, event.params[1].split(',')); + Reflect.callMethod(null, func, args); } } @@ -1382,7 +1383,7 @@ class PlayState extends MusicBeatState if (Script.staticVariables.exists(event.params[0])) { var func = Script.staticVariables.get(event.params[0]); if (func != null && Reflect.isFunction(func)) - Reflect.callMethod(null, func, event.params[1].split(',')); + Reflect.callMethod(null, func, args); } case "Camera Movement":