Skip to content

Commit 650c0f4

Browse files
Fix Hscript Call event not calling public and static functions (#459)
* fix hscript call event not calling public/static functions also can now call character scripts * cache args
1 parent 2474575 commit 650c0f4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

source/funkin/game/PlayState.hx

+21-1
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,27 @@ class PlayState extends MusicBeatState
13681368

13691369
switch(event.name) {
13701370
case "HScript Call":
1371-
scripts.call(event.params[0], event.params[1].split(','));
1371+
var scriptPacks:Array<ScriptPack> = [scripts, stateScripts];
1372+
for (strLine in strumLines.members) for (char in strLine.characters) scriptPacks.push(char.scripts);
1373+
var args:Array<String> = event.params[1].split(',');
1374+
1375+
for (pack in scriptPacks) {
1376+
pack.call(event.params[0], args);
1377+
//public functions
1378+
if (pack.publicVariables.exists(event.params[0])) {
1379+
var func = pack.publicVariables.get(event.params[0]);
1380+
if (func != null && Reflect.isFunction(func))
1381+
Reflect.callMethod(null, func, args);
1382+
}
1383+
}
1384+
1385+
//static functions
1386+
if (Script.staticVariables.exists(event.params[0])) {
1387+
var func = Script.staticVariables.get(event.params[0]);
1388+
if (func != null && Reflect.isFunction(func))
1389+
Reflect.callMethod(null, func, args);
1390+
}
1391+
13721392
case "Camera Movement":
13731393
curCameraTarget = event.params[0];
13741394
case "Add Camera Zoom":

0 commit comments

Comments
 (0)