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
Copy file name to clipboardExpand all lines: README.md
+65-7Lines changed: 65 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,58 @@ class Main {
61
61
62
62
### New features
63
63
64
+
#### Import
65
+
SScript supports normal imports, wildcard imports and imports with aliases.
66
+
67
+
```haxe
68
+
import hscript.SScript;
69
+
70
+
class Main {
71
+
static function main() {
72
+
var script:SScript = new SScript();
73
+
script.doString("
74
+
import Date;
75
+
trace(Data.now());
76
+
");
77
+
}
78
+
}
79
+
```
80
+
81
+
##### Wildcard Imports
82
+
```haxe
83
+
import hscript.SScript;
84
+
85
+
class Main {
86
+
static function main() {
87
+
var script:SScript = new SScript();
88
+
script.doString("
89
+
import sys.*;
90
+
trace(FileSystem); // Class<sys.FileSystem>
91
+
");
92
+
}
93
+
}
94
+
```
95
+
96
+
SScript uses a macro for wildcard imports. In most cases, it works fine. However, if you want to disable this feature, you can define `DISABLED_MACRO_SUPERLATIVE` in your project. This is not recommended, however, as doing so will also make the `FULL` preset mode unavailable.
SScript supports string interpolation. Just like normal haxe, special identifiers, denoted by the dollar sign `$` within a String enclosed by single-quote `'` characters, are evaluated as if they were concatenated identifiers.
66
118
@@ -103,7 +155,7 @@ class Main {
103
155
trace(matches.length); // 3
104
156
105
157
// Email addresses regular expression
106
-
// (In files, use one back slash instead
158
+
// (In files, use one back slash instead)
107
159
var emailReg = ~/[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z][A-Z][A-Z]*/i;
This makes `import` optional and it is useful for one-time use of a class or enum.
143
-
This feature may be exhausting for weak machines, so if you wish to disable it set `hscript.SScript.defaultImprovedField` to `false`.
195
+
This feature may be exhausting for weak machines and is disabled by default, so if you wish to enable it set `hscript.SScript.defaultImprovedField` to `true`.
144
196
145
197
## Reworked Function Arguments
146
198
Function arguments have been reworked, so optional arguments will work like native Haxe.
@@ -170,10 +222,11 @@ class Main {
170
222
Presets are the variables that get set before the script gets executed.
171
223
172
224
SScript has a presetting system where you can set multiple preset modes
173
-
to customize presetting. Currently it has 3 modes, `NONE`, `MINI`and `REGULAR`.
225
+
to customize presetting. Currently it has 4 modes, `NONE`, `MINI`, `REGULAR`and `FULL`.
174
226
175
-
`MINI` only contains basic classes and extremely lightweight,
176
-
`REGULAR` contains slightly more and it includes more common classes aswell.
227
+
-`MINI` only contains basic classes and extremely lightweight,
228
+
-`REGULAR` contains slightly more and it includes more common classes aswell.
229
+
-`FULL` contains all existing classes, expensive when there are many scripts being handled. (Avaiable only if `DISABLED_MACRO_SUPERLATIVE` is undefined)
177
230
178
231
Example:
179
232
```haxe
@@ -182,8 +235,8 @@ import hscript.SScript;
182
235
183
236
class Main {
184
237
static function main() {
185
-
SScript.defaultPreset = PresetMode.REGULAR;
186
-
var script = new SScript("trace(Json); // haxe.Json class is included with REGULAR");
238
+
SScript.defaultPreset = PresetMode.FULL;
239
+
var script = new SScript("trace(Json); // haxe.Json class is included with REGULAR and FULL");
187
240
}
188
241
}
189
242
```
@@ -316,6 +369,7 @@ Special objects are especially useful for OpenFL and Flixel states.
316
369
317
370
Example:
318
371
```haxe
372
+
import flixel.FlxG;
319
373
import hscript.SScript;
320
374
321
375
class PlayState extends flixel.FlxState
@@ -324,10 +378,14 @@ class PlayState extends flixel.FlxState
0 commit comments