sm.gui

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

This library can only be used on the client.

Functions:

  • chatMessage
  • createAmmunitionContainerGui
  • createBagIconGui
  • createBatteryContainerGui
  • createBeaconIconGui
  • createChallengeHUDGui
  • createChallengeMessageGui
  • createCharacterCustomizationGui
  • createChemicalContainerGui
  • createContainerGui
  • createCraftBotGui
  • createDressBotGui
  • createEngineGui
  • createFertilizerContainerGui
  • createGasContainerGui
  • createGuiFromLayout
  • createHideoutGui
  • createLogbookGui
  • createMechanicStationGui
  • createNameTagGui
  • createQuestTrackerGui
  • createSeatGui
  • createSeatUpgradeGui
  • createSeedContainerGui
  • createSteeringBearingGui
  • createSurvivalHudGui
  • createWaterContainerGui
  • createWaypointIconGui
  • createWidget
  • createWorkbenchGui
  • createWorldIconGui
  • displayAlertText
  • endFadeToBlack
  • exitToMenu
  • getCurrentLanguage
  • getKeyBinding
  • getScreenSize
  • hideGui
  • setCenterIcon
  • setCharacterDebugText
  • setInteractionText
  • setProgressFraction
  • startFadeToBlack
  • ticksToTimeString
  • translateLocalizationTags

  • sm.gui.chatMessage(message)

    Prints text in the chat gui.

    Note:

    Will not be sent to other players.

    Parameters:

    TypeNameDescription
    stringmessageThe message.

    sm.gui.createAmmunitionContainerGui(destroyOnClose=false)

    Client only

    Create a ammunition 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.createBagIconGui(destroyOnClose=false)

    Deprecated:

    use createWorldIconGui

    Client only

    Create a bag icon 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.createBatteryContainerGui(destroyOnClose=false)

    Client only

    Create a battery 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.createBeaconIconGui(destroyOnClose=false)

    Deprecated:

    use createWorldIconGui

    Client only

    Create a beacon icon 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.createChallengeHUDGui(destroyOnClose=false)

    Client only

    Create a challenge HUD 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.createChallengeMessageGui(destroyOnClose=false)

    Client only

    Create a challenge message HUD 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.createCharacterCustomizationGui(destroyOnClose=false)

    Client only

    Create a character customization 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.createChemicalContainerGui(destroyOnClose=false)

    Client only

    Create a chemical 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.createContainerGui(destroyOnClose=false)

    Client only

    Create a container GUI, for showing two containers.

    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.createCraftBotGui(destroyOnClose=false)

    Client only

    Create a craft bot 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.createDressBotGui(destroyOnClose=false)

    Client only

    Create a dress bot 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.createEngineGui(destroyOnClose=false)

    Client only

    Create a engine 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.createFertilizerContainerGui(destroyOnClose=false)

    Client only

    Create a fertilizer 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.createGasContainerGui(destroyOnClose=false)

    Client only

    Create a gas 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.createGuiFromLayout(layout, destroyOnClose=false, settings=nil)

    Client only

    Create a GUI from a layout file.

    Parameters:

    TypeNameDescription
    stringlayoutPath to the layout file
    booleandestroyOnClose=falseIf true the gui is destroyed when closed, otherwise the gui can be reused.
    tablesettings=nilTable with bool settings for: isHud, isInteractive, needsCursor

    Returns:

    TypeDescription
    GuiInterfaceThe gui interface to the created gui.

    sm.gui.createHideoutGui(destroyOnClose=false)

    Client only

    Create a hideout gui 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.createLogbookGui(destroyOnClose=false)

    Client only

    Create a log book 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.createMechanicStationGui(destroyOnClose=false)

    Client only

    Create a mechanical station 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.createNameTagGui(destroyOnClose=false)

    Client only

    Create a name tag 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.createQuestTrackerGui(destroyOnClose=false)

    Client only

    Create a quest tracker 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.createSeatGui(destroyOnClose=false)

    Client only

    Create a seat 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.createSeatUpgradeGui(destroyOnClose=false)

    Client only

    Create a seat upgrade 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.createSeedContainerGui(destroyOnClose=false)

    Client only

    Create a seed 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.createSteeringBearingGui(destroyOnClose=false)

    Client only

    Create a steering bearing upgrade 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.createSurvivalHudGui(destroyOnClose=false)

    Client only

    Create a survival hud 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.createWaterContainerGui(destroyOnClose=false)

    Client only

    Create a water 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.createWaypointIconGui(destroyOnClose=false)

    Deprecated:

    use createWorldIconGui

    Client only

    Create a waypoint icon 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.createWidget()

    Deprecated:

    Use sm.gui.createGuiFromLayout

    Removed! Does nothing.


    sm.gui.createWorkbenchGui(destroyOnClose=false)

    Client only

    Create a workbench 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.createWorldIconGui(width, height, layout=nil, destroyOnClose=nil)

    Client only

    Create a world icon GUI from a layout file.

    Parameters:

    TypeNameDescription
    integerwidthThe width.
    integerheightThe height.
    stringlayout=nilPath to the layout file (Defaults to "$GAME_DATA/Gui/Layouts/Hud/Hud_WorldIcon.layout")
    booleandestroyOnClose=nilIf 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=4)

    Client only

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

    Parameters:

    TypeNameDescription
    stringtextThe message to be displayed
    numberduration=4The time in seconds during which the message is shown. Defaults to 4 seconds

    sm.gui.endFadeToBlack(duration)

    Client only

    Fades the screen back from a fade to black.

    Parameters:

    TypeNameDescription
    numberdurationAnimation duration

    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.getKeyBinding(action, hyper=false)

    Client only

    Returns the set binding for an action as a string

    Parameters:

    TypeNameDescription
    stringactionThe action
    booleanhyper=falseIf the string should contain hyper text

    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.hideGui(visible)

    Client only

    Set gui visibility.

    Parameters:

    TypeNameDescription
    booleanvisibleThe gui visibility

    sm.gui.setCenterIcon(iconName)

    Client only

    Set the icon displayed at the center.

    Parameters:

    TypeNameDescription
    stringiconNameThe icon.

    sm.gui.setCharacterDebugText(character, text, clear=true)

    Client only

    Set a text for the character that will be displayed above its head.

    Parameters:

    TypeNameDescription
    CharactercharacterThe character.
    stringtextThe debug text.
    booleanclear=trueIf true the previous text will be overwritten.

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

    Client only

    Set the binding text displayed at the center.

    Parameters:

    TypeNameDescription
    stringtext1The leftmost segment.
    stringbinding1=nilThe left white segment.
    stringtext2=nilThe mid or end segment.
    stringbinding2=nilThe right white segment.
    stringtext3=nilThe 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.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