-
Notifications
You must be signed in to change notification settings - Fork 0
Defining scripted types
HscriptInsanity supports defining types (such as classes or enums) within scripts! Below is a comprehensive list of what you can do with this library...
Currently, you can define the following types in scripts...
Support for currently unsupported types is planned to be introduced in the near future.
Defining fields at module level is also supported within scripted modules!
You can simply declare types within your scripts!
class Message {
public var text:String;
public function new(text:String) { this.text = text; }
public function alert():String { trace(text); }
}
new Message('hello world!').alert(); // hello world!The code example above should work correctly in a script.
The only caveat to doing this is that script defined types can't be imported in any other scripts by default (maybe obviously).
Modules work (almost) exactly the same you would expect in Haxe!
Look at the Loading scripts page to learn how to implement modules in your project.
A handful of the issues below arise from type parameters being stripped at runtime.
-
Abstracts
- Still rather experimental!!! You might encounter bugs or inconsistent behaviors for the time being, but they're still being fixed.
- Typing may be degraded. This is also the case when using compiled abstracts.
-
Typedefs
- Struct / json typedefs are parsed without errors but are not enforced or checked at runtime.
HscriptInsanity by emi3