Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Hscript Call event not calling public and static functions #459

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion source/funkin/game/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,27 @@ class PlayState extends MusicBeatState

switch(event.name) {
case "HScript Call":
scripts.call(event.params[0], event.params[1].split(','));
var scriptPacks:Array<ScriptPack> = [scripts, stateScripts];
for (strLine in strumLines.members) for (char in strLine.characters) scriptPacks.push(char.scripts);
var args:Array<String> = event.params[1].split(',');

for (pack in scriptPacks) {
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, args);
}
}

//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, args);
}

case "Camera Movement":
curCameraTarget = event.params[0];
case "Add Camera Zoom":
Expand Down