Repository navigation
Lua Script API: HScript Functions
Imports haxe libraries into the interpreter. Basically an import statement in Haxe which imports specific packages into Haxe like sprites, text, tweens, etc.
-
libName- The library name to be referenced. -
libPackage- An optional parameter, The library package to use.
Examples:
- Imports the sound library:
addHaxeLibrary('FlxSound', 'flixel.system') - Imports shader filters:
addHaxeLibrary('ShaderFilter', 'openfl.filters') - Imports CoolUtil:
addHaxeLibrary('CoolUtil')
Import Haxe (Reference):
package; // they are directories that contain modules, i dunno how it works; but very important to use.
// import library_package.library_name | <-- That's the syntax
import flixel.system.FlxSound; // Imports the sound package
import openfl.filters.ShaderFilter; // Imports the shader filter package
import CoolUtil; // Imports CoolUtil haxe file, i think
// Also the semi colon ';' character is very important when declaring functions, packages, variables, etc.runHaxeCode(codeToRun:String, ?varsToBring:Any = null, ?funcToRun:String = null, ?funcArgs:Array<Dynamic> = null)
Runs your haxe code for your Hscripts and stuff.
-
codeToRun- The haxe code to be run, use double brackets[[]]for the string. -
varsToBring- An optional parameter, The Haxe variable(s) to import for string interpolation; Must be a table dictionary. -
funcToRun- An optional parameter, The Haxe function name to be referenced. -
funcArgs- An optional parameter, The argument(s) to be passed to the Haxe function.
Example:
function onCreate()
runHaxeCode([[
debugPrint(text, color); // will print > 'hi'
]], {text = 'hi', color = 0xFF0000})
endExecutes the Haxe function from the runHaxeCode() function.
-
funcToRun- The Haxe function name to be referenced. -
funcArgs- An optional parameter, The argument(s) to be passed to the Haxe function.
Example:
function onCreate()
runHaxeCode([[
function isBool(bool:String) { return bool == 'true' ? true : false; }
]])
local proof = runHaxeFunction('isBool', {'true'})
debugPrint(type(proof)) -- will print > 'boolean'
endWorks exactly the same as setVar() function in Lua.
-
varName- The variable to be referenced. -
value- The specified type of value for the variable to use or to over-write.
Example:
function onCreate()
runHaxeCode([[
setVar('globalVar', 'Hello Haxe!');
setVar('globalYes', [34, 123, 4.20]);
]])
runHaxeCode([[
debugPrint(getVar('globalVar'), 0xf88700); // will print > 'Hello Haxe!'
debugPrint(getVar('globalYes')[2], 0xf88700); // will print > 4.20
]])
-- Calling a Global Haxe Variable into Lua
debugPrint(getProperty('globalYes')[1]) -- will print > 34
debugPrint(getProperty('globalYes')[2]) -- will print > 123
endWorks exactly the same as getVar() function in Lua.
-
varName- The variable to be referenced.
Removes the global variable permanently, if not used anymore.
-
varName- The variable to be referenced.
Works exactly the same as the debugPrint() function.
-
text- The text to be outputed to the top-left of the screen. -
color- An optional parameter, The color for the text to be displayed.
Gets the specified tag object outside the runHaxeCode() function.
-
tag- The object tag name to be referenced.
Example:
function onCreate()
makeLuaSprite('graphicThingy', nil, 0, 0)
makeGraphic('graphicThingy', 1000, 1000, 'ff00ff')
addLuaSprite('graphicThingy', true)
runHaxeCode([[
var theLuaTag = game.getLuaObject('graphicThingy'); // gets the lua tag
theLuaTag.cameras = [game.camHUD]; // Sets it into 'camHUD'
theLuaTag.alpha = 0.5; // Sets the opacity to '0.5'
theLuaTag.angle = 180; // Sets the angle to '180'
]])
endIs the page in some way inaccurate? an error, a typo, or outdated data? To report it, use the "Issue Tab". Or do you wish to include a new function or add new information? use the "Pull Request Tab". Help is always appreciated!
- Event Callbacks
- Custom Sprite
- Custom Text
- Object Functions
- General Functions
- Scripting & File Functions
- Game Input Control Functions
- Language Translation
- HScript Functions
- Custom Substates
- Custom Shaders
- Deprecated & Removed Functions
- Sound & Music Functions
- Tweens & Timers Functions
- Reflection Functions
- Variables