Skip to content

Commit 9a27517

Browse files
committed
fixing destroy in global having no static anymore
1 parent 734b139 commit 9a27517

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

source/funkin/backend/scripting/GlobalScript.hx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,8 @@ class GlobalScript {
106106
});
107107
}
108108

109-
public static function event<T:CancellableEvent>(name:String, event:T):T {
110-
if (scripts != null)
111-
scripts.event(name, event);
112-
return event;
113-
}
114-
115-
public static function call(name:String, ?args:Array<Dynamic>) {
116-
if (scripts != null)
117-
scripts.call(name, args);
118-
}
119-
120109
public static function onModSwitch(newMod:String) {
121-
call("destroy");
122-
scripts = FlxDestroyUtil.destroy(scripts);
110+
destroy();
123111
scripts = new ScriptPack("GlobalScript");
124112
for (i in funkin.backend.assets.ModsFolder.getLoadedMods()) {
125113
var path = Paths.script('data/global/LIB_$i');
@@ -132,12 +120,24 @@ class GlobalScript {
132120
}
133121
}
134122

135-
public static function beatHit(curBeat:Int) {
136-
call("beatHit", [curBeat]);
123+
public static inline function event<T:CancellableEvent>(name:String, event:T):T {
124+
if (scripts != null)
125+
scripts.event(name, event);
126+
return event;
137127
}
138128

139-
public static function stepHit(curStep:Int) {
129+
public static inline function call(name:String, ?args:Array<Dynamic>)
130+
if (scripts != null) scripts.call(name, args);
131+
132+
public static inline function beatHit(curBeat:Int)
133+
call("beatHit", [curBeat]);
134+
135+
public static inline function stepHit(curStep:Int)
140136
call("stepHit", [curStep]);
137+
138+
public static inline function destroy() if (scripts != null) {
139+
call("destroy");
140+
scripts = FlxDestroyUtil.destroy(scripts);
141141
}
142142
}
143143
#end

source/funkin/backend/system/MainState.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class MainState extends FlxState {
9292
}
9393
#end
9494

95+
#if GLOBAL_SCRIPT
96+
funkin.backend.scripting.GlobalScript.destroy();
97+
#end
9598
funkin.backend.scripting.Script.staticVariables.clear();
9699

97100
#if MOD_SUPPORT

0 commit comments

Comments
 (0)