sm.gui

The gui library contains various utility functions for handling user interfaces.

This library can only be used on the client.

Constants:

Functions:

  • bindDisplayMessageCallback
  • blockInGameMenu
  • chatMessage
  • computeTextSize
  • createAmmunitionContainerGui
  • createBagIconGui
  • createBatteryContainerGui
  • createBeaconIconGui
  • createChallengeHUDGui
  • createChallengeMessageGui
  • createCharacterCustomizationGui
  • createChemicalContainerGui
  • createCompassHudGui
  • createContainerGui
  • createCraftBotGui
  • createDressBotGui
  • createEngineGui
  • createFertilizerContainerGui
  • createGasContainerGui
  • createGlowstickContainerGui
  • createGuiFromLayout
  • createHideoutGui
  • createLogbookGui
  • createMechanicStationGui
  • createMininghubDispenserGui
  • createNameTagGui
  • createOreCrusherContainerGui
  • createPortableCrafterGui
  • createProspectorContainerGui
  • createQuestTrackerGui
  • createRefineryContainerGui
  • createSawbotGui
  • createSeatGui
  • createSeatUpgradeGui
  • createSeedContainerGui
  • createSteeringBearingGui
  • createSurvivalHudGui
  • createWaterContainerGui
  • createWaypointIconGui
  • createWidget
  • createWorkbenchGui
  • createWorldIconGui
  • displayAlertText
  • endFadeToBlack
  • exitToMenu
  • getCurrentLanguage
  • getItemIconFromUuid
  • getKeyBinding
  • getScreenSize
  • hasActiveGui
  • hideGui
  • hideHotbar
  • openGarageImportGui
  • setCenterIcon
  • setCharacterDebugText
  • setGarageButtonCallback
  • setGarageErrorCallback
  • setGarageImportGuiStorage
  • setInteractionText
  • setProgressFraction
  • startFadeToBlack
  • startFadeToBlackWaitForWorld
  • ticksToTimeString
  • translateLocalizationTags

  • sm.gui.widgetStates table

    Widget states

    disabled,
    normal,
    highlighted,
    pushed,
    disabled_checked,
    normal_checked,
    highlighted_checked,
    pushed_checked

    sm.gui.bindDisplayMessageCallback(callback)

    Client only

    Sets a target callback for generic notification popups

    Parameters:

    TypeNameDescription
    stringcallbackFunction to be called when a alert message is called

    sm.gui.blockInGameMenu(block)

    Client only

    Sets the blocking state for the in game menu.

    Parameters:

    TypeNameDescription
    booleanblockThe new blocking state for the in game menu.

    sm.gui.chatMessage(message)

    Prints text in the chat gui.

    Note:

    Will not be sent to other players.

    Parameters:

    TypeNameDescription
    stringmessageThe message.

    sm.gui.computeTextSize(text, font, align, maxWidth?, replaceTags?)

    Client only

    Calculates the 720 widget size required to display a text

    Parameters:

    TypeNameDescription
    stringtextThe text to compute.
    stringfontThe font to use.
    stringalignThe text alignment.
    numbermaxWidth?The maximum desired widget width before wrapping (optional) (Defaults to -1)
    booleanreplaceTags?Should tags be replaced before calculating? (optional) (Defaults to true)

    Returns:

    TypeDescription
    {number, number}The calculated width and height.

    sm.gui.createAmmunitionContainerGui(destroyOnClose?)

    Client only

    Create a ammunition container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createBagIconGui(destroyOnClose?)

    Deprecated:

    use createWorldIconGui

    Client only

    Create a bag icon GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createBatteryContainerGui(destroyOnClose?)

    Client only

    Create a battery container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createBeaconIconGui(destroyOnClose?)

    Deprecated:

    use createWorldIconGui

    Client only

    Create a beacon icon GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createChallengeHUDGui(destroyOnClose?)

    Client only

    Create a challenge HUD GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createChallengeMessageGui(destroyOnClose?)

    Client only

    Create a challenge message HUD GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createCharacterCustomizationGui(destroyOnClose?)

    Client only

    Create a character customization GUI.

    Note:

    Character customization gui has two magic callbacks

    Mouse drag cl_onDragZoneUsed ( number, number )

    Mouse scroll cl_onDragZoneUsed ( number )

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createChemicalContainerGui(destroyOnClose?)

    Client only

    Create a chemical container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createCompassHudGui(destroyOnClose?)

    Client only

    Create a compass hud GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createContainerGui(destroyOnClose?)

    Client only

    Create a container GUI, for showing two containers.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createCraftBotGui(destroyOnClose?)

    Client only

    Create a craft bot GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createDressBotGui(destroyOnClose?)

    Client only

    Create a dress bot GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createEngineGui(destroyOnClose?)

    Client only

    Create a engine GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createFertilizerContainerGui(destroyOnClose?)

    Client only

    Create a fertilizer container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createGasContainerGui(destroyOnClose?)

    Client only

    Create a gas container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createGlowstickContainerGui(destroyOnClose?)

    Client only

    Create a glowstick container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createGuiFromLayout(layout, destroyOnClose?, settings?)

    Client only

    Create a GUI from a layout file.

    Parameters:

    TypeNameDescription
    stringlayoutPath to the layout file
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)
    tablesettings?Table with bool settings for: isHud, isInteractive, needsCursor

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createHideoutGui(destroyOnClose?)

    Client only

    Create a hideout gui GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createLogbookGui(destroyOnClose?)

    Client only

    Create a log book GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createMechanicStationGui(destroyOnClose?)

    Client only

    Create a mechanic station dispenser GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createMininghubDispenserGui(destroyOnClose?)

    Client only

    Create a mining hub dispenser GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createNameTagGui(destroyOnClose?)

    Client only

    Create a name tag GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createOreCrusherContainerGui(destroyOnClose=false)

    Client only

    Create a ore crusher container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose=falseIf true the gui is destroyed when closed, otherwise the gui can be reused.

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createPortableCrafterGui(destroyOnClose?)

    Client only

    Create a portable craftbot GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createProspectorContainerGui(destroyOnClose?)

    Client only

    Create a prospector container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createQuestTrackerGui(destroyOnClose?)

    Client only

    Create a quest tracker GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createRefineryContainerGui(destroyOnClose=false)

    Client only

    Create a refinery container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose=falseIf true the gui is destroyed when closed, otherwise the gui can be reused.

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createSawbotGui(destroyOnClose?)

    Client only

    Create a saw bot GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createSeatGui(destroyOnClose?)

    Client only

    Create a seat GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createSeatUpgradeGui(destroyOnClose?)

    Client only

    Create a seat upgrade GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createSeedContainerGui(destroyOnClose?)

    Client only

    Create a seed container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createSteeringBearingGui(destroyOnClose?)

    Client only

    Create a steering bearing upgrade GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createSurvivalHudGui(destroyOnClose?)

    Client only

    Create a survival hud GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createWaterContainerGui(destroyOnClose?)

    Client only

    Create a water container GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createWaypointIconGui(destroyOnClose?)

    Deprecated:

    use createWorldIconGui

    Client only

    Create a waypoint icon GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createWidget()

    Deprecated:

    Use sm.gui.createGuiFromLayout

    Removed! Does nothing.


    sm.gui.createWorkbenchGui(destroyOnClose?)

    Client only

    Create a workbench GUI.

    Parameters:

    TypeNameDescription
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createWorldIconGui(width, height, layout?, destroyOnClose?)

    Client only

    Create a world icon GUI from a layout file.

    Parameters:

    TypeNameDescription
    integerwidthThe width.
    integerheightThe height.
    stringlayout?Path to the layout file (Defaults to "$GAME_DATA/Gui/Layouts/Hud/Hud_WorldIcon.layout")
    booleandestroyOnClose?If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.displayAlertText(text, duration?, queued?)

    Client only

    Displays an alert message at the top of the screen for a set duration.

    Parameters:

    TypeNameDescription
    stringtextThe message to be displayed
    numberduration?The time in seconds during which the message is shown. Defaults to 4 seconds
    booleanqueued?If true the message is queued, otherwise it is displayed instantly. Defaults to false

    sm.gui.endFadeToBlack(duration, force?)

    Client only

    Fades the screen back from a fade to black.

    Parameters:

    TypeNameDescription
    numberdurationAnimation duration
    booleanforce?If true, start the fade out from full black even if there was no fade to black active. (Defaults to false)

    sm.gui.exitToMenu()

    Client only

    Exits the current game and returns to the main menu

    Note:

    Can only be used in the Challenge Mode


    sm.gui.getCurrentLanguage()

    Client only

    Returns the current users language setting.

    Returns:

    TypeDescription
    stringThe language setting ex. "English".

    sm.gui.getItemIconFromUuid(uuid)

    Gets the item resource, group and name for an item icon from a uuid

    Parameters:

    TypeNameDescription
    UuiduuidThe uuid.

    Returns:

    TypeDescription
    {string, string, string, string, string} The item resource, group, name, trackingType and shapeType.

    sm.gui.getKeyBinding(action, hyper?)

    Client only

    Returns the set binding for an action as a string

    Parameters:

    TypeNameDescription
    stringactionThe action
    booleanhyper?If the string should contain hyper text (Defaults to false)

    Returns:

    TypeDescription
    stringThe key binding

    sm.gui.getScreenSize()

    Client only

    Returns the size of the screen.

    Returns:

    TypeDescription
    integer,integerThe screen size as width and height.

    sm.gui.hasActiveGui()

    Client only

    Returns whether the player has an active gui or not

    Returns:

    TypeDescription
    booleanguiActive Whether the player has an active gui or not.

    sm.gui.hideGui(visible)

    Client only

    Set gui visibility.

    Parameters:

    TypeNameDescription
    booleanvisibleThe gui visibility

    sm.gui.hideHotbar(visible)

    Client only

    Set hotbar visibility.

    Parameters:

    TypeNameDescription
    booleanvisibleThe hotbar visibility

    sm.gui.openGarageImportGui()

    Client only

    Open the garage creation import GUI


    sm.gui.setCenterIcon()

    Deprecated:

    Use sm.gui.setInteractionText

    Removed! Does nothing.


    sm.gui.setCharacterDebugText(character, text, clear?)

    Set a text for the character that will be displayed above its head. Only has effect in dev build.

    Parameters:

    TypeNameDescription
    CharactercharacterThe character.
    stringtextThe debug text.
    booleanclear?If true the previous text will be overwritten. (Defaults to true)

    sm.gui.setGarageButtonCallback(callback)

    Client only

    Sets a button callback to be called when the button is pressed.

    Parameters:

    TypeNameDescription
    stringcallbackFunction to be called when button is pressed

    sm.gui.setGarageErrorCallback(callback)

    Client only

    Sets a callback to be called when an error with the import is met.

    Parameters:

    TypeNameDescription
    stringcallbackFunction to be called when error is met

    sm.gui.setGarageImportGuiStorage(container)

    Set the storage container for the garage creation import gui to use

    Parameters:

    TypeNameDescription
    ContainercontainerThe container import gui should use for materials.

    sm.gui.setInteractionText(text1, binding1?, text2?, binding2?, text3?)

    Client only

    Set the binding text displayed at the center.

    Parameters:

    TypeNameDescription
    stringtext1The leftmost segment.
    stringbinding1?The left white segment.
    stringtext2?The mid or end segment.
    stringbinding2?The right white segment.
    stringtext3?The rightmost segment.

    sm.gui.setProgressFraction(progress)

    Client only

    Set the progress fraction filling the circle icon displayed at the center.

    Parameters:

    TypeNameDescription
    numberprogressThe fraction that determines how much of the circle is filled.

    sm.gui.startFadeToBlack(duration, timeout)

    Client only

    Fades the screen to black and back after timeout.

    Parameters:

    TypeNameDescription
    numberdurationAnimation duration
    numbertimeoutSeconds until the fade fades back

    sm.gui.startFadeToBlackWaitForWorld(duration, timeout)

    Client only

    Fades the screen to black, waits for the world to finish loading, then fades back.

    First waits until timeout, then holds black until the world is ready or a max timeout is reached.

    Parameters:

    TypeNameDescription
    numberdurationAnimation duration
    numbertimeoutSeconds until the fade starts waiting for the world

    sm.gui.ticksToTimeString(ticks)

    Client only

    Converts ticks to a HH:MM:SS string representation.

    Parameters:

    TypeNameDescription
    integerticksGame ticks

    Returns:

    TypeDescription
    stringtime Human time formatted string

    sm.gui.translateLocalizationTags(text)

    Client only

    Translates all localization tags in a text using the current language.

    Parameters:

    TypeNameDescription
    stringtextThe text containing localization tags

    Returns:

    TypeDescription
    stringThe text with translated tags