Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.

Caveats

skellypupper edited this page Dec 15, 2022 · 8 revisions

Unfortunately there are quite a few things that can't be done in hscript the same way they can be done in haxe. This page is here to tell you what a few of those observed things are and how they can be worked around.

Variables

Since hscript doesn't get stored in memory to run, you can't make persistent variables using var. The edak solution to this is rather simple. Most script types come with the vars property, which is a map that can store your variables persistently.

// these will only be available in the function you run them in.
var foo = "bar";
var cool = "swag";
// these will work any function in your script.
vars["foo"] = "bar";
vars["cool"] = "swag";

FlxSprite#makeGraphic Doing Nothing

No understood reason for why this happens. The workaround is after running the function, to set the sprites height and width properties manually.

var coolSprite = new FlxSprite().makeGraphic(27, 27);
coolSprite.width = 27;
coolSprite.height = 27;

Enum Types Don't Work

Enum types aren't supported in hscript and there is no workaround for this. This means you cannot use enum property arguments in your scripts. (i.e sprite.screenCenter(X);)

import Doesn't Work

The import statement isn't supported in hscript. Edak has a workaround function for that achieves the same effect: importLib which imports the requested module for use in your script.

// using this in hscript might just make your script not run at all
import flixel.FlxBasic;
// this works
importLib("flixel.FlxBasic");

If you'd like to import a module under an alias name (like as), you can add a second arg to the function to rename it. (i.e importLib("flixel.FlxBasic", "BasicButAwesome");) If a module is already imported to your script and you try to import it again, it won't import anything. Same with importing non-existent modules.

FlxColor

FlxColor is an abstract type which isn't supported by hscript. Currently there is no workaround for this. You can still use hex ints as color values.

Clone this wiki locally