You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hscript addon with imports, usings, string interpolation and more.
3
+
Hscript addon with script classes, imports, usings, properties, string interpolation and more.
4
4
5
5
## Features:
6
6
7
+
-[Package](#package)
8
+
-[Import](#import)
9
+
- [Alias](#import-with-alias)
10
+
- [Static field](#static-field-import)
11
+
-[Using](#using)
12
+
-[Property](#property)
13
+
-[String interpolation](#string-interpolation)
14
+
-[Script Class](#rulescriptedclass)
15
+
-[Abstracts in script](#abstracts-in-script)
16
+
-[Key => value Iterator](#key--value-iterator)
17
+
-[`??` and `??=` operators](#-and--operators)
18
+
7
19
### Package
8
-
package keyword (optional).
9
20
```haxe
10
21
package scripts.hello.world;
11
22
```
@@ -34,6 +45,17 @@ map.set("Hello","World");
34
45
trace(map.get("Hello")); // World
35
46
```
36
47
48
+
### Static field import
49
+
```haxe
50
+
import Reflect.getProperty;
51
+
52
+
var a = {
53
+
"hello":"world"
54
+
};
55
+
56
+
return getProperty(a,"hello");
57
+
```
58
+
37
59
### Using
38
60
```haxe
39
61
using Reflect;
@@ -44,6 +66,21 @@ var a = {
44
66
trace(a.getProperty("Hello")); // World
45
67
```
46
68
69
+
### Property
70
+
```haxe
71
+
var _a = 'Hello World';
72
+
73
+
var a(get,set):String;
74
+
75
+
function get_a():String
76
+
return _a;
77
+
78
+
function set_a(v:String):String
79
+
return _a = v;
80
+
81
+
trace(a); // Hello World
82
+
```
83
+
47
84
### String interpolation
48
85
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.
Rulescript supports scripted classes, they can have a strict and non-strict constructor.
102
+
103
+
Script :
104
+
```haxe
105
+
class ScriptedClass extends test.ScriptedClassTest
106
+
{
107
+
public function new(customArg:Int,arg1:String)
108
+
{
109
+
trace('Constructor.pre: $customArg, $arg1');
110
+
111
+
super('Super Arg');
112
+
113
+
trace('Constructor.post: $customArg, $arg1');
114
+
}
115
+
116
+
override public function info()
117
+
{
118
+
return 'Scripted class, super info: ${super.info()}';
119
+
}
120
+
}
121
+
```
122
+
Source :
123
+
```haxe
124
+
class ScriptedClassTest implements RuleScriptedClass extends SrcClass {}
125
+
```
126
+
127
+
See [`Main.hx`](./test/src/Main.hx#l267), [`ScriptedClassTest.hx`](./test/src/test/ScriptedClassTest.hx), [`ScriptedClass`](./test/scripts/haxe/ScriptedClass.rhx).
0 commit comments