Hscript addon with script classes, imports, usings, properties, string interpolation and more.
- Package
- Import
- Using
- Property
- String interpolation
- Script Class
- Abstracts in script
- Key => value iterator
??and??=operators- Rest
package scripts.hello.world;
import haxe.ds.StringMap; var map = new StringMap(); map.set("Hello","World"); trace(map.get("Hello")); // World
you can use as or in keywords alias.
import haxe.ds.StringMap as StrMap; var map = new StrMap(); map.set("Hello","World"); trace(map.get("Hello")); // World
import haxe.ds.StringMap in StrMap; var map = new StrMap(); map.set("Hello","World"); trace(map.get("Hello")); // World
import Reflect.getProperty; var a = { "hello":"world" }; return getProperty(a,"hello");
using Reflect; var a = { "Hello":"World" }; trace(a.getProperty("Hello")); // World
var _a = 'Hello World'; var a(get,set):String; function get_a():String return _a; function set_a(v:String):String return _a = v; trace(a); // Hello World
var a = 'Hello'; trace('RuleScript: $a World'); // RuleScript: Hello World
var a = { a:'RuleScript', b: () -> 'Hello', c: (a) -> a ? 'World' : ''; }; trace('${a.a}: ${a.b() + ' ' + a.c(true)}'); // RuleScript: Hello World
Rulescript supports scripted classes, they can have a strict and non-strict constructor.
Script :
class ScriptedClass extends test.ScriptedClassTest { public function new(customArg:Int,arg1:String) { trace('Constructor.pre: $customArg, $arg1'); super('Super Arg'); trace('Constructor.post: $customArg, $arg1'); } override public function info() { return 'Scripted class, super info: ${super.info()}'; } }
Source :
class ScriptedClassTest implements RuleScriptedClass extends SrcClass {}
See Main.hx, ScriptedClassTest.hx, ScriptedClass.
RuleScriptAbstracts.txt in any classpath :
test.HelloWorldAbstract
test/HelloWorldAbstract.hx :
abstract HelloWorldAbstract(String) from String to String { public static function rulescriptPrint():HelloWorldAbstract return 'Hello World'; }
Script :
import test.HelloWorldAbstract; trace(HelloWorldAbstract.rulescriptPrint()); // Hello World
More templates in test/src/Main.hx.
var map = [ 'RuleScript' => 'Hello World', ]; for(key => value in map){ trace('$key: $value'); // RuleScript: Hello World }
trace(null ?? 'Hello World'); // Hello World var a = 'hello'; a ??= 'world'; trace(a); // hello a = null; a ??= 'world'; trace(a) // world
var f = function(hello:String, ...rest:Dynamic) { return '$hello: ' + rest.join(' '); } trace(f('Rulescript','Hello','World','!')); // Rulescript: Hello World ! trace(f('Rulescript',...['Hello','World','!'])); // Rulescript: Hello World !
- Script
usingcallback supports max number of arguments is 8. - Wildcard imports don't support.
- AbstractMacro ports only static fields
- Lua Parser
- Improve hscript module parser
-
Installing lib:
-
haxelib version
- Haxelib :
haxelib install rulescript - Hmm :
hmm haxelib rulescript
- Haxelib :
-
github version
- Haxelib :
haxelib git rulescript https://github.com/Kriptel/RuleScript.git - Hmm :
hmm git rulescript https://github.com/Kriptel/RuleScript.git
- Haxelib :
-
github version (dev)
- Haxelib :
haxelib git rulescript https://github.com/Kriptel/RuleScript.git dev - Hmm :
hmm git rulescript https://github.com/Kriptel/RuleScript.git dev
- Haxelib :
-
-
Adding lib to your project:
Hxml :
-lib rulescriptLime/OpenFL :
<haxelib name="rulescript"/>