### sm.challenge.start Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.challenge.html Starts the challenge. ```APIDOC ## sm.challenge.start() ### Description Starts challenge. ``` -------------------------------- ### start Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Effect.html Initiates playback of an effect, with an optional start time for audio or cinematic effects. ```lua effect:start( startTime ) ``` -------------------------------- ### Update Builder Guide Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BlueprintVisualization.html Refreshes the state of a builder guide visualization. Avoid calling this every frame or tick to maintain performance. ```lua blueprintVisualization:updateBuilderGuide( ) ``` -------------------------------- ### effect:start Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Effect.html Starts playing an effect. ```APIDOC ## effect:start( startTime ) ### Description Starts playing an effect. ### Parameters - **startTime** (number) - Optional. The start time of the effect. Only applies to audio and cinematic effects. (Defaults to 0) ``` -------------------------------- ### Get BuilderGuide Stage Index Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Retrieves the current stage index of the builder guide. ```lua builderGuide:getCurrentStageIndex( ) ``` -------------------------------- ### Get BuilderGuide ID Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Retrieves the unique identifier for the builder guide. ```lua builderGuide:getId( ) ``` -------------------------------- ### sm.challenge.hasStarted Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.challenge.html Checks if the current challenge has started. ```APIDOC ## sm.challenge.hasStarted() ### Description Check if a challenge has started. ### Returns - **boolean** - Return true if the challenge has started. ``` -------------------------------- ### Update BuilderGuide State Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Refreshes the guide state; call this whenever the root Shape of the guide changes. ```lua builderGuide:update( ) ``` -------------------------------- ### builderGuide:update Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Updates the state of the builder guide. This should be called whenever the root Shape of the builder guide changes. ```APIDOC ## builderGuide:update() ### Description Update the state of a guide. Should be called whenever the root Shape of the builder guide has changed. ### Parameters - **guide** (BuilderGuide) - Required - The guide. ``` -------------------------------- ### jsonGui:isHidden Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/JsonGui.html Gets the visibility of the gui. ```APIDOC ## jsonGui:isHidden() ### Description Gets the visibility of the gui. ### Parameters - **gui** (JsonGui) - The gui. ### Returns - **hidden** (boolean) - True if the gui is hidden. ``` -------------------------------- ### builderGuide:isComplete Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Checks if the builder guide has been completed. ```APIDOC ## builderGuide:isComplete() ### Description Returns the completion status of a guide. ### Parameters - **guide** (BuilderGuide) - Required - The guide. ### Returns - **boolean** - True if the guide is completed. ``` -------------------------------- ### sm.container.beginTransaction Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.container.html Starts a new transaction shared across all containers. ```APIDOC ## sm.container.beginTransaction() ### Description Starts a new transaction shared across all containers. A transaction is a collection of all changes of container items will be collected and processed. A transaction must be ended with sm.container.endTransaction. ### Returns - **boolean** - Whether starting a transaction was successful. ``` -------------------------------- ### Check BuilderGuide Completion Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Returns true if the builder guide has been completed. ```lua builderGuide:isComplete( ) ``` -------------------------------- ### sm.localPlayer.getRaycastStart Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.localPlayer.html Returns the start position of the local player's raycast. ```APIDOC ### sm.localPlayer.getRaycastStart() Returns the start position of the local player's raycast. The position depends on the camera's position, and whether it's in first- of third-person. #### Returns - **Vec3** - The start position of the raycast. ``` -------------------------------- ### Start AI state Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/AiState.html Initializes and begins the execution of the AI state. ```lua aiState:start( ) ``` -------------------------------- ### Create a BuilderGuide Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.builderGuide.html Initializes a new BuilderGuide by comparing a root shape to a blueprint file path. ```lua sm.builderGuide.createBuilderGuide( path, shape, ignoreBlockUuid, recordErrors, allowExtraBlocks ) ``` -------------------------------- ### Load Watched Tutorials Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.game.html Retrieves the user's watched tutorials as a table. ```lua sm.game.loadWatchedTutorials( ) ``` -------------------------------- ### sm.gui.createSeatUpgradeGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a seat upgrade GUI. ```APIDOC ## sm.gui.createSeatUpgradeGui(destroyOnClose) ### Description Creates a seat upgrade GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### Create a new GUI instance Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.jsonGui.html Initializes a new GUI with optional settings such as HUD status, interactivity, and cursor requirements. ```lua sm.jsonGui.createGui( settings ) ``` -------------------------------- ### Get tracked blueprint Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Garage.html Gets the tracked creation Name and JsonTable from the garage. ```lua garage:getTrackedBlueprint( ) ``` -------------------------------- ### setStartStopDistance Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Effect.html Configures distance-based start and stop thresholds for an effect. ```lua effect:setStartStopDistance( startDistance, stopDistance ) ``` -------------------------------- ### sm.jsonGui.createGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.jsonGui.html Creates a new GUI instance with specified settings. ```APIDOC ## sm.jsonGui.createGui ### Description Creates a new GUI instance based on the provided settings table. ### Parameters - **settings** (table) - Optional - Table containing boolean settings: isHud, isInteractive, needsCursor, hidesHotbar, isOverlapped, backgroundAlpha, handleKeySetup, name, layer. ### Returns - **gui** (JsonGui) - The created GUI object. ``` -------------------------------- ### sm.gui.openGarageImportGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Opens the garage creation import GUI. ```APIDOC ## sm.gui.openGarageImportGui() ### Description Open the garage creation import GUI. ``` -------------------------------- ### sm.gui.createSeatGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a seat GUI. ```APIDOC ## sm.gui.createSeatGui(destroyOnClose) ### Description Creates a seat GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### sm.render.getDefaultGI Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.render.html Gets a table of the default GI render settings. ```APIDOC ## sm.render.getDefaultGI() ### Description Gets a table of the default GI render settings. ### Returns - **table** - The default GI render settings. ``` -------------------------------- ### Get BuilderGuide Stage Information Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Returns a table detailing remaining requirements for the current stage. ```lua builderGuide:getStageInfo( ) ``` -------------------------------- ### sm.render.getDefaultFog Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.render.html Gets a table of the default fog render settings. ```APIDOC ## sm.render.getDefaultFog() ### Description Gets a table of the default fog render settings. ### Returns - **table** - The default fog render settings. ``` -------------------------------- ### builderGuide:destroy Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Destroys the specified builder guide instance. ```APIDOC ## builderGuide:destroy() ### Description Destroys a guide. ### Parameters - **guide** (BuilderGuide) - Required - The guide to be destroyed. ``` -------------------------------- ### sm.menuCreation.load Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.menuCreation.html Loads the user's menu creation blueprint and returns it as a table. ```APIDOC ## sm.menuCreation.load() ### Description Loads the user's menu creation blueprint and returns it as a table. ### Returns - **table** - Users menu creation blueprint table. ``` -------------------------------- ### Get mass Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Shape.html Returns the mass of the shape. ```lua shape:getMass( ) ``` -------------------------------- ### sm.gui.createWorkbenchGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a workbench GUI. ```APIDOC ### sm.gui.createWorkbenchGui(destroyOnClose) #### Description Creates a workbench GUI. #### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) #### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### sm.gui.createWaterContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a water container GUI. ```APIDOC ### sm.gui.createWaterContainerGui(destroyOnClose) #### Description Creates a water container GUI. #### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) #### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### getLockingInteractable Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Gets the Interactable the character is locked to. ```APIDOC ## character:getLockingInteractable() ### Description Get the Interactable that the Character is locked to. ### Returns - **Interactable** - The interactable. ``` -------------------------------- ### sm.gui.createBatteryContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Create a battery container GUI. ```APIDOC ## sm.gui.createBatteryContainerGui(destroyOnClose) ### Description Create a battery container GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused (Defaults to false). ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### getLockingHarvestable Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Gets the Harvestable the character is locked to. ```APIDOC ## character:getLockingHarvestable() ### Description Get the Harvestable that the Character is locked to. ### Returns - **Harvestable** - The harvestable. ``` -------------------------------- ### Create portal Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.portal.html Initializes a new portal with the specified dimensions. ```lua sm.portal.createPortal( dimensions ) ``` -------------------------------- ### getContents Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/AreaTrigger.html Gets the contents of the area trigger. ```APIDOC ## areaTrigger:getContents() ### Description Gets the contents of the area trigger, returning a table of characters, bodies, harvestables, lifts, and/or areaTriggers. ### Returns - **table** - The table with the content. ``` -------------------------------- ### sm.gui.createMechanicStationGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a mechanic station dispenser GUI. ```APIDOC ## sm.gui.createMechanicStationGui(destroyOnClose) ### Description Creates a mechanic station dispenser GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### sm.gui.createMininghubDispenserGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a mining hub dispenser GUI. ```APIDOC ## sm.gui.createMininghubDispenserGui(destroyOnClose) ### Description Creates a mining hub dispenser GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### Get ID Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Returns the unique identifier for the interactable. ```lua interactable:getId( ) ``` -------------------------------- ### Destroy a BuilderGuide Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Removes the specified builder guide instance. ```lua builderGuide:destroy( ) ``` -------------------------------- ### sm.gui.createSteeringBearingGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a steering bearing upgrade GUI. ```APIDOC ### sm.gui.createSteeringBearingGui(destroyOnClose) #### Description Creates a steering bearing upgrade GUI. #### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) #### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### Get velocity Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Shape.html Returns the linear velocity of the shape. ```lua shape:getVelocity( ) ``` -------------------------------- ### character:isTumbling Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Get the character tumbling state. ```APIDOC ## character:isTumbling() ### Description Get the character tumbling state. ### Returns - **boolean** - The tumbling state. ``` -------------------------------- ### sm.gui.createGuiFromLayout Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a GUI from a layout file. ```APIDOC ### sm.gui.createGuiFromLayout(layout, destroyOnClose, settings) **Description:** Create a GUI from a layout file. **Parameters:** - `layout` (string) - Required - Path to the layout file - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) - `settings` (table) - Optional - Table with bool settings for: isHud, isInteractive, needsCursor **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### builderGuide:getId Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Retrieves the unique identifier for the builder guide. ```APIDOC ## builderGuide:getId() ### Description Returns the id of a guide. ### Parameters - **guide** (BuilderGuide) - Required - The guide. ### Returns - **integer** - The guide's id. ``` -------------------------------- ### sm.builderGuide.createBuilderGuide Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.builderGuide.html Creates a BuilderGuide object, comparing the creation from the root Shape to the blueprint specified by the path. ```APIDOC ## sm.builderGuide.createBuilderGuide ### Description Creates a BuilderGuide, comparing the creation from the root Shape to the blueprint given by the path. ### Signature `sm.builderGuide.createBuilderGuide(path, shape, ignoreBlockUuid, recordErrors, allowExtraBlocks)` ### Parameters - **path** (string) - Required - A file path to the builder guide blueprint. - **shape** (Shape) - Required - Root Shape for comparing the creation from. - **ignoreBlockUuid** (boolean) - Optional - Should block uuid be ignored for stage completion. (Defaults to false) - **recordErrors** (boolean) - Optional - Should errors be recorded. Needed for getErrorInfo (Defaults to false) - **allowExtraBlocks** (boolean) - Optional - Should extra blocks be ignored for stage completion. (Defaults to true) ### Returns - **BuilderGuide** - The created guide. ``` -------------------------------- ### character:isSwimming Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Get the character swimming state. ```APIDOC ## character:isSwimming() ### Description Get the character swimming state. ### Returns - **boolean** - The swimming state. ``` -------------------------------- ### character:isHovering Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Get the character hovering state. ```APIDOC ## character:isHovering ### Description Get the character hovering state. ### Returns - **boolean** - The hovering state. ``` -------------------------------- ### sm.gui.createChemicalContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Create a chemical container GUI. ```APIDOC ## sm.gui.createChemicalContainerGui(destroyOnClose) ### Description Create a chemical container GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused (Defaults to false). ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### character:isFlying Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Get the character flying state. ```APIDOC ## character:isFlying ### Description Get the character flying state. ### Returns - **boolean** - The flying state. ``` -------------------------------- ### sm.gui.createSurvivalHudGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a survival hud GUI. ```APIDOC ### sm.gui.createSurvivalHudGui(destroyOnClose) #### Description Creates a survival hud GUI. #### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) #### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### character:isDowned Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Get the character downed state. ```APIDOC ## character:isDowned ### Description Get the character downed state. ### Returns - **boolean** - The downed state. ``` -------------------------------- ### sm.gui.createChallengeHUDGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Create a challenge HUD GUI. ```APIDOC ## sm.gui.createChallengeHUDGui(destroyOnClose) ### Description Create a challenge HUD GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused (Defaults to false). ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### character:isDiving Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Get the character diving state. ```APIDOC ## character:isDiving ### Description Get the character diving state. ### Returns - **boolean** - The diving state. ``` -------------------------------- ### sm.gui.createDressBotGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a dress bot GUI. ```APIDOC ### sm.gui.createDressBotGui(destroyOnClose) **Description:** Create a dress bot GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### character:isClimbing Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Get the character climbing state. ```APIDOC ## character:isClimbing ### Description Get the character climbing state. ### Returns - **boolean** - The climbing state. ``` -------------------------------- ### sm.game.loadWatchedTutorials Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.game.html Loads the user's watched tutorials as a table. ```APIDOC ## sm.game.loadWatchedTutorials() ### Description Loads the users watched tutorials and returns it as a table. ### Returns - **table** - Users watched tutorials table. ``` -------------------------------- ### getJumpSpeedFraction Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Gets the current jump speed multiplier. ```APIDOC ## character:getJumpSpeedFraction() ### Description Gets the current fraction multiplier applied on the character's jump speed. ### Returns - **number** - The jump speed fraction. ``` -------------------------------- ### body:getWorldAabb Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Body.html Get the world aabb of the body. ```APIDOC ## body:getWorldAabb() ### Description Get the world aabb of the body. ### Returns - **Vec3, Vec3** - Returns the aabb min and max. ``` -------------------------------- ### sm.gui.startFadeToBlackWaitForWorld Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Fades to black, waits for world loading, then fades back. ```APIDOC ## sm.gui.startFadeToBlackWaitForWorld(duration, timeout) ### Description 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 - **duration** (number) - Animation duration - **timeout** (number) - Seconds until the fade starts waiting for the world ``` -------------------------------- ### sm.gui.createFertilizerContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a fertilizer container GUI. ```APIDOC ### sm.gui.createFertilizerContainerGui(destroyOnClose) **Description:** Create a fertilizer container GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### body:getLocalAabb Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Body.html Get the local aabb of the body. ```APIDOC ## body:getLocalAabb() ### Description Get the local aabb of the body. ### Returns - **Vec3, Vec3** - Returns the aabb min and max. ``` -------------------------------- ### sm.visualization.createBuilderGuide Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.visualization.html Creates a builder guide BlueprintVisualization comparing a root shape to a blueprint. ```APIDOC ## sm.visualization.createBuilderGuide(path, shape, ignoreBlockUuid, completeEffectName, completeEffectAtBaseName) ### Description Create a builder guide BlueprintVisualization, comparing the creation from the root Shape to the blueprint give by path. ### Parameters - **path** (string) - Required - A file path to the builder guide blueprint - **shape** (Shape) - Required - Root Shape for comparing the creation from - **ignoreBlockUuid** (boolean) - Optional - Should block uuid be evaluated for stage completion (Defaults to false) - **completeEffectName** (string) - Optional - The name of the effect that should be played at the placed block once the builder guide stage is completed (Defaults to "") - **completeEffectAtBaseName** (string) - Optional - The name of the effect that should be played at the base once the builder guide stage is completed (Defaults to "") ### Returns - **BlueprintVisualization** - The builder guide blueprint visualization ``` -------------------------------- ### harvestable:getInitialHash Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Harvestable.html Gets the initial hash of a kinematic. ```APIDOC ## harvestable:getInitialHash() ### Description Gets the initial hash of a kinematic. The initial hash identifies the kinematic by its initial world position, uuid and world id. This can be used to match kinematics spawned from the same entity in a tile even though each loaded kinematic is technically a different object. ### Returns - **number** - The initial hash. Returns 0 if the harvestable is not kinematic. ``` -------------------------------- ### sm.render.getDefaultVolumetricFog Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.render.html Gets a table of the default Volumetric fog render settings. ```APIDOC ## sm.render.getDefaultVolumetricFog() ### Description Gets a table of the default Volumetric fog render settings. ### Returns - **table** - The default Volumetric fog render settings. ``` -------------------------------- ### sm.gui.createSawbotGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a saw bot GUI. ```APIDOC ## sm.gui.createSawbotGui(destroyOnClose) ### Description Creates a saw bot GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### harvestable:getData Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Harvestable.html Get the script data from a harvestable. ```APIDOC ## harvestable:getData() ### Description Get the script data from a harvestable. ### Returns - **data** (table) - The script data. ``` -------------------------------- ### sm.gui.createEngineGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates an engine GUI. ```APIDOC ### sm.gui.createEngineGui(destroyOnClose) **Description:** Create a engine GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### Get garage position Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Garage.html Returns the position of the garage. ```lua garage:getPosition( ) ``` -------------------------------- ### sm.gui.createCraftBotGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a craft bot GUI. ```APIDOC ### sm.gui.createCraftBotGui(destroyOnClose) **Description:** Create a craft bot GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### sm.camera.getCameraState Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.camera.html Gets the camera's control state. ```APIDOC ## sm.camera.getCameraState() ### Description Gets the camera's control state. ### Returns - **state** (integer) - How the camera is moved. (See sm.camera.state) ``` -------------------------------- ### sm.gui.createGasContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a gas container GUI. ```APIDOC ### sm.gui.createGasContainerGui(destroyOnClose) **Description:** Create a gas container GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### sm.gui.createRefineryContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a refinery container GUI. ```APIDOC ## sm.gui.createRefineryContainerGui(destroyOnClose) ### Description Creates a refinery container GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### updateBuilderGuide Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BlueprintVisualization.html Updates the state of a builder guide BlueprintVisualization. ```APIDOC ## blueprintVisualization:updateBuilderGuide() ### Description Update the state of a builder guide BlueprintVisualization. Should be called whenever the root Shape of the builder guide has changed. But should not be called every frame or tick for performance. ### Parameters - **blueprintVisualization** (BlueprintVisualization) - Required - A blueprint visualization created with sm.visualization.createBuilderGuide ``` -------------------------------- ### sm.gui.createCharacterCustomizationGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Create a character customization GUI. ```APIDOC ## sm.gui.createCharacterCustomizationGui(destroyOnClose) ### Description Create a character customization GUI. Note: Character customization gui has two magic callbacks: Mouse drag cl_onDragZoneUsed (number, number) and Mouse scroll cl_onDragZoneUsed (number). ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused (Defaults to false). ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### setAutoPlay Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Effect.html Sets an effect to start playing and repeating automatically. ```APIDOC ## effect:setAutoPlay(autoplay, autoPlayOnce, resetPlayOnce) ### Description Sets an effect to start playing and repeating automatically. ### Parameters - **autoplay** (boolean) - Required - Autoplay enabled. - **autoPlayOnce** (boolean) - Optional - If set the effect will not loop when autoplaying. (Defaults to false) - **resetPlayOnce** (boolean) - Optional - Will reset the autoPlayOnce condition, allowing the effect to play again if it already has since earlier. (Defaults to false) ``` -------------------------------- ### interactable:getGlowMultiplier Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Gets the current glow multiplier value. ```APIDOC ## interactable:getGlowMultiplier() ### Description Gets the glow multiplier value for the interactable. ### Returns - **number** - The glow multiplier (0.0 - 1.0). ``` -------------------------------- ### Get BuilderGuide Error Information Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Returns a table containing counts of blocks, joints, parts, and connection errors. ```lua builderGuide:getErrorInfo( ) ``` -------------------------------- ### Get World Rotation Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Shape.html Retrieves the world rotation of a shape. ```lua shape:getWorldRotation( ) ``` -------------------------------- ### sm.gui.createWorldIconGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a world icon GUI from a layout file. ```APIDOC ### sm.gui.createWorldIconGui(width, height, layout, destroyOnClose) #### Description Creates a world icon GUI from a layout file. #### Parameters - **width** (integer) - Required - The width. - **height** (integer) - Required - The height. - **layout** (string) - Optional - Path to the layout file (Defaults to "$GAME_DATA/Gui/Layouts/Hud/Hud_WorldIcon.layout"). - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) #### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### sm.gui.createPortableCrafterGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a portable craftbot GUI. ```APIDOC ## sm.gui.createPortableCrafterGui(destroyOnClose) ### Description Creates a portable craftbot GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### Get World Position Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Shape.html Retrieves the world position of a shape. ```lua shape:getWorldPosition( ) ``` -------------------------------- ### interactable:getCarryData Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Get carry data for a script interactable. ```APIDOC ## interactable:getCarryData ### Description Get carry data for a script interactable. ### Returns - **any** - The data. ``` -------------------------------- ### Create Blueprint Visualization Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.visualization.html Creates a BlueprintVisualization from either a file path or a blueprint table. ```lua sm.visualization.createBlueprint( path ) ``` ```lua sm.visualization.createBlueprint( blueprintTable ) ``` -------------------------------- ### sm.gui.startFadeToBlack Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Fades the screen to black and back after a timeout. ```APIDOC ## sm.gui.startFadeToBlack(duration, timeout) ### Description Fades the screen to black and back after timeout. ### Parameters - **duration** (number) - Animation duration - **timeout** (number) - Seconds until the fade fades back ``` -------------------------------- ### Get Interactable Type Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Returns the type identifier for the interactable. ```lua interactable:getType( ) ``` -------------------------------- ### sm.gui.createQuestTrackerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a quest tracker GUI. ```APIDOC ## sm.gui.createQuestTrackerGui(destroyOnClose) ### Description Creates a quest tracker GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### Get Shape Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Returns the shape object that hosts the interactable. ```lua interactable:getShape( ) ``` -------------------------------- ### Get Pistons Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Returns a table of all pistons connected to the interactable. ```lua interactable:getPistons( ) ``` -------------------------------- ### sm.creation.importFromFile Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.creation.html Imports a blueprint JSON file into the world. ```APIDOC ## sm.creation.importFromFile( world, pathString, worldPosition, worldRotation, importTransforms, indestructible ) ### Description Imports a blueprint JSON file into the specified world. ### Parameters - **world** (World) - Required - The world to import to. - **pathString** (string) - Required - The blueprint path. - **worldPosition** (Vec3) - Optional - World position of import. - **worldRotation** (Quat) - Optional - World rotation of import. - **importTransforms** (boolean) - Optional - Import world transforms from bodies. - **indestructible** (boolean) - Optional - Deprecated. ### Returns - **table** - The table {Body, ...} of bodies created from the blueprint. ``` -------------------------------- ### sm.gui.createLogbookGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a log book GUI. ```APIDOC ### sm.gui.createLogbookGui(destroyOnClose) **Description:** Create a log book GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### Get Bearings Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Retrieves a table of bearings connected to the interactable. ```lua interactable:getBearings( ) ``` -------------------------------- ### sm.render.getDefaultHorizonLight Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.render.html Gets a table of the default horizon light render settings. ```APIDOC ## sm.render.getDefaultHorizonLight() ### Description Gets a table of the default horizon light render settings. ### Returns - **table** - The default horizon light render settings. ``` -------------------------------- ### sm.visualization.drawLine Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.visualization.html Adds a builderguide connection guide line between two points. ```APIDOC ## sm.visualization.drawLine(startingPoint, endPoint, color) ### Description Adds a builderguide connection guide line between two points. ### Parameters - **startingPoint** (Vec3) - Required - The starting point for the line. - **endPoint** (Vec3) - Required - The end point for the line. - **color** (Color) - Optional - The color for the line. Defaults to yellow. ``` -------------------------------- ### open Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/GuiInterface.html Opens a GUI interface. ```APIDOC ## open ### Description Open a gui interface. ### Parameters - **gui** (GuiInterface) - Required - The Gui interface to open. ``` -------------------------------- ### getWorldPosition Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/GuiInterface.html Gets the current world position of a world GUI. ```APIDOC ## getWorldPosition ### Description Gets the current world position of a world gui. ### Parameters - **gui** (GuiInterface) - Required - The Gui interface. ### Returns - **Vec3** - The in world position of the gui. ``` -------------------------------- ### sm.render.getDefaultCameraLight Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.render.html Gets a table of the default camera light render settings. ```APIDOC ## sm.render.getDefaultCameraLight() ### Description Gets a table of the default camera light render settings. ### Returns - **table** - The default camera light render settings. ``` -------------------------------- ### character:getGlowMultiplier() Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Gets the current glow multiplier for the character. ```APIDOC ## character:getGlowMultiplier() ### Description Gets the glow multiplier. ### Returns - **number** - The glow multiplier (0.0 - 1.0). ``` -------------------------------- ### Save Watched Tutorials Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.game.html Persists the provided table of watched tutorials to the user's save data. ```lua sm.game.saveWatchedTutorials( watchedTutorials ) ``` -------------------------------- ### Create a client ScriptableObject Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.clientScriptableObject.html Initializes a new client-side scriptable object using a UUID, optional parameters, and an optional world context. ```lua sm.clientScriptableObject.createScriptableObject( uuid, params, world ) ``` -------------------------------- ### Get Shape ID Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Shape.html Retrieves the unique identifier for the shape. ```lua shape:getId( ) ``` -------------------------------- ### Get Shape Color Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Shape.html Retrieves the color assigned to the shape. ```lua shape:getColor( ) ``` -------------------------------- ### sm.gui.createContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a container GUI for showing two containers. ```APIDOC ### sm.gui.createContainerGui(destroyOnClose) **Description:** Create a container GUI, for showing two containers. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### Get Shape Buoyancy Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Shape.html Retrieves the buoyancy multiplier for the shape. ```lua shape:getBuoyancy( ) ``` -------------------------------- ### character:isLadderClimbing Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Character.html Get whether the character is climbing a ladder. ```APIDOC ## character:isLadderClimbing ### Description Get whether the character is climbing a ladder. ### Returns - **boolean** - The ladder climbing state. ``` -------------------------------- ### Get Tool ID Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Tool.html Retrieves the unique identifier for the tool. ```lua tool:getId( ) ``` -------------------------------- ### sm.gui.createSeedContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a seed container GUI. ```APIDOC ## sm.gui.createSeedContainerGui(destroyOnClose) ### Description Creates a seed container GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### unit:getCurrentMovementDirection Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Unit.html Gets the current movement direction of a unit. ```APIDOC ## unit:getCurrentMovementDirection() ### Description Gets the current movement direction of a unit. ### Returns - **Vec3** - The units movement direction. ``` -------------------------------- ### Set Portal Opening A Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Portal.html Configures the position, rotation, and world for portal opening A. ```lua portal:setOpeningA( position, rotation, world ) ``` -------------------------------- ### unit:getCurrentFacingDirection Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Unit.html Gets the current facing direction of a unit. ```APIDOC ## unit:getCurrentFacingDirection() ### Description Gets the current facing direction of a unit. ### Returns - **Vec3** - The units facing direction. ``` -------------------------------- ### sm.gui.createProspectorContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a prospector container GUI. ```APIDOC ## sm.gui.createProspectorContainerGui(destroyOnClose) ### Description Creates a prospector container GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### Get Player Name Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Player.html Retrieves the name of the player as a string. ```lua player:getName( ) ``` -------------------------------- ### Create dropdown menu Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/GuiInterface.html Creates a dropdown menu at the specified widget. ```lua guiInterface:createDropDown( widgetName, functionName, options ) ``` -------------------------------- ### Get Joint Color Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Joint.html Retrieves the color property of the joint. ```lua joint:getColor( ) ``` -------------------------------- ### Load menu creation blueprint Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.menuCreation.html Retrieves the user's menu creation blueprint as a table. This function is server-only. ```lua sm.menuCreation.load( ) ``` -------------------------------- ### Get Body Mass Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Body.html Returns the total mass of the body. ```lua body:getMass( ) ``` -------------------------------- ### sm.gui.createHideoutGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a hideout GUI. ```APIDOC ### sm.gui.createHideoutGui(destroyOnClose) **Description:** Create a hideout gui GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### Get Effect ID Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Effect.html Retrieves the unique identifier for the effect. ```lua effect:getId( ) ``` -------------------------------- ### Get Lift Level Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Lift.html Retrieves the current level of the lift. ```lua lift:getLevel( ) ``` -------------------------------- ### sm.gui.createCompassHudGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a compass HUD GUI. ```APIDOC ### sm.gui.createCompassHudGui(destroyOnClose) **Description:** Creates a compass hud GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### sm.gui.createWaypointIconGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a waypoint icon GUI. ```APIDOC ### sm.gui.createWaypointIconGui(destroyOnClose) #### Description Creates a waypoint icon GUI. Note: Deprecated, use createWorldIconGui. #### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) #### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### sm.gui.createGlowstickContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a glowstick container GUI. ```APIDOC ### sm.gui.createGlowstickContainerGui(destroyOnClose) **Description:** Create a glowstick container GUI. **Parameters:** - `destroyOnClose` (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) **Returns:** - `GuiInterface` - The gui interface to the created gui. ``` -------------------------------- ### Open GUI interface Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/GuiInterface.html Opens the specified GUI interface. ```lua guiInterface:open( ) ``` -------------------------------- ### sm.localPlayer.getGarmentUpperCaseTitle Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.localPlayer.html Gets the uppercase title of the garment with the given UUID. ```APIDOC ## sm.localPlayer.getGarmentUpperCaseTitle(uuid) ### Description Gets the UPPER CASE title of the garment with the given uuid in the current language. ### Parameters - **uuid** (Uuid) - Required - The garment. ### Returns - **string** - The title of the garment. ``` -------------------------------- ### ClientScriptableObject Template Source: https://scrapmechanicdocs.com/Game-Script-Environment/Classes/ClientScriptableObjectClass-Template.html Use this template as a starting point for your script, removing any unused callback functions. ```lua ClientScriptableObject = class() -- Server callbacks -- Docs: ClientScriptableObjectClass.html#server_oncreate function ClientScriptableObject.server_onCreate( self ) end -- Docs: ClientScriptableObjectClass.html#server_ondestroy function ClientScriptableObject.server_onDestroy( self ) end -- Docs: ClientScriptableObjectClass.html#server_onrefresh function ClientScriptableObject.server_onRefresh( self ) end -- Docs: ClientScriptableObjectClass.html#server_onfixedupdate function ClientScriptableObject.server_onFixedUpdate( self, timeStep ) end -- Docs: ClientScriptableObjectClass.html#server_onreceiveupdate function ClientScriptableObject.server_onReceiveUpdate( self ) end -- Client callbacks -- Docs: ClientScriptableObjectClass.html#client_oncreate function ClientScriptableObject.client_onCreate( self ) end -- Docs: ClientScriptableObjectClass.html#client_ondestroy function ClientScriptableObject.client_onDestroy( self ) end -- Docs: ClientScriptableObjectClass.html#client_onrefresh function ClientScriptableObject.client_onRefresh( self ) end -- Docs: ClientScriptableObjectClass.html#client_onfixedupdate function ClientScriptableObject.client_onFixedUpdate( self, timeStep ) end -- Docs: ClientScriptableObjectClass.html#client_onupdate function ClientScriptableObject.client_onUpdate( self, deltaTime ) end -- Docs: ClientScriptableObjectClass.html#client_onclientdataupdate function ClientScriptableObject.client_onClientDataUpdate( self, data, channel ) end -- Docs: ClientScriptableObjectClass.html#client_onlocalplayerchangedworld function ClientScriptableObject.client_onLocalPlayerChangedWorld( self, world ) end ``` -------------------------------- ### Get current tick Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.game.html Returns the current game tick. ```lua sm.game.getCurrentTick( ) ``` -------------------------------- ### jsonGui:setHidden Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/JsonGui.html Sets desired visibility of the gui. ```APIDOC ## jsonGui:setHidden(hidden) ### Description Sets desired visibility of the gui. ### Parameters - **gui** (JsonGui) - The gui. - **hidden** (boolean) - True if the gui should be hidden. ``` -------------------------------- ### Set Widget Preview Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/JsonWidget.html Configures the item or blueprint preview for the widget. Passing nil clears the preview. ```lua jsonWidget:setPreview( uuid ) ``` ```lua jsonWidget:setPreview( string ) ``` ```lua jsonWidget:setPreview( ) ``` -------------------------------- ### sm.gui.createOreCrusherContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates an ore crusher container GUI. ```APIDOC ## sm.gui.createOreCrusherContainerGui(destroyOnClose) ### Description Creates an ore crusher container GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### builderGuide:getStageInfo Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/BuilderGuide.html Retrieves information about the current stage, including remaining requirements. ```APIDOC ## builderGuide:getStageInfo() ### Description Returns information about the current stage. ### Parameters - **guide** (BuilderGuide) - Required - The guide. ### Returns - **table** - Table of stage info { blocksLeft = number, jointsLeft = number, partsLeft = number, connectionsLeft = number }. ``` -------------------------------- ### Get Local Axes Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Shape.html Retrieves the local axis vectors of a shape. ```lua shape:getXAxis( ) ``` ```lua shape:getYAxis( ) ``` ```lua shape:getZAxis( ) ``` -------------------------------- ### jsonGui:render Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/JsonGui.html Renders the DOM for the GUI. ```APIDOC ## jsonGui:render(DOM, forceProperties) ### Description Renders the DOM. ### Parameters - **gui** (JsonGui) - The gui. - **DOM** (table) - A table representing the gui elements to show. - **forceProperties** (boolean) - Optional. Force update widget properties. Defaults to false. ``` -------------------------------- ### Get Animation Duration Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Retrieves the duration of a specific animation in seconds. ```lua interactable:getAnimDuration( name ) ``` -------------------------------- ### Add Grid Items From File Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/GuiInterface.html Populates a grid with items defined in a JSON file. ```lua guiInterface:addGridItemsFromFile( gridName, jsonPath, additionalData ) ``` -------------------------------- ### Get Steering Sprint Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Retrieves the sprint value of a steering interactable. ```lua interactable:getSteeringSprint( ) ``` -------------------------------- ### sm.tool.forceTool Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.tool.html Force equips a tool for the local player. ```APIDOC ## sm.tool.forceTool(tool) ### Description Force equip a tool for the local player. Pass nil to unforce an already forced tool. ### Parameters - **tool** (Tool) - The tool. ``` -------------------------------- ### Get Steering Power Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Returns the Character currently locking the controller. ```lua interactable:getSteeringPower( ) ``` -------------------------------- ### client_onEquip Source: https://scrapmechanicdocs.com/Game-Script-Environment/Classes/ToolClass.html Called when a player equips the tool. ```APIDOC ## ToolClass:client_onEquip(animate) ### Description Called when a Player equips the Tool. ### Parameters - **self** (table) - Required - The class instance. - **animate** (boolean) - Required - A boolean indicating whether the event should be animated or not. ``` -------------------------------- ### sm.game.getSettingString Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.game.html Retrieves a string game setting. ```APIDOC ## sm.game.getSettingString(name) ### Parameters - **name** (string) - The name of the setting. ### Returns - **value** (string) - The string value of the setting. ``` -------------------------------- ### Get Seat Interactables Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Retrieves a list of interactables connected to the seat. ```lua interactable:getSeatInteractables( ) ``` -------------------------------- ### Get Seat Character Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Retrieves the character currently seated in the interactable. ```lua interactable:getSeatCharacter( ) ``` -------------------------------- ### sm.creation.importFromString Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.creation.html Imports a blueprint JSON string into the world. ```APIDOC ## sm.creation.importFromString( world, jsonString, worldPosition, worldRotation, importTransforms, forceInactive ) ### Description Imports a blueprint JSON string into the specified world. ### Parameters - **world** (World) - Required - The world to import to. - **jsonString** (string) - Required - The blueprint json string. - **worldPosition** (Vec3) - Optional - World position of import. - **worldRotation** (Quat) - Optional - World rotation of import. - **importTransforms** (boolean) - Optional - Import world transforms from bodies. - **forceInactive** (boolean) - Optional - Import interactables in an inactive state. ### Returns - **table** - The table {Body, ...} of bodies created from the blueprint. ``` -------------------------------- ### Get Joints Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Returns a table of all connected joints, such as bearings and pistons. ```lua interactable:getJoints( ) ``` -------------------------------- ### sm.gui.createNameTagGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Creates a name tag GUI. ```APIDOC ## sm.gui.createNameTagGui(destroyOnClose) ### Description Creates a name tag GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused. (Defaults to false) ### Returns - **GuiInterface** - The gui interface to the created gui. ``` -------------------------------- ### Get Container Source: https://scrapmechanicdocs.com/Game-Script-Environment/Userdata/Interactable.html Retrieves the container at the specified index within the controller. ```lua interactable:getContainer( index ) ``` -------------------------------- ### sm.gui.createAmmunitionContainerGui Source: https://scrapmechanicdocs.com/Game-Script-Environment/Static-Functions/sm.gui.html Create an ammunition container GUI. ```APIDOC ## sm.gui.createAmmunitionContainerGui(destroyOnClose) ### Description Create an ammunition container GUI. ### Parameters - **destroyOnClose** (boolean) - Optional - If true the gui is destroyed when closed, otherwise the gui can be reused (Defaults to false). ### Returns - **GuiInterface** - The gui interface to the created gui. ```