|
| 1 | +# RuleScript |
| 2 | + |
| 3 | +Hscript addon with imports, usings, string interpolation and more. |
| 4 | + |
| 5 | +## Features: |
| 6 | + |
| 7 | +### Package : |
| 8 | +package keyword (optional). |
| 9 | +```haxe |
| 10 | +package scripts.hello.world; |
| 11 | +``` |
| 12 | +### Import : |
| 13 | +```haxe |
| 14 | +import haxe.ds.StringMap; |
| 15 | +
|
| 16 | +var map = new StringMap(); |
| 17 | +map.set("Hello","World"); |
| 18 | +trace(map.get("Hello")); // World |
| 19 | +``` |
| 20 | +### Import with alias: |
| 21 | +you can use `as` or `in` keywords alias. |
| 22 | +```haxe |
| 23 | +import haxe.ds.StringMap as StrMap; |
| 24 | +
|
| 25 | +var map = new StrMap(); |
| 26 | +map.set("Hello","World"); |
| 27 | +trace(map.get("Hello")); // World |
| 28 | +``` |
| 29 | +You also can use `in` keyword. |
| 30 | +```haxe |
| 31 | +import haxe.ds.StringMap in StrMap; |
| 32 | +
|
| 33 | +var a = { |
| 34 | + "Hello":"World" |
| 35 | +}; |
| 36 | +trace(a.getProperty("Hello")); // World |
| 37 | +``` |
| 38 | +### Using: |
| 39 | +```haxe |
| 40 | +using Reflect; |
| 41 | +
|
| 42 | +var map = new StrMap(); |
| 43 | +map.set("Hello","World"); |
| 44 | +trace(map.get("Hello")); // World |
| 45 | +``` |
| 46 | + |
| 47 | +### String interpolation (Experimental) |
| 48 | +RuleScript supports [String Interpolation](https://haxe.org/manual/lf-string-interpolation.html), but you can only use identifiers, double quotes string, calls without arguments and `+` operator. |
| 49 | +```haxe |
| 50 | +var a = 'Hello'; |
| 51 | +return 'RuleScript: $a World'; // RuleScript: Hello World |
| 52 | +``` |
| 53 | + |
| 54 | +More templates in `test/src/Main.hx`. |
| 55 | +# Limitations |
| 56 | + |
| 57 | +- String interpolations don't support many functions. |
| 58 | +- Script `using` callback supports max number of arguments is 8. |
| 59 | +- [Wildcard imports](https://haxe.org/manual/type-system-import.html#wildcard-import) don't support. |
| 60 | + |
| 61 | +# To Do: |
| 62 | +- Lua Parser |
| 63 | +- Importing abstract classes in scripts |
| 64 | +- Improve String Interpolation |
| 65 | +- Improve hscript module parser |
| 66 | + |
| 67 | +# Install |
| 68 | + |
| 69 | +1. Installing lib : |
| 70 | +- Haxelib : `haxelib git rulescript https://github.com/Kriptel/RuleScript.git` |
| 71 | +- Hmm : `hmm git rulescript https://github.com/Kriptel/RuleScript.git` |
| 72 | +2. Adding lib to your project : |
| 73 | +- Hxml : |
| 74 | +```hxml |
| 75 | +-lib rulescript |
| 76 | +``` |
| 77 | +- Lime/OpenFL : |
| 78 | +```xml |
| 79 | +<haxelib name="rulescript"/> |
| 80 | +``` |
0 commit comments