Window - AlsoGhostglowDev/Ghost-s-Utilities GitHub Wiki

window.lua

Tools used for the game's application/window manipulation. Use with caution.

local window = require 'ghostutil.window'

Fields

defaultDimensions = {
    width: int = 1280,
    height: int = 720
}
Contains the default game's window dimensions.
desktopDimensions = {
    -- not a constant, therefore it's defaulted to 0. 
    width: int = 0,
    height: int = 0
}
Contains the current desktop's dimensions. The values are only usable after onCreate, else it will only return 0.

Methods

setProperty(property: string, value: dynamic, ?allowMaps: boolean, ?allowInstances: boolean): dynamic

Sets the window's property directly to value.
(uses helper.setProperty)

Parameters:

  • property: The property to set, available properties can be referred here: lime.ui.Window.
  • value: The value to set the property to.
  • allowMaps (optional): Allows for map access in properties, disabled by default for optimization.
  • allowInstances (optional): Allows usage of instanceArg for properties, disabled by default for optimization.

Returns: The passed value.

View Example

-- sets the window's X position to 100.
window.setProperty('x', 100)

─────────────────────────

getProperty(property: string, ?allowMaps: boolean): dynamic

Fetches the window's property directly.

Parameters:

  • property: The property to fetch, available properties can be referred here: lime.ui.Window.
  • allowMaps (optional): Allows for map access in properties, disabled by default for optimization.

Returns: The fetched value.

View Example

-- assuming you didn't change the window title,
-- this will return "Friday Night Funkin': Psych Engine"
window.getProperty('title')

─────────────────────────

setPosition(x: number, y: number): void

Sets the window's position.

Parameters:

  • x: The target X position.
  • y: The target Y position.
View Example

-- sets the window's position to (X: 240, Y: 320)
window.setPosition(240, 320)

─────────────────────────

screenCenter(?axes: string): void

Centers the current window at the given axis.

Parameters:

  • axes (optional): The axis the window should center at, defaults to 'xy'
    (can be x, y or xy)
View Example

-- centers the window on the X axis.
window.screenCenter('x')

─────────────────────────

resize(width: number, height: number): void

Resizes the window to the specified dimensions.

Parameters:

  • width: The new window width.
  • height: The new window height.
View Example

-- resizes the window to half it's size
window.resize(
    window.getProperty('width') / 2,
    window.getProperty('height') / 2
)

─────────────────────────

doTweenX(tag: string, value: number, ?duration: number, ?ease: string): void

Tweens the window's X position to the given value.

Parameters:

  • tag: The tween's tag.
  • value: The target X position.
  • duration (optional): Determines how long the tween will take, defaults to 1.
  • ease (optional): Determines the ease used on the tween. Refer to FlxEase. Defaults to 'linear'
View Example

-- tweens the window's X position to 100.
window.doTweenX('coolTween', 100, 2, 'expoInOut')

─────────────────────────

doTweenY(tag: string, value: number, ?duration: number, ?ease: string): void

Just like doTweenX, instead this tweens the window's Y position instead.

Parameters:

  • tag: The tween's tag.
  • value: The target Y position.
  • duration (optional): Determines how long the tween will take, defaults to 1.
  • ease (optional): Determines the ease used on the tween. Refer to FlxEase. Defaults to 'linear'
View Example

-- tweens the window's Y position to 300.
window.doTweenY('coolTween', 300, 2, 'expoInOut')

─────────────────────────

doTweenPosition(tag: string, x: number, y: number, ?duration: number, ?ease: string): void

Tweens the window's position to the specified values.

Parameters:

  • tag: The tween's tag.
  • x: The target X position.
  • y: The target Y position.
  • duration (optional): Determines how long the tween will take, defaults to 1.
  • ease (optional): Determines the ease used on the tween. Refer to FlxEase. Defaults to 'linear'

─────────────────────────

doTweenSize(tag: string, width: number, height: number, ?duration: number, ?ease: string): void

Tweens the window's size to the specified values.

Parameters:

  • tag: The tween's tag.
  • width: The target window width.
  • height: The target window height.
  • duration (optional): Determines how long the tween will take, defaults to 1.
  • ease (optional): Determines the ease used on the tween. Refer to FlxEase. Defaults to 'linear'
View Example

-- tweens the window's width and height to your desktop's dimensions.
window.doTweenSize('coolResize', window.desktopDimensions.width, window.desktopDimensions.height, 2, 'expoInOut')

─────────────────────────

tweenToCenter(tag: string, ?axes: string, ?duration: number, ?options: TweenOptions): void

Tweens the window to the center of the given axis.
(uses bcompat.startTween)

Parameters:

  • tag: The tween's tag.
  • axes (optional): The axis the window should center at, defaults to 'xy'
    (can be x, y or xy)
  • duration (optional): Determines how long the tween will take, defaults to 1.
  • options (optional): The tween's options; Refer to TweenOptions.
View Example

-- tweens the window to the center.
window.tweenToCenter('tweener', 'xy', 2, {
    ease = 'quadIn'
})

─────────────────────────

startTween(tag: string, values: directory<string, dynamic>, ?duration: number, ?options: TweenOptions): void

Creates a tween of the window supporting multiple values for each respective fields.
(uses bcompat.startTween)

Parameters:

  • tag: The tween's tag.
  • object: The target object to tween.
  • values: Directory containing values mapped to their corresponding field.
  • duration (optional): Determines how long the tween will take, defaults to 1.
  • options (optional): The tween's options; Refer to TweenOptions.

This tween is still cancelable through Psych's cancelTween.

View Example

-- tweens the window's width and x to 200 and 100 respectively.
window.startTween('tweener', {x = 100, width = 200}, 2, {
    ease = 'quadInOut'
})

─────────────────────────

setIcon(image: string): void

Sets the window's icon to the specified image.

Parameters:

  • image: The image path. (checks in images)
View Example

-- assuming you have icon.png in mods/images/..
window.setIcon('icon')

─────────────────────────

alert(title: string, message: string): void

Sends an alert to the user.
For a more advanced use, check out cpp.makeMessageBox.

Parameters:

  • title: The alert's window title.
  • message: The alert's message.
View Example

window.alert('Cool dude spotted', 'YOOO THIS GUY USES GHOSTUTIL!!')

─────────────────────────

setTitle(?title: string): void

Sets the current window's title.

Parameters:

  • title (optional): The new window title, defaults to "Friday Night Funkin': Psych Engine".

─────────────────────────

createWindow(tag: string, ?attributes: WindowAttributes): void

Creates a new window for the current application.
(This window does not automatically close. Use window.closeWindow to close it.)

Warning

This function is exclusively for Psych Engine versions below 0.7.0.

Parameters:

  • tag: The tag to store to later use with other functions like setProperty, etc.
  • attributes: The window's attributes; Refer to WindowAttributes.
View Example

-- WARNING: this only works in Psych Engine versions below 0.7.0
window.createWindow('coolWindow', {
    x = 100,
    y = 200,
    title = 'Cool Window'
})

-- you can change it's properties with setProperty..
setProperty('coolWindow.title', 'VERY Cool Window')

-- close it once you're done using it!
function onDestroy()
    window.closeWindow('coolWindow')
end

─────────────────────────

closeWindow(tag: string): void

Closes the custom window that corresponds to the given tag that was created with createWindow.

Parameters:

  • tag: The custom window tag.

─────────────────────────

close(): void

Exits the current window.
(Shortcut for os.exit.)



GhostUtil 3.0.0Docs 3.0.0, Revision 2

a Lua Library made by GhostglowDev; for Psych Engine
© 2025 GhostglowDevGhost's Utilities
Licensed under the MIT License.

⚠️ **GitHub.com Fallback** ⚠️