Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
khuonghoanghuy committed Jan 9, 2025
2 parents 55aa8c9 + 3c5170e commit 1dae360
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/Coding-Game.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ function onCreate()

### Making a Group
```haxe
var group:FlxTypedGroup<FlxSprite> = [];
var group:Dynamic;
function onCreate()
{
group = createTypedGroup();
group = createTypedGroup(group);
add(group);
for (i in 0...5)
Expand Down
13 changes: 10 additions & 3 deletions source/ScriptedClass.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ using StringTools;
class ScriptedClass extends FlxUIState
{
public var script:HScript = null;
public var path:String = "";

public static var instance:ScriptedClass = null;
public static var trackerFolder:Int = 0;
var path:String = "";

public function new(fileName:String, ?args:Array<Dynamic>)
{
super();
if (fileName != null)
path = fileName;

instance = this;

trackerFolder = PlayState.trackerFolder;
try
{
var filePath = "mods/" + PolyHandler.trackedMods[trackerFolder].id + "/data/classes/" + fileName + ".hxs";
var filePath = "mods/" + PolyHandler.trackedMods[trackerFolder].id + "/data/classes/" + path + ".hxs";

if (FileSystem.exists(filePath))
path = filePath;
Expand All @@ -37,6 +40,10 @@ class ScriptedClass extends FlxUIState
script = null;
trace('Error getting script from $fileName!\n$e');
}

scriptExecute("new", args);

super();
}

override function create()
Expand Down
12 changes: 9 additions & 3 deletions source/ScriptedSubClass.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ using StringTools;
class ScriptedSubClass extends FlxUISubState
{
public var script:HScript = null;
public var path:String = "";

public static var instance:ScriptedSubClass = null;
public static var trackerFolder:Int = 0;
var path:String = "";

public function new(fileName:String, ?args:Array<Dynamic>)
{
super();
if (fileName != null)
path = fileName;

instance = this;
trackerFolder = PlayState.trackerFolder;
try
{
var filePath = "mods/" + PolyHandler.trackedMods[trackerFolder].id + "/data/classes/" + fileName + ".hxs";
var filePath = "mods/" + PolyHandler.trackedMods[trackerFolder].id + "/data/classes/" + path + ".hxs";

if (FileSystem.exists(filePath))
path = filePath;
Expand All @@ -36,6 +38,10 @@ class ScriptedSubClass extends FlxUISubState
script = null;
trace('Error getting script from $fileName!\n$e');
}

scriptExecute("new", args);

super();
}

override function create()
Expand Down

0 comments on commit 1dae360

Please sign in to comment.