-
Notifications
You must be signed in to change notification settings - Fork 1
Utility
GhostglowDev edited this page Mar 21, 2024
·
2 revisions
local utl = require "ghostutil.util"
Tweens a number (Returns the tweened values in a callback)
-
tag
: For cancelling the tween andonTweenCompleted
-
from
: The number where the tween starts at -
to
: The number where the tweens ends at -
duration
: The time it takes to complete the tween -
ease
: FlxEase
local foo = {"curry", "tuna"}
function onCreatePost()
utl.switch(foo[1], {
["curry"] = function()
debugPrint("I like my tuna with curry")
end,
["soup"] = function()
debugPrint("I like my tuna with soup")
end
})
-- prints "I like my tuna with curry"
end
-
file
: File path (starts from./mods/
), must include the extension
It's not a must for the file to be a lua file. You can also use .txt for this.
From mods/code/hi.lua:
debugPrint("hello hi")
Script:
function onCreatePost()
utl.runCodeFromFile("code/hi.lua")
-- prints "hello hi"
end
-
v
: The value you want to convert to a boolean
utl.toBool("true")
-- returns true
utl.toBool(0)
-- returns false
utl.toBool("1")
-- returns true
-
v
: Value to check
-
v
: Value to check -
type
: Type
utl.isBool("this is totally a boolean")
-- returns false
utl.isNumber(100)
-- returns true
utl.isNil("nil")
-- returns false
utl.isTable({"im", "table"})
-- returns true
utl.isOfType("is this a string", "number")
-- returns false
-
texts
: The texts you want to print -
color
: The text color (0xAARRGGBB)
utl.debugPrint({"foo", "tuna", "curry"}, "0xFF00FF00")
-- debug-prints "foo", "tuna" and "curry" in a green text all at once
quickText(tag:String, text:String, fieldWidth:Float, pos:Array[Float]|Float, ?instantAdd:Bool, ?size:Float, ?alignment:String, ?color:String, ?centerType:String) -> Void
-
tag
: The text's tag -
text
: The text, duh -
fieldWidth
: How long of texts could line of text fit? -
pos
: Text's position. If both values are the same, useFloat
instead -
instantAdd
: Adds it right after setting it up without having to doaddLuaText()
manually -
size
: Text's size/scale -
alignment
: Alignment type.center
,left
orright
-
color
: Text's color (0xAARRGGBB) -
centerType
: Leave this as nil if you don't want to center, At what axis do you want it to be centered on?x
,y
orxy
utl.quickText("myText", "my cool text", 0, {0, 350}, true, 60, "center", "FFFFFF", "x")
quickSprite(tag:String, filePath:String, pos:Array[Float]|Float, ?instantAdd:Bool, ?inFrontOfChars:Bool, ?scrollFactor:Array[Float]|Float, ?scale:Array[Float]|Float, ?camera:String, ?color:String, ?centerType:String, ?shader:String)
-
tag
: Sprite tag -
filePath
: Sprite's file path, starts in the "images" folder (in assets or in mods) -
pos
: Positions in a table. Example: {100, 300}. If both values are the same, useFloat
instead -
instantAdd
: Do you want to add it without needing to useaddLuaSprite()
after? -
inFrontOfChars
: Is the sprite in front of the characters? -
scrollFactor
: Scroll Factor of the sprite. Example: {3, 1}. If both values are the same, useFloat
instead -
scale
: Scale of the sprite. Example: {2, 2.45}. If both values are the same, useFloat
instead -
camera
: What camera should the sprite be added on? -
color
: FlxColor (color of the sprite) -
centerType
: xy, x, y. Set it to nil if you don't want it to center. -
shader
: Name of the shader from theshaders
folder
I think you already know how this works..
quickGraphic(tag:String, pos:Array[Float]|Float, dimensions:Array[Float], ?color:String, ?instantAdd:Bool, ?inFrontOfChars:Bool, ?scrollFactor:Array[Float]|Float, ?scale:Array[Float]|Float, ?camera:String, ?centerType:String, ?shader:String)
All-in-one makeGraphic
. made as a lua graphic counterpart to the function 'quickSprite' and 'quickText'.
-
tag
: Sprite tag -
pos
: Positions in a table. Example: {100, 300}. If both values are the same, useFloat
instead -
dimensions
: Graphic's width and height. If both values are the same, useFloat
instead -
color
: FlxColor (color of the graphic) -
instantAdd
: Do you want to add it without needing to useaddLuaSprite
after? -
inFrontOfChars
: Is the graphic infront of the characters -
scrollFactor
: Scroll factor of the graphic. Example: {3, 1}. If both values are the same, useFloat
instead -
scale
: Scale of the graphic. Example: {2, 2.1}. If both values are the same, useFloat
instead -
camera
: "game", "hud" or "other" -
centerType
: xy, x, y. Set it to nil if you don't want it to center. -
shader
: Name of the shader theshaders
folder
I think you already know how this works..
Reading this wiki is recommended before using GhostUtil