diff --git a/README.md b/README.md index dafd880..d05d4cf 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ A game engine using HScript with a scriptable interface to create a complete gam ### Polymod System - This engine uses Polymod as the core system to function. -### HScript-Based System -- You can code the game using the HScript system we developed! +### Haxe Scripting +- This engine support hscript code, you can code haxe as a script! ### Lua Scripting (available from v2.0 and above) - Yes, you can code in Lua with many functions and variables we provide. diff --git a/TODO.md b/TODO.md index f35d206..99c3f25 100644 --- a/TODO.md +++ b/TODO.md @@ -1,11 +1,13 @@ # List TODO for Cruese Engine -## v2.0 (Lua update) +## v2.1 (Menu Update) +- [ ] Rework game menu + +## v2.0 (Lua update) - DONE - [X] Added Lua script (is work lmao) -- [ ] Added alot of function/variable make for lua -- [ ] Make `GameSelectionState` can be editable -- [ ] Fix for Lua `haxe value not supported` from `llua/Convert.hx:34` -- [ ] Fix `mod_version` will also not able to load if the mods not have same version at `api_version` +- [X] Added alot of function/variable make for lua (beta!) +- [X] Fix `mod_version` will also not able to load if the mods not have same version at `api_version` (maybe it just a bug??) - [X] Using `hscript-iris` since this one is better +- [ ] Update `README.md` ## v1.3.1 (Little Fixed) - DONE - [X] Make Splashes can be skipping by press Enter diff --git a/engineVer.json b/engineVer.json index 358b80a..df022f9 100644 --- a/engineVer.json +++ b/engineVer.json @@ -1,3 +1,3 @@ { - "version":"1.3.1" + "version":"2.0" } diff --git a/source/AboutClass.hx b/source/AboutClass.hx index 806d9ca..5eff99e 100644 --- a/source/AboutClass.hx +++ b/source/AboutClass.hx @@ -28,7 +28,7 @@ class AboutClass extends FlxSubState bg.cameras = [camGame]; add(bg); - var text:FlxText = new FlxText(0, 0, 0, 'Engine v' + Lib.application.meta.get("version") + "\nMods and API v" + GameHandler.versionA_M, 24); + var text:FlxText = new FlxText(0, 0, 0, 'Engine v' + Lib.application.meta.get("version") + "\nAPI For Mods v" + GameHandler.versionAPI, 24); text.screenCenter(); text.scrollFactor.set(); text.cameras = [camGame]; diff --git a/source/GameHandler.hx b/source/GameHandler.hx index 57a8123..a07ed56 100644 --- a/source/GameHandler.hx +++ b/source/GameHandler.hx @@ -6,13 +6,12 @@ import flixel.text.FlxText; import flixel.util.FlxColor; import haxe.Http; import haxe.Json; -import openfl.Lib; // just a bunch of function can be used class GameHandler { // public static var version:String = Lib.application.meta.get("version"); - public static var versionA_M:String = "2.0.0"; + public static var versionAPI:String = "2.0.0"; // Bunch Variable for Lua public static var gameText:Map = new Map(); diff --git a/source/HScript-Old.hx b/source/HScript-Old.hx deleted file mode 100644 index 3100aa3..0000000 --- a/source/HScript-Old.hx +++ /dev/null @@ -1,189 +0,0 @@ -package; - -import flixel.FlxCamera; -import flixel.FlxG; -import flixel.FlxSprite; -import flixel.group.FlxGroup.FlxTypedGroup; -import flixel.group.FlxSpriteGroup; -import flixel.text.FlxText; -import flixel.tweens.FlxEase; -import flixel.tweens.FlxTween; -import hscript.*; -import openfl.Lib; -import sys.io.File; - -using StringTools; - -class HScript extends flixel.FlxBasic -{ - public var locals(get, set):Map; - - function get_locals():Map - { - @:privateAccess - return interp.locals; - } - - function set_locals(local:Map) - { - @:privateAccess - return interp.locals = local; - } - - public static var Function_Stop:Dynamic = 1; - public static var Function_Continue:Dynamic = 0; - - public var parser:Parser = new Parser(); - public var interp:Interp = new Interp(); - - public function new(file:String, ?execute:Bool = true) - { - trace("Load File: " + file); - super(); - parser.allowJSON = parser.allowTypes = parser.allowMetadata = true; - - set('importClass', function(daClass:String, ?asDa:String) - { - final splitClassName:Array = [for (e in daClass.split('.')) e.trim()]; - final className:String = splitClassName.join('.'); - final daClass:Class = Type.resolveClass(className); - final daEnum:Enum = Type.resolveEnum(className); - - if (daClass == null && daEnum == null) - Lib.application.window.alert('Class / Enum at $className does not exist.', 'Hscript Error!'); - else { - if (daEnum != null) { - var daEnumField = {}; - for (daConstructor in daEnum.getConstructors()) - Reflect.setField(daEnumField, daConstructor, daEnum.createByName(daConstructor)); - - if (asDa != null && asDa != '') - set(asDa, daEnumField); - else - set(splitClassName[splitClassName.length - 1], daEnumField); - } else { - if (asDa != null && asDa != '') - set(asDa, daClass); - else - set(splitClassName[splitClassName.length - 1], daClass); - } - } - }); - - set("importScript", function(source:String) { - var name:String = StringTools.replace(source, ".", "/"); - var filePath = "mods/" + PolyHandler.trackedMods[PlayState.trackerFolder].id + "/data/" + name + ".hxs"; - var script:HScript = new HScript(filePath, false); - script.execute(filePath, false); - return script.getAll(); - }); - - set("stopScript", function() { - this.destroy(); - }); - - set("trace", function(value:Dynamic) { - trace(value); - }); - - set("config", GameHandler); - set("Action", ActionState); - set("Paths", Paths); - // Flixel - set("FlxG", FlxG); - set("FlxSprite", FlxSprite); - set("FlxCamera", FlxCamera); - set("FlxText", FlxText); - set("FlxTween", FlxTween); - set("FlxEase", FlxEase); - set("FlxColor", GameHandler.colorWorkaround()); - - set("ScriptedClass", ScriptedClass); - set("ScriptedSubClass", ScriptedSubClass); - // Same but replace `Class` with `State` - set("ScriptedState", ScriptedClass); - set("ScriptedSubState", ScriptedSubClass); - set("PlayState", PlayState); - - set("createTypedGroup", function() - { - return new FlxTypedGroup(); - }); - - set("game", PlayState.instance); - set("state", FlxG.state); - set("add", FlxG.state.add); - set("remove", FlxG.state.remove); - - if (execute) - this.execute(file); - } - - public function execute(file:String, ?executeCreate:Bool = true):Void - { - try - { - interp.execute(parser.parseString(File.getContent(file))); - } - catch (e:Dynamic) - Lib.application.window.alert(Std.string(e), 'HScript Error!'); - - trace('Script Loaded Succesfully: $file'); - - if (executeCreate) - call('onCreate', []); - } - - public function set(name:String, val:Dynamic):Void - { - interp?.variables.set(name, val); - locals.set(name, {r: val}); - } - - public function get(name:String):Dynamic - { - if (locals.exists(name) && locals[name] != null) - return locals.get(name).r; - else if (interp.variables.exists(name)) - return interp?.variables.get(name); - - return null; - } - - public function existsVar(name:String):Bool - return interp?.variables.exists(name); - - public function call(name:String, args:Array) - { - if (existsVar(name)) - { - try - { - return Reflect.callMethod(this, get(name), args == null ? [] : args); - } - catch (e:Dynamic) - Lib.application.window.alert(Std.string(e), 'HScript Error!'); - } - - return null; - } - - public function getAll():Dynamic - { - var balls:Dynamic = {}; - - for (i in locals.keys()) - Reflect.setField(balls, i, get(i)); - for (i in interp.variables.keys()) - Reflect.setField(balls, i, get(i)); - - return balls; - } - - override function destroy() - { - super.destroy(); - parser = null; - interp = null; - } -} diff --git a/source/LuaScript.hx b/source/LuaScript.hx index cad81a0..5174fc2 100644 --- a/source/LuaScript.hx +++ b/source/LuaScript.hx @@ -33,7 +33,7 @@ class LuaScript extends FlxBasic } setVar("VERSION", openfl.Lib.application.meta.get("version")); - setVar("VERSION_A_M", GameHandler.versionA_M); + setVar("VERSION_API", GameHandler.versionAPI); setFunction("exitGame", function(exitActually:Bool = false) GameHandler.exitGame(exitActually)); setFunction("resizeApp", function(w:Int, h:Int) GameHandler.resizeApp(w, h)); diff --git a/source/PlayState.hx b/source/PlayState.hx index 207a328..d9f6f00 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1,6 +1,7 @@ package; import flixel.FlxState; +import openfl.Lib; import sys.FileSystem; using StringTools; diff --git a/source/PolyHandler.hx b/source/PolyHandler.hx index fd28dd7..4bcca63 100644 --- a/source/PolyHandler.hx +++ b/source/PolyHandler.hx @@ -1,6 +1,5 @@ package; -import flixel.FlxG; import polymod.Polymod; import polymod.backends.PolymodAssets.PolymodAssetType; import polymod.format.ParseRules;