Lua Script API: Object Functions - Lokitot/FNF-SoulEngine GitHub Wiki
Graphics Functions
makeGraphic(obj:String, width:Int, height:Int, color:String)
Used for making an object use a solid color Width x Height frame instead of a texture.
obj
- Lua Sprite tag or Object variable namewidth
- Width in pixels of the graphic you want to createheight
- Height in pixels of the graphic you want to createcolor
- Color string, works the same as getColorFromHex
Example: Use makeGraphic('testBlackSquare', 1000, 1000, '000000')
to make the Lua Sprite with the tag "testBlackSquare" turn into a 1000x1000 black square.
setBlendMode(obj:String, blend:String)
Changes the blend mode of a Sprite (Works similar to how Photoshop do it)
- obj - Lua Sprite tag or Object variable name
- blend - Blend mode to use. Example: add, darken, normal. List of blend modes
Animations Functions
addAnimationByPrefix(tag:String, name:String, prefix:String, framerate:Int = 24, loop:Bool = true)
Adds an animation name
to the Lua Sprite/Object using the tag/variable tag
, it will also overwrite another animation using the same name.
obj
- Lua Sprite tag or Object variable namename
- Animation to be added's nameprefix
- Animation name on the .xml fileframerate
- Optional value, how many frames per second does the animation have, Default value is24
loop
- Optional value, should the animation loop? Default value:true
addAnimationByIndices(tag:String, name:String, prefix:String, indices:String, framerate:Int = 24)
Adds an animation name
to the Lua Sprite/Object using the tag/variable tag
with the specified indices on indices
, it will also overwrite another animation using the same name.
obj
- Lua Sprite tag or Object variable namename
- Animation to be added's nameprefix
- Animation name on the .xml fileindices
- What frames the animation should use, must be separated with a comma. Example:1, 2, 3, 4, 5, 3, 4, 5
framerate
- Optional value, how many frames per second does the animation have, Default value is24
objectPlayAnimation(obj:String, name:String, forced:Bool = false)
Plays animation name
on a Lua Sprite/Object with the tag/variable obj
.
obj
- Lua Sprite tag or Object variable namename
- Animation name to playforced
- If true, the animation will reset if the current animation is the same as the one you're trying to play. Default value is false
Scale Functions
setGraphicSize(obj:String, multX:Float, multY:Float = 0)
obj
- Object from PlayState or Lua SpritemultX
- Horizontal multiplier, default value is 1multY
- Vertical multiplier, default value is 1
scaleObject(obj:String, multX:Float, multY:Float = 0)
Works identically to setGraphicSize
updateHitbox(obj:String)
Use this to update the hitbox in case you change the sprite's scale manually or via a tween.
obj
- Object from PlayState or Lua Sprite
Other Functions
setScrollFactor(obj:String, scrollX:Float, scrollY:Float)
Changes how much a Sprite moves along with the camera.
obj
- Lua Sprite tag or Object variable namescrollX
- Horizontal movement multiplierscrollY
- Vertical movement multiplier
Note: Boyfriend/Opponent have a scrollX/scrollY value of 1, while Girlfriend have a scrollX/scrollY value of 0.95, if you're gonna do background elements, it's highly suggested that you make the values something under 1.
setObjectCamera(obj:String, camera:String)
Changes on which camera should your object be drawn on
obj
- Lua Sprite tag or Object variable namecamera
-game
,hud
orother
.