Skip to content

a Haxe Script fork, intended to add features and fix issues with the original hscript with added features for UPF.

License

Notifications You must be signed in to change notification settings

Untitled-Psych-Fork/hscript-iris-UPF

 
 

Repository files navigation

HScript Iris


a HScript extension made to make the process of creating a script way easier.



USAGE

Initializing a Iris Script should be fairly easy and very much self-explanatory

// *
// assets/scripts/hi.hx
// *

// import somepackage.SomeModule;

final greeting:String = "Hello from Iris!";

function sayHello() {
	trace(greeting);

	/*
	// if you try this, this function will crash as `greeting` is a constant value
	greeting = "Uh Oh!";
	// if SomeModule was imported, you can use it here!
	var module:SomeModule = new SomeModule();
	*/
}

function countUpTo(number:Int) {
	for (i in 1...number+1)
		trace(i);
}

// *
// * src/Main.hx
// *

import crowplexus.iris.Iris;
import crowplexus.iris.IrisConfig;

class Main {
	static function main():Void {
		// reminder that the rules are completely optional.
		final rules:RawIrisConfig = {name: "My Script", autoRun: false, autoPreset: true};
		final getText:String->String = #if sys sys.io.File.getContent #elseif openfl openfl.utils.Assets.getText #end;
		var myScript:Iris = new Iris(getText("assets/scripts/hi.hx"), rules);

		// this is necessary in case the `autoRun` rule is disabled when initializing the script, if not it will initialize by itself.
		myScript.execute();

		myScript.call("sayHello"); // prints "Hello from Iris!"
		myScript.call("countUpTo", [5]); // prints "1, 2, 3, 4, 5"
	}
}

About

a Haxe Script fork, intended to add features and fix issues with the original hscript with added features for UPF.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haxe 100.0%