Skip to content

Lua Script API: Object Functions

Meme1079 edited this page Aug 5, 2022 · 27 revisions

Graphics Functions

makeGraphic(tag:String, width:Int, height:Int, color:String)

Spawns a graphic with no image

  • tag - Lua Sprite tag or Object variable name
  • width - the width of the sprite object
  • height - the height of the sprite object
  • color - the color of the sprite object, must be a hex color!

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

setGraphicSize(obj:String, x:Int, y:Int = 0, updateHitbox:Bool = true)

Changes the size of the graphic

  • obj - Lua Sprite tag or Object variable name
  • x - the x-coordinate of the sprite object
  • y - the x-coordinate of the sprite object
  • updateHitbox - if true will change the sprite's scale manually or via a tween.

Animations Functions

addAnimationByPrefix(tag:String, name:String, prefix:String, framerate:Int = 24, loop:Bool = true)

Adds an animation nameto 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 name
  • name - Animation to be added's name
  • prefix - Animation name on the .xml file
  • framerate - Optional value, how many frames per second does the animation have, Default value is 24
  • 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 name
  • name - Animation to be added's name
  • prefix - Animation name on the .xml file
  • indices - 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 is 24

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 name
  • name - Animation name to play
  • forced - 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
Clone this wiki locally