@@ -143,6 +143,16 @@ class PlayState extends MusicBeatState
143143 public var hscriptArray : Array <HScript > = [];
144144 #end
145145
146+
147+ #if LUA_ALLOWED
148+ public var modchartTweens : Map <String , FlxTween > = new Map <String , FlxTween >();
149+ public var modchartSprites : Map <String , ModchartSprite > = new Map <String , ModchartSprite >();
150+ public var modchartTimers : Map <String , FlxTimer > = new Map <String , FlxTimer >();
151+ public var modchartSounds : Map <String , FlxSound > = new Map <String , FlxSound >();
152+ public var modchartTexts : Map <String , FlxText > = new Map <String , FlxText >();
153+ public var modchartSaves : Map <String , FlxSave > = new Map <String , FlxSave >();
154+ #end
155+
146156 public var BF_X : Float = 770 ;
147157 public var BF_Y : Float = 100 ;
148158 public var BF2_X : Float = 770 ;
@@ -326,7 +336,8 @@ class PlayState extends MusicBeatState
326336
327337 // Lua shit
328338 public static var instance : PlayState ;
329- #if LUA_ALLOWED public var luaArray : Array <FunkinLua > = []; #end
339+ #if LUA_ALLOWED public var luaArray : Array <FunkinLua > = [];
340+ public var legacyLuaArray : Array <LegacyFunkinLua > = []; #end
330341
331342 #if (LUA_ALLOWED || HSCRIPT_ALLOWED)
332343 private var luaDebugGroup : FlxTypedGroup <psychlua. DebugLuaText >;
@@ -771,15 +782,16 @@ class PlayState extends MusicBeatState
771782 {
772783 #if LUA_ALLOWED
773784 if (file .toLowerCase ().endsWith (' .lua' ))
774- new FunkinLua (folder + file );
785+ ( ClientPrefs . getGameplaySetting ( ' legacyMode ' , false ) ? new LegacyFunkinLua ( folder + file ) : new FunkinLua (folder + file ) );
775786 #end
776787
777788 #if HSCRIPT_ALLOWED
778789 if (file .toLowerCase ().endsWith (' .hx' ))
779790 initHScript (folder + file );
780791 #end
781- }
792+
782793 #end
794+ }
783795
784796 var camPos : FlxPoint = FlxPoint .get (girlfriendCameraOffset [0 ], girlfriendCameraOffset [1 ]);
785797 if (gf != null )
@@ -1127,7 +1139,7 @@ class PlayState extends MusicBeatState
11271139 {
11281140 #if LUA_ALLOWED
11291141 if (file .toLowerCase ().endsWith (' .lua' ))
1130- new FunkinLua (folder + file );
1142+ ( ClientPrefs . getGameplaySetting ( ' legacyMode ' , false ) ? new LegacyFunkinLua ( folder + file ) : new FunkinLua (folder + file ) );
11311143 #end
11321144
11331145 #if HSCRIPT_ALLOWED
@@ -1342,7 +1354,9 @@ class PlayState extends MusicBeatState
13421354 break ;
13431355 }
13441356 }
1345- if (doPush ) new FunkinLua (luaFile );
1357+ if (doPush )
1358+ (ClientPrefs .getGameplaySetting (' legacyMode' , false ) ? new LegacyFunkinLua (luaFile ) : new FunkinLua (luaFile ));
1359+
13461360 }
13471361 #end
13481362
@@ -1375,8 +1389,18 @@ class PlayState extends MusicBeatState
13751389 #end
13761390 }
13771391
1378- public function getLuaObject (tag : String ): Dynamic
1379- return variables .get (tag );
1392+ public function getLuaObject (tag : String , text : Bool = true ): FlxSprite
1393+ {
1394+ #if LUA_ALLOWED
1395+ if (modchartSprites .exists (tag ))
1396+ return modchartSprites .get (tag );
1397+ if (text && modchartTexts .exists (tag ))
1398+ return modchartTexts .get (tag );
1399+ if (variables .exists (tag ))
1400+ return variables .get (tag );
1401+ #end
1402+ return null ;
1403+ }
13801404
13811405 function startCharacterPos (char : Character , ? gfCheck : Bool = false ) {
13821406 if (gfCheck && char .curCharacter .startsWith (' gf' )) { // IF DAD IS GIRLFRIEND, HE GOES TO HER POSITION
@@ -3950,7 +3974,14 @@ class PlayState extends MusicBeatState
39503974 }
39513975 }
39523976
3953- public function triggerEvent (eventName : String , value1 : String , value2 : String , strumTime : Float ) {
3977+ public function getControl (key : String )
3978+ {
3979+ var pressed : Bool = Reflect .getProperty (controls , key );
3980+ // trace('Control result: ' + pressed);
3981+ return pressed ;
3982+ }
3983+
3984+ public function triggerEvent (eventName : String , value1 : String , value2 : String , ? strumTime : Float ) {
39543985 var flValue1 : Null <Float > = Std .parseFloat (value1 );
39553986 var flValue2 : Null <Float > = Std .parseFloat (value2 );
39563987 if (Math .isNaN (flValue1 )) flValue1 = null ;
@@ -5797,7 +5828,13 @@ class PlayState extends MusicBeatState
57975828 lua .call (' onDestroy' , []);
57985829 lua .stop ();
57995830 }
5831+ for (lua in legacyLuaArray )
5832+ {
5833+ lua .call (' onDestroy' , []);
5834+ lua .stop ();
5835+ }
58005836 luaArray = null ;
5837+ legacyLuaArray = null ;
58015838 FunkinLua .customFunctions .clear ();
58025839 #end
58035840
@@ -6020,7 +6057,7 @@ class PlayState extends MusicBeatState
60206057 for (script in luaArray )
60216058 if (script .scriptName == luaToLoad ) return false ;
60226059
6023- new FunkinLua (luaToLoad );
6060+ ( ClientPrefs . getGameplaySetting ( ' legacyMode ' , false ) ? new LegacyFunkinLua ( luaToLoad ) : new FunkinLua (luaToLoad ) );
60246061 return true ;
60256062 }
60266063 return false ;
@@ -6087,8 +6124,10 @@ class PlayState extends MusicBeatState
60876124 if (exclusions == null ) exclusions = [];
60886125 if (excludeValues == null ) excludeValues = [LuaUtils . Function_Continue ];
60896126
6090- var arr : Array <FunkinLua > = [];
6091- for (script in luaArray )
6127+ // var lua = flixel.util.typeLimit.OneOfTwo;
6128+
6129+ var arr : Array <Dynamic > = [];
6130+ for (script in yutautil. CollectionUtils .toIterable (cast (luaArray :Array < Dynamic > ).concat (legacyLuaArray )))
60926131 {
60936132 if (script .closed )
60946133 {
@@ -6114,7 +6153,7 @@ class PlayState extends MusicBeatState
61146153
61156154 if (arr .length > 0 )
61166155 for (script in arr )
6117- luaArray .remove (script );
6156+ ( luaArray .contains ( script )) ? luaArray . remove (script ) : legacyLuaArray . remove ( cast ( script , LegacyFunkinLua ) );
61186157 #end
61196158 return returnVal ;
61206159 }
0 commit comments