Skip to content

Lua Script API: General Functions

Meme1079 edited this page Aug 5, 2022 · 58 revisions

Character Functions

characterPlayAnim(character:String, anim:String, forced:Bool = false)

  • character - Can be boyfriend, dad or gf
  • anim - Animation name to be played
  • forced - Can be either true or false, if set to true, it will force the animation to reset if the current animation is the same as the animation to play

characterDance(character:String)

Makes character do the idle dance

  • character - Can be boyfriend, dad or gf

getCharacterX(type:String)

Gets the general X position of a character from the type

  • type - Can be boyfriend, dad or gf

getCharacterY(type:String)

Gets the general Y position of a character from the type

  • type - Can be boyfriend, dad or gf

setCharacterX(type:String)

Sets the general X position of a character from the type, this will also move all precached characters from the same type into the position you want

  • type - Can be boyfriend, dad or gf

setCharacterY(type:String)

Sets the general Y position of a character from the type, this will also move all precached characters from the same type into the position you want

  • type - Can be boyfriend, dad or gf

Score/Accuracy Functions

addScore(value:Int = 0)

Adds value to the current song's score and recalculates rating

addMisses(value:Int = 0)

Adds value to the current song's misses total and recalculates rating

addHits(value:Int = 0)

Adds value to the current song's notes hit total and recalculates rating

addHealth(value:Float = 0)

Adds value to the current song's health total and recalculates rating

setScore(value:Int = 0)

Set the current song's score to value and recalculates rating

setMisses(value:Int = 0)

Set the current song's misses to value and recalculates rating

setHits(value:Int = 0)

Set the current song's hit total to value and recalculates rating

setHealth(value:Int = 0)

Set the current song's health total to value and recalculates rating

setRatingPercent(value:Float)

Sets the rating percent in case you want to do your own rating calculation.

  • value - Should go from 0 to 1 but can actually be whatever value you want, but it's kinda stupid to get out of the base values.

setRatingString(value:String)

Sets the rating name to value in case you want to do your own rating calculation.

getScore()

Get the current song's score

getMisses()

Get the current song's misses

getHits()

Get the current song's hit total

getHealth()

Get the current song's health


Key Press Functions

keyJustPressed(name:String)

Get if the key name just got pressed on the current frame.

Keys: 'left', 'down', 'up', 'right', 'accept', 'back', 'pause', 'reset', 'space'

keyPressed(name:String)

Get if the key name is being held on the current frame.

Keys: 'left', 'down', 'up', 'right', 'space'

keyReleased(name:String)

Get if the key name was released on the current frame.

Keys: 'left', 'down', 'up', 'right', 'space'

keyboardJustPressed(name:String)

Get if the key name just got pressed on the current frame.

name - any key you want but must be capitalize Example: keyboardJustPressed('SHIFT')

keyboardPressed(name:String)

Get if the key name is being held on the current frame.

keyboardReleased(name:String)

Get if the key name was released on the current frame.


Mouse Click functions

mouseClicked(name:String)

Get if the mouse button name just got pressed on the current frame. leave 'name' blank for left mouse

Buttons: 'left', 'right', 'middle'

mousePressed(name:String)

Get if the mouse button name is being held on the current frame.

Buttons: 'left', 'right', 'middle'

mouseReleased(name:String)

Get if the mouse button name was released on the current frame.

Buttons: 'left', 'right', 'middle'


Mouse Click functions

mouseClicked(name:String)

Get if the mouse button name just got pressed on the current frame. leave 'name' blank for left mouse

Buttons: 'left', 'right', 'middle'

mousePressed(name:String)

Get if the mouse button name is being held on the current frame.

Buttons: 'left', 'right', 'middle'

mouseReleased(name:String)

Get if the mouse button name was released on the current frame.

Buttons: 'left', 'right', 'middle'


Other Functions

triggerEvent(name:String, arg1:String, arg2:String)

Triggers an event without you having to chart them.

  • name - Event name on Chart Editor
  • arg1 - Value 1 on Chart Editor
  • arg2 - Value 2 on Chart Editor

addLuaScript(path:String)

Loads another .lua script.

path - Path to LUA relative to the base folder

removeLuaScript(path:String)

removes the loaded .lua script.

path - Path to LUA relative to the base folder

addHaxeLibrary(libName:String, ?libPackage:String = '')

adds a library variable into the interperter

Library: 'FlxG', 'FlxSprite', 'FlxCamera', 'FlxTween', 'FlxEase', 'PlayState', 'game', 'Paths', 'Conductor', 'ClientPrefs', 'Character', 'Alphabet', 'FlxRuntimeShader', 'ShaderFilter', 'StringTools', 'setVar', and 'getVar'

runHaxeCode(codeToRun:String)

runs string as a hscript

getColorFromHex(color:String)

Get the color decimal ID from an Hexadecimal value (color).

Example: To get orange, you should use getColorFromHex('FF7800') or getColorFromHex('0xFFFF7800')

getSongPosition()

Returns the current song position. Shortcut to getPropertyClass('Conductor', 'songPosition')

Randomizers

getRandomInt(min:Int, max:Int)

It randomizes

  • min - start
  • max - end

getRandomFloat(min:Int, max:Int)

It randomizes but in decimal

getRandomBool(chance:Float = 50)

It randomizes the chance being true

Clone this wiki locally