sm.gui

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

This library can only be used on the client.

Constants

Name Type Description
widgetStates table The widget states list.

widgetStates

Value type: table

Widget states

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

Server + Client

chatMessage

sm.gui.chatMessage( message )

Prints text in the chat gui.

Note: Will not be sent to other players.

Parameters:

Name Type Description
message string The message.

createWidget

sm.gui.createWidget(  )

Deprecated: Use sm.gui.createGuiFromLayout

Removed! Does nothing.

getItemIconFromUuid

sm.gui.getItemIconFromUuid( uuid )

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

Parameters:

Name Type Description
uuid Uuid The uuid.

Returns:

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

setCenterIcon

sm.gui.setCenterIcon(  )

Deprecated: Use sm.gui.setInteractionText

Removed! Does nothing.

setCharacterDebugText

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:

Name Type Description
character Character The character.
text string The debug text.
clear (optional) boolean If true the previous text will be overwritten. (Defaults to true)

setGarageImportGuiStorage

sm.gui.setGarageImportGuiStorage( container )

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

Parameters:

Name Type Description
container Container The container import gui should use for materials.

Client-only

bindDisplayMessageCallback

sm.gui.bindDisplayMessageCallback( callback )

Sets a target callback for generic notification popups

Parameters:

Name Type Description
callback string Function to be called when a alert message is called

blockInGameMenu

sm.gui.blockInGameMenu( block )

Sets the blocking state for the in game menu.

Parameters:

Name Type Description
block boolean The new blocking state for the in game menu.

computeTextSize

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

Calculates the 720 widget size required to display a text

Parameters:

Name Type Description
text string The text to compute.
font string The font to use.
align string The text alignment.
maxWidth (optional) number The maximum desired widget width before wrapping (optional) (Defaults to -1)
replaceTags (optional) boolean Should tags be replaced before calculating? (optional) (Defaults to true)

Returns:

Type Description
{number, number} The calculated width and height.

createAmmunitionContainerGui

sm.gui.createAmmunitionContainerGui( destroyOnClose )

Create a ammunition container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createBagIconGui

sm.gui.createBagIconGui( destroyOnClose )

Deprecated: use createWorldIconGui

Create a bag icon GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createBatteryContainerGui

sm.gui.createBatteryContainerGui( destroyOnClose )

Create a battery container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createBeaconIconGui

sm.gui.createBeaconIconGui( destroyOnClose )

Deprecated: use createWorldIconGui

Create a beacon icon GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createChallengeHUDGui

sm.gui.createChallengeHUDGui( destroyOnClose )

Create a challenge HUD GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createChallengeMessageGui

sm.gui.createChallengeMessageGui( destroyOnClose )

Create a challenge message HUD GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createCharacterCustomizationGui

sm.gui.createCharacterCustomizationGui( destroyOnClose )

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:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createChemicalContainerGui

sm.gui.createChemicalContainerGui( destroyOnClose )

Create a chemical container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createCompassHudGui

sm.gui.createCompassHudGui( destroyOnClose )

Create a compass hud GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createContainerGui

sm.gui.createContainerGui( destroyOnClose )

Create a container GUI, for showing two containers.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createCraftBotGui

sm.gui.createCraftBotGui( destroyOnClose )

Create a craft bot GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createDressBotGui

sm.gui.createDressBotGui( destroyOnClose )

Create a dress bot GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createEngineGui

sm.gui.createEngineGui( destroyOnClose )

Create a engine GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createFertilizerContainerGui

sm.gui.createFertilizerContainerGui( destroyOnClose )

Create a fertilizer container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createGasContainerGui

sm.gui.createGasContainerGui( destroyOnClose )

Create a gas container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createGlowstickContainerGui

sm.gui.createGlowstickContainerGui( destroyOnClose )

Create a glowstick container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createGuiFromLayout

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

Create a GUI from a layout file.

Parameters:

Name Type Description
layout string Path to the layout file
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)
settings (optional) table Table with bool settings for: isHud, isInteractive, needsCursor

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createHideoutGui

sm.gui.createHideoutGui( destroyOnClose )

Create a hideout gui GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createLogbookGui

sm.gui.createLogbookGui( destroyOnClose )

Create a log book GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createMechanicStationGui

sm.gui.createMechanicStationGui( destroyOnClose )

Create a mechanic station dispenser GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createMininghubDispenserGui

sm.gui.createMininghubDispenserGui( destroyOnClose )

Create a mining hub dispenser GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createNameTagGui

sm.gui.createNameTagGui( destroyOnClose )

Create a name tag GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createOreCrusherContainerGui

sm.gui.createOreCrusherContainerGui( destroyOnClose=false )

Create a ore crusher container GUI.

Parameters:

Name Type Description
destroyOnClose=false boolean If true the gui is destroyed when closed, otherwise the gui can be reused.

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createPortableCrafterGui

sm.gui.createPortableCrafterGui( destroyOnClose )

Create a portable craftbot GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createProspectorContainerGui

sm.gui.createProspectorContainerGui( destroyOnClose )

Create a prospector container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createQuestTrackerGui

sm.gui.createQuestTrackerGui( destroyOnClose )

Create a quest tracker GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createRefineryContainerGui

sm.gui.createRefineryContainerGui( destroyOnClose=false )

Create a refinery container GUI.

Parameters:

Name Type Description
destroyOnClose=false boolean If true the gui is destroyed when closed, otherwise the gui can be reused.

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createSawbotGui

sm.gui.createSawbotGui( destroyOnClose )

Create a saw bot GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createSeatGui

sm.gui.createSeatGui( destroyOnClose )

Create a seat GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createSeatUpgradeGui

sm.gui.createSeatUpgradeGui( destroyOnClose )

Create a seat upgrade GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createSeedContainerGui

sm.gui.createSeedContainerGui( destroyOnClose )

Create a seed container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createSteeringBearingGui

sm.gui.createSteeringBearingGui( destroyOnClose )

Create a steering bearing upgrade GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createSurvivalHudGui

sm.gui.createSurvivalHudGui( destroyOnClose )

Create a survival hud GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createWaterContainerGui

sm.gui.createWaterContainerGui( destroyOnClose )

Create a water container GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createWaypointIconGui

sm.gui.createWaypointIconGui( destroyOnClose )

Deprecated: use createWorldIconGui

Create a waypoint icon GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createWorkbenchGui

sm.gui.createWorkbenchGui( destroyOnClose )

Create a workbench GUI.

Parameters:

Name Type Description
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

createWorldIconGui

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

Create a world icon GUI from a layout file.

Parameters:

Name Type Description
width integer The width.
height integer The height.
layout (optional) string Path to the layout file (Defaults to "$GAME_DATA/Gui/Layouts/Hud/Hud_WorldIcon.layout")
destroyOnClose (optional) boolean If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false)

Returns:

Type Description
GuiInterface The gui interface to the created gui.

displayAlertText

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

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

Parameters:

Name Type Description
text string The message to be displayed
duration (optional) number The time in seconds during which the message is shown. Defaults to 4 seconds
queued (optional) boolean If true the message is queued, otherwise it is displayed instantly. Defaults to false

endFadeToBlack

sm.gui.endFadeToBlack( duration, force )

Fades the screen back from a fade to black.

Parameters:

Name Type Description
duration number Animation duration
force (optional) boolean If true, start the fade out from full black even if there was no fade to black active. (Defaults to false)

exitToMenu

sm.gui.exitToMenu(  )

Exits the current game and returns to the main menu

Note: Can only be used in the Challenge Mode

getCurrentLanguage

sm.gui.getCurrentLanguage(  )

Returns the current users language setting.

Returns:

Type Description
string The language setting ex. "English".

getKeyBinding

sm.gui.getKeyBinding( action, hyper )

Returns the set binding for an action as a string

Parameters:

Name Type Description
action string The action
hyper (optional) boolean If the string should contain hyper text (Defaults to false)

Returns:

Type Description
string The key binding

getScreenSize

sm.gui.getScreenSize(  )

Returns the size of the screen.

Returns:

Type Description
integer
integer
The screen size as width and height.

hasActiveGui

sm.gui.hasActiveGui(  )

Returns whether the player has an active gui or not

Returns:

Name Type Description
guiActive boolean Whether the player has an active gui or not.

hideGui

sm.gui.hideGui( visible )

Set gui visibility.

Parameters:

Name Type Description
visible boolean The gui visibility

hideHotbar

sm.gui.hideHotbar( visible )

Set hotbar visibility.

Parameters:

Name Type Description
visible boolean The hotbar visibility

openGarageImportGui

sm.gui.openGarageImportGui(  )

Open the garage creation import GUI

setGarageButtonCallback

sm.gui.setGarageButtonCallback( callback )

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

Parameters:

Name Type Description
callback string Function to be called when button is pressed

setGarageErrorCallback

sm.gui.setGarageErrorCallback( callback )

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

Parameters:

Name Type Description
callback string Function to be called when error is met

setInteractionText

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

Set the binding text displayed at the center.

Parameters:

Name Type Description
text1 string The leftmost segment.
binding1 (optional) string The left white segment.
text2 (optional) string The mid or end segment.
binding2 (optional) string The right white segment.
text3 (optional) string The rightmost segment.

setProgressFraction

sm.gui.setProgressFraction( progress )

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

Parameters:

Name Type Description
progress number The fraction that determines how much of the circle is filled.

startFadeToBlack

sm.gui.startFadeToBlack( duration, timeout )

Fades the screen to black and back after timeout.

Parameters:

Name Type Description
duration number Animation duration
timeout number Seconds until the fade fades back

startFadeToBlackWaitForWorld

sm.gui.startFadeToBlackWaitForWorld( duration, timeout )

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:

Name Type Description
duration number Animation duration
timeout number Seconds until the fade starts waiting for the world

ticksToTimeString

sm.gui.ticksToTimeString( ticks )

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

Parameters:

Name Type Description
ticks integer Game ticks

Returns:

Name Type Description
time string Human time formatted string

translateLocalizationTags

sm.gui.translateLocalizationTags( text )

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

Parameters:

Name Type Description
text string The text containing localization tags

Returns:

Type Description
string The text with translated tags