-
Notifications
You must be signed in to change notification settings - Fork 61
HScript Notes
Nicolas Cannasse edited this page Apr 4, 2020
·
2 revisions
You can edit hscript (.hx) files as part of the Resource View in HIDE. The code editor is Monaco (Visual Studio Code editor component).
By default, it will only check for correct syntax, but it can also be setup for type checking.
In order to do that, you need first to compile your Haxe project with -xml api.xml
, this will generate an XML file containing all the types and classes of your project, allowing to use this type information to type check hscript files.
Then, you can setup your res/props.json
this way:
{
"script.api.files" : ["../api.xml"],
"script.api" : {
"hx" : {
"globals" : { "flags" : "Dynamic" },
"context" : "script.Api",
"cdbEnums" : ["mission"]
}
}
}
Here, you are defining:
- the api XML to import for type checking, produced by
haxe -xml api.xml
output - the global variables with their types that will be accessible within the script
- the "context", which means that all public variables and methods of this class will be globally accessible within the script
- the "cdbEnums", which means that for each of these CDB types, a global
Mission
enum will be available just the same way CDB defines it in Haxe. This is better than sharing the haxe-generated enum as a global because you don't have recompile your api.xml in order to have the results corresponding to current CDB values.