-
Notifications
You must be signed in to change notification settings - Fork 3
Defining scripted types
ashley edited this page Aug 9, 2026
·
3 revisions
You can define scripted types in the following ways...
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 (maybe obviously) can't be imported in any other scripts by default.
Modules work (almost) exactly the same you would expect in Haxe!
Currently, you can define the following types in scripts...
- Classes
- Interfaces
- Enums
- Typedefs
- Alias
- Struct / json*
- Can be defined but are ignored by Hscript due to technical limitations.
- Abstracts
- Enum abstracts
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!
Look at the Loading scripts page to learn how to implement modules in your project.
HscriptInsanity by emi3