This basic object helps with the creation of scripts, along with having neat helper functions to initialize and stop scripts

It is highly recommended that you override this class to add custom defualt variables and such.

Static variables

@:value([])@:unreflectivestaticblocklistImports:Array<String> = []

Contains Classes/Enums that cannot be accessed via HScript.

you may find this useful if you want your project to be more secure.

@:value(new StringMap<Iris>())staticinstances:StringMap<Iris> = new StringMap<Iris>()

Map with stored instances of scripts.

@:value(["Type" => ProxyType])@:unreflectivestaticproxyImports:Map<String, Dynamic> = ["Type" => ProxyType]

Contains proxies for classes. So they can be sandboxed or add extra functionality.

@:value([new UsingEntry("StringTools", function(o:Dynamic, f:String, args:Array<Dynamic>):Dynamic { if (f == "isEof") return null; switch (Type.typeof(o)) { case TInt if (f == "hex"): return StringTools.hex(o, args[0]); case TClass(String): if (Reflect.hasField(StringTools, f)) { var field = Reflect.field(StringTools, f); if (Reflect.isFunction(field)) { return Reflect.callMethod(StringTools, field, [o].concat(args)); }; }; default: }; return null; }), new UsingEntry("Lambda", function(o:Dynamic, f:String, args:Array<Dynamic>):Dynamic { if (Tools.isIterable(o)) { if (Reflect.hasField(Lambda, f)) { var field = Reflect.field(Lambda, f); if (Reflect.isFunction(field)) { return Reflect.callMethod(Lambda, field, [o].concat(args)); }; }; }; return null; })])staticregisteredUsingEntries:Array<UsingEntry> = [new UsingEntry("StringTools", function(o:Dynamic, f:String, args:Array<Dynamic>):Dynamic { if (f == "isEof") return null; switch (Type.typeof(o)) { case TInt if (f == "hex"): return StringTools.hex(o, args[0]); case TClass(String): if (Reflect.hasField(StringTools, f)) { var field = Reflect.field(StringTools, f); if (Reflect.isFunction(field)) { return Reflect.callMethod(StringTools, field, [o].concat(args)); }; }; default: }; return null; }), new UsingEntry("Lambda", function(o:Dynamic, f:String, args:Array<Dynamic>):Dynamic { if (Tools.isIterable(o)) { if (Reflect.hasField(Lambda, f)) { var field = Reflect.field(Lambda, f); if (Reflect.isFunction(field)) { return Reflect.callMethod(Lambda, field, [o].concat(args)); }; }; }; return null; })]

Static methods

staticaddProxyImport(name:String, value:Dynamic):Void

staticdestroyAll():Void

Destroys every single script found within the Iris.instances map.

 *
 * **WARNING**: this action CANNOT be undone.

staticdynamicerror(x:String, ?pos:Null<PosInfos>):Void

Custom error function for script wrappers.

staticdynamicfatal(x:String, ?pos:Null<PosInfos>):Void

Custom fatal error function for script wrappers.

staticdynamiclogLevel(level:ErrorSeverity, x:String, ?pos:Null<PosInfos>):Void

Custom warning function for script wrappers.

Overriding is recommended if you're doing custom error handling.

staticdynamicprint(x:String, ?pos:Null<PosInfos>):Void

Custom print function for script wrappers.

staticregisterUsingGlobal(name:String, call:UsingCall):UsingEntry

staticdynamicwarn(x:String, ?pos:Null<PosInfos>):Void

Custom warning function for script wrappers.

Overriding is recommended if you're doing custom error handling.

Constructor

new(scriptCode:String, ?config:Null<AutoIrisConfig>)

Instantiates a new Script with the string value.

trace("Hello World!");

will trace "Hello World!" to the standard output.

Parameters:

scriptCode

the script to be parsed, e.g:

Variables

@:value(null)config:IrisConfig = null

Config file, set when creating a new Iris instance.

read onlyname:String

Current script name, from config.name.

Methods

call(fun:String, ?args:Array<Dynamic>):IrisCall

Calls a method on the script

Parameters:

fun

The name of the method you wanna call.

args

The arguments that the method needs.

destroy():Void

Destroys the current instance of this script along with its parser, and also removes it from the Iris.instances map.

WARNING: this action CANNOT be undone.

execute():Dynamic

Executes this script and returns the interp's run result.

exists(field:String):Bool

Checks the existance of a field or method within your script.

Parameters:

field

The field to check if exists.

get(field:String):Dynamic

Returns a field from the script.

Parameters:

field

The field that needs to be looked for.

@:value({ force : false })parse(force:Bool = false):Expr

If you want to override the script, you should do parse(true);

just parse(); otherwise, forcing may fix some behaviour depending on your implementation.

preset():Void

Appends Default Classes/Enums for the Script to use.

@:value({ allowOverride : true })set(name:String, value:Dynamic, allowOverride:Bool = true):Void

Sets a new field to the script

Parameters:

name

The name of your new field, scripts will be able to use the field with the name given.

value

The value for your new field.

allowOverride

If set to true, when setting the new field, we will ignore any previously set fields of the same name.