Undertale background

The UI Object [E/M/W]



This section details the various elements you can use to manipulate CYF's internal user interface.

If you want to manipulate UI elements related to the enemy (attack animation, health bar, position of the damage text), I suggest visiting the Misc. Functions section of the documentation.


sprite UI.background Sprite object allowing you to manipulate the background image set using the background variable.


textObject UI.namelv Text object displaying the Player's name as well as its level. Its contents is usually the Player's name followed by two spaces, the text LV, another space, then finally the Player's level.


sprite UI.hplabel Sprite for the HP text next to the Player's life bar.


bar UI.hpbar Bar object used as the Player's life bar.


textObject UI.hptext Text object displaying the Player's HP. Its contents display the Player's current HP, a space, a slash, another space, and finally the Player's max HP.


sprite UI.fightbtn Sprite for the FIGHT button. Do not use its Remove function, or it may cause unexpected errors. If you want to remove it, set its alpha to 0 instead.


sprite UI.actbtn Sprite for the ACT button. Do not use its Remove function, or it may cause unexpected errors. If you want to remove it, set its alpha to 0 instead.


sprite UI.itembtn Sprite for the ITEM button. Do not use its Remove function, or it may cause unexpected errors. If you want to remove it, set its alpha to 0 instead.


sprite UI.mercybtn Sprite for the MERCY button. Do not remove it in any way, or it may cause unexpected errors. If you want to remove it, set its alpha to 0 instead.


UI.StopUpdate( toggle) If toggle is true, the Player's UI (except the buttons) will not be updated by the engine, whether it is the Player's name and level text or the Player's hp bar and text.

False by default.


UI.Hide( hide) If hide is true, all of the Player's UI (including the buttons) will be hidden.

False by default.


UI.RepositionHPElements() Updates the Player's life's bar's position, and the player's hp text's position depending on the sizes of the hp bar and the hp label.


UI.Reset() Tries to reset all modifications to the Player's UI, making it look like it originally is at the beginning of the battle by resetting most of the UI elements' parameters.


UI.GetCurrentButton() returns Returns the name of the currently selected button. Its return value can either be FIGHT, ACT, ITEM or MERCY.


UI.DisableButton( button) Disables the given button, preventing its selection in the state ACTIONSELECT.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.EnableButton( button) Reenables the given button if it was previously disabled using UI.DisableButton.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.ResetButtonPosition( button, resetX = true, resetY = true) Resets the position of the given button. Setting resetX to true resets the button's horizontal position, while setting resetY to true resets the button's vertical position.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.GetPlayerXPosOnButton( button) Returns the player's horizontal position offset when selecting the given button, starting from the button's bottom left corner. The default value for all buttons is 16.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.GetPlayerYPosOnButton( button) Returns the player's vertical position offset when selecting the given button, starting from the button's bottom left corner. The default value for all buttons is 19.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.SetPlayerXPosOnButton( button, newX) Sets the player's horizontal position offset when selecting the given button, starting from the button's bottom left corner.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.SetPlayerYPosOnButton( button, newY) Sets the player's vertical position offset when selecting the given button, starting from the button's bottom left corner.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.ResetPlayerPosOnButton( button, resetX = true, resetY = true) Resets the player's position offset when selecting the given button, starting from the button's bottom left corner. Setting resetX to true resets the player's horizontal position offset, while setting resetY to true resets the player's vertical position offset.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.SetButtonActiveSprite( button, sprite) Sets the sprite of the given button whenever it is selected.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.ResetButtonActiveSprite( button) Resets the sprite of the given button whenever it is selected to the one that was used by the engine at the beginning of the encounter.

Accepted values for the button argument are FIGHT, ACT, ITEM or MERCY.


UI.UpdateButtons() Sets the active button's active sprite and moves the Player where it needs to be on its currently selected button. This function is automatically called after most functions related to button manipulation.


The Bar Object [E/M/W]



This separate section lists the various functions and variables are usable when dealing with a bar object, which can be used for life bars, for example.

These objects are used in CYF as life bars, whether it's the Player's, the life bars appearing next to the enemy's names after selecting the FIGHT button and the life bar appearing after attacking an enemy.

Bar objects are composed of three sprites (four of them if it has an outline) which are all children of one another: fill is the child of mask which is itself the child of background. If the bar's outline exists, then background will be its child.


CreateBar( x, y, width, height = 20) returns bar [E/M/W] Creates a bar object which bottom left corner is at the absolute position x and y, with a size of width pixels horizontally and height pixels vertically.


CreateBarWithSprites( x, y, backgroundSprite, fillSprite = backgroundSprite) returns bar [E/M/W] Creates a bar object which bottom left corner is at the absolute position x and y, and which uses the sprites backgroundSprite and fillSprite to create the life bar.

Both sprites must have the same size, and if no value is given for fillSprite, then it uses the same sprite as backgroundSprite.


sprite Bar.background Background sprite of the bar object, which is also the parent of all other standard bar elements.


sprite Bar.mask Mask sprite of the bar object, used to hide part of the fill sprite. A mask is used in order to cut the fill sprite if it's a sprite other than a single pixel scaled up, allowing for the bar's fill to be cut instead of squished.


sprite Bar.fill Fill sprite of the bar object, which is used to represent the amount of the bar which is still full.


sprite Bar.outline Outline sprite of the bar object, which adds a black outline to the bar object. It needs to be created first using the function AddOutline().

If it exists, it will be the parent of the background sprite.


Bar.currentFill (readonly) Value usually between 0 and 1 that gives the percentage of the bar which is currently full. 0 means the bar is empty, while 1 means it is full.

Can be outside of these bounds if SetInstant() or SetLerp() are used without clamping.


Bar.hasOutline (readonly) Returns true if the bar object has an outline sprite, false otherwise.


Bar.outlineThickness Returns the thickness in pixels of the outline sprite. Returns 0 if the outline doesn't exist.

Can be set to resize the outline's thickness.


Bar.SetInstant( fillValue, allowNonClamped = false) Sets the fill percentage of the bar object between 0 and 1. 0 means the bar is empty, while 1 means it is full.

If allowNonClamped is set to true, you can use values lower than 0 and higher than 1.

Note that the bar will be updated properly when fillValue is beyond its usual bounds only if the bar-px sprite is used for all of the bar's sprites.


Bar.SetLerp( fillValue, time = 60, allowNonClamped = false) Gradually sets the fill percentage of the bar object between 0 and 1 to fillValue over time frames, with 60 frames being equal to one second. 0 means the bar is empty, while 1 means it is full.

If allowNonClamped is set to true, you can use values lower than 0 and higher than 1.

Note that the bar will be updated properly when fillValue is beyond its usual bounds only if the bar-px sprite is used for all of the bar's sprites.


Bar.SetLerp( originalValue, fillValue, time = 60, allowNonClamped = false) Acts like the function above, except you can set the initial fill percentage of the bar object using originalValue.


Bar.AddOutline( thickness, r = 0, g = 0, b = 0) Creates a rectangle outline sprite which has a thickness of thickness pixels on all sides. This new sprite will be the parent of the background sprite, which means it needs to be moved if you want to move the entire bar object if it exists.

The standard color of the outline is black, but you can change the color of the outline sprite by setting the values r, g and b between 0 and 1.


Bar.RemoveOutline() Removes the outline sprite if it exists without removing the bar object.


Bar.Resize( width, height, updateOutline = true) Sets the scale of the various elements of the bar object. If the outline sprite shouldnt be updated, set updateOutline to false.

If used on a bar object using the bar-px sprite for both its background and its fill sprite, then the bar object will be width pixels wide and height pixels tall.


Bar.SetSprites( bgSprite, fSprite = bgSprite, mSprite = nil, oSprite = nil) Sets the sprites of the various elements of the bar object. bgSprite will replace the image of the background sprite, fSprite will replace the image of the fill sprite, mSprite will replace the image of the mask sprite and oSprite will replace the image of the outline sprite, if it exists.

The size of the background and fill sprites must always be the same, hence why if fSprite is not given, it will use the same spite as bgSprite.


Bar.SetVisible( visible) Hides the bar object completely if visible is set to false, shows it otherwise.


Bar.Destroy() Destroys this bar object, removing all of its sprites. The Player's lifebar cannot be destroyed.

* YOU WON!
* You earned 0 EXP and 0 gold.
* also the nav menu is broken now


Undertale fake button
Undertale fake button
Undertale fake button
Undertale fake button