Gui-related functions.
sm.crashlander.createDialogGui( text, optionsAmount, optionsTexts, optionsCallback, icon, displayedName, isSelfTalkGui, forceHud )
Client only
Creates a dialog gui with the given parameters.
Arguments:
text
[ string ] The text that should be displayed. optionsAmount
[ number ] The amount of options. (allowed: 0, 1, 2, 3) optionsTexts
[ table? ] A table containing the strings displayed in the options in order. (default: "Accept", "Decline", "Leave") optionsCallback
[ string ] The name of the callback to be called when an option is chosen. icon
[ string? ] The path to the icon that should be displayed. (default: "player") displayedName
[ string? ] The name to display under the icon. (default: "") isSelfTalkGui
[ boolean? ] Whether the gui is a "self talk" gui. (only allowed with 0 options) forceHud
[ boolean? ] Whether to force the gui to be a hud or not. (default: false)Returns:
sm.crashlander.createToolChargeGui( iconPath )
Client only
Creates a tool charge gui with the given icon.
Arguments:
iconPath
[ string ] The path to the icon.Returns:
sm.crashlander.getNamedIconPath( name )
Client only
Returns the path to the icon with the given name, returns nil if the name is invalid.
Valid icon names:
"player"
"playerFemale"
"playerMale"
"loneGuy"
"mark"
"ivan"
"justin"
"hank"
Arguments:
name
[ string ] The name of the icon.Returns:
sm.crashlander.getInteractionIconScreenSize()
Client only
Returns the screen size for icons in interaction texts.
Returns:
sm.crashlander.getDisplayName( name )
Client only
Returns a translated string if a language tag with the given name exists, otherwise returns the given name.
Arguments:
name
[ string? ] The name.Returns:
sm.crashlander.addLanguageTagSet( path, language )
Server only
Adds a langugage tag set to crashlander's language tag system.
Allows for easily adding translations for any string.
Arguments:
path
[ string ] The path to the json file containing the tags. The path has to use $CONTENT_<uuid of your mod>
instead of $CONTENT_DATA
, or else it will refer to the Crashlander files. (You can find the uuid of your mod in description.json in the root folder of your mod)language
[ LanguageName ] The language that the tags are for.Crashlander's weather system.
sm.crashlander.getCurrentWeatherType()
Returns the current weather type.
See sm.crashlander.weatherTypes.
Returns:
sm.crashlander.getCurrentWeatherData()
Client only
Returns the current translated weather string and weather icon.
See sm.crashlander.weatherTypes.
Returns:
sm.crashlander.isRaining()
Returns whether the current weather has rain in it.
See sm.crashlander.weatherTypes.
Returns:
sm.crashlander.weatherTypes = {
clear = 0,
rain = 1,
cloudy = 2,
verycloudy = 3,
fog = 4,
storm = 5,
}
A table of all weather types.
Crashlander's equipment system.
sm.crashlander.addEquipment(uuid, slot, renderable, stats, onUpdate, onUse, setId)
Adds a new equipment item to the equipment system.
Arguments:
uuid
[ Uuid ] UUID of the item.slot
[ EquipmentSlot ] The slot that the equipment will be used in, check sm.crashlander.equipmentSlots.renderable
[ string ] Path to the renderable of the equipment.stats
[ EquipmentStats? ] The stats of the equipment, optional, defaults to no special stats.onUpdate
[ EquipmentCallback? ] The function that will be called when the equipment is equipped/unequipped, optional. The callback recieves an [EquipmentCallbackArgument] object as an argument. Client only onUse
[ EquipmentCallback? ] The function that will be called when the equipment is used(player presses R), optional. The callback recieves the [Player] that has the item equipped as an argument. Client onlysetId
[ string? ] The set id of the equipment, optional. Client onlysm.crashlander.getEquipmentList( character )
Returns a list of equipped items.
Argument:
character
[ Character ] The player's character.Returns:
sm.crashlander.isEquipmentEquipped( character, uuid )
Returns whether the equipment item is equipped.
Argument:
character
[ Character ] The player's character. uuid
[ Uuid ] The uuid of the equipment.Returns:
sm.crashlander.isEquipmentSetEquipped( character, setId )
Returns whether the equipment set is equipped.
Arguments:
character
[ Character ] The player's character.setId
[ string ] The id of the equipment set.Returns:
sm.crashlander.equipmentSlots = {
head = "head",
torso = "torso",
leg = "leg",
foot = "foot",
accessory = "acc"
}
A list of crashlander's equipment slots.
Other utilities.
sm.crashlander.version
The current version of crashlander as a string.
sm.crashlander.hasSoundDLC()
Whether the Crashlander Audio Enhancement DLC is installed.
Returns:
sm.crashlander.getCompletedAchievementCount()
Returns the amount of completed achievements.
Returns:
sm.crashlander.npcUuids = {
sm.uuid.new("36b1e8ff-8ffa-4b75-a548-1d6377434d53"),
sm.uuid.new("4296f22c-1205-4035-bad8-e12120fce5a8"),
sm.uuid.new("bf3982d8-ac96-47c0-b8b7-224f822180e2"),
sm.uuid.new("ae6310a3-ea6c-4e8e-ac28-407bb0c2dfb1"),
sm.uuid.new("538ec386-f714-4cde-bd82-ade0d6f5edbf")
}
A list of crashlander npc uuids.
sm.crashlander.fetchRecipeByUUID( uuid )
Returns the recipe of an item by it's uuid or string uuid.
Arguments:
uuid
[ Uuid | string ] The uuid or string uuid of the recipe.Returns:
sm.crashlander.isServer()
Returns whether the function is being run on the server.
Returns:
sm.crashlander.isActionBound( action )
Returns whether the player has a keybind bound to the specified action.
Arguments:
action
[ string ] The action name, e.g. "Use", "Reload", "Tinker".Returns:
sm.crashlander.isInLiquid( areaTrigger, filter )
Checks whether the given areaTrigger is inside a liquid.
Arguments:
areaTrigger
[ AreaTrigger ] The areaTrigger to check. filter
[ LiquidFilter? ] The liquids to check for. (default: { water = true, chemical = true, oil = true })Returns:
sm.crashlander.getMaterialIndex( matString )
Returns the index of a material from its string.
Arguments:
matString
[ string ] The material string.Returns:
sm.crashlander.getCellPosition( x, y )
Gets cell coordinates from world coordinates.
Arguments:
x
[ number ] The world X position. y
[ number ] The world y position.Returns:
sm.crashlander.getBiomeAt( x, y, asString )
Server only
Gets cell biome from world position.
Arguments:
x
[ number ] The X position. y
[ number ] The y position. asString
[ boolean ] Whether to return the biome as string, otherwise as index.Returns:
sm.crashlander.doesUnitExist( uuid )
Server only
Checks if atleast one unit with this character uuid exists.
Arguments:
uuid
[ Uuid ] The character uuid to check for.Returns:
sm.crashlander.getUnitQuantity( uuid )
Server only
Checks how many units with this character uuid exist.
Arguments:
uuid
[ Uuid ] The character uuid to check for.Returns:
sm.crashlander.killUnitsOfUuid( uuid )
Server only
Kills all units with this character uuid.
Arguments:
uuid
[ Uuid ] The character uuid to check for.sm.crashlander.getPlayerByName( name )
Returns the player with the given name.
Arguments:
name
[ string ] The name of the player.Returns:
sm.crashlander.getPlayersInRange( pos, distance, maxAmount )
Returns players that are in a certain distance around a provided point.
Arguments:
pos
[ Vec3 ] The position to look around.distance
[ number ] The distance to look in.maxAmount
[ integer? ] Max amount of players to return, nil for infinite.Returns:
sm.crashlander.getRandomColor()
Returns a random color.
Returns:
sm.crashlander.getIndexOf( item, tbl )
Returns the index of the item in the table.
Arguments:
item
[ any ] The thing to check for. tbl
[ table ] The table to check in.Returns:
sm.crashlander.combineTables( ... )
Returns a table combining the tables provided into the function.
Arguments:
...
[ table ] Variable amount of tables.Returns:
sm.crashlander.getRealLength( tbl )
Returns the real length of a table.
Unlike #table
, this function also works for tables with keys.
Arguments:
tbl
[ table ] The table.Returns:
sm.crashlander.getByIndex( tbl, index )
Returns an item from the table by a number index.
Unlike table[number]
, this function gets items from tables using an index even if the table has keys.
Arguments:
tbl
[ table ] The table.index
[ number ] The index.Returns:
sm.crashlander.areAnyOf( tbl, tbl2 )
Returns whether any item from tbl is present in tbl2.
Arguments:
tbl
[ table ] The table. tbl2
[ table ] The other table.Returns:
sm.crashlander.getContainerItems( container )
Returns a table of all contents inside the specified container.
Arguments:
container
[ Container ] The container.Returns:
sm.crashlander.ordinalizeNumber( num )
Client only
Returns the given number or number string with Ordinal Indication.
Arguments:
num
[ number | string ] The number.Returns:
Classes used purely for documenting specific values or table structures.
Any string from sm.crashlander.equipmentSlots.
Table contents:
uuid
[ Uuid ]slot
[ EquipmentSlot ]renderable
[ string? ]stats
[ EquipmentStats? ]onUpdate
[ string? ]onUse
[ string? ]setId
[ string? ]Table contents:
damageReduction
[ number? ] The amount of damage that the equipment will block(in percents)oxygenMultiplier
[ number? ] The amount the oxygen will be multiplied by when equippedwaterMovementMultiplier
[ number? ] The amount the swim speed will be multiplied by when equppedTable contents:
callback
[ string ] The name of the function that will be called.object
[ Harvestable | ScriptableObject | Character | Tool | Interactable | Unit | Player | World ] The reference to the object that the function will be called on.Table contents:
state
[ boolean ]player
[ Player ]Any of the following strings:
"TYPE_MEADOW"
"TYPE_FOREST"
"TYPE_DESERT"
"TYPE_FIELD"
"TYPE_BURNTFOREST"
"TYPE_AUTUMNFOREST"
"TYPE_TAYGA"
"TYPE_LAKE"
Table contents:
water
[ boolean? ]chemical
[ boolean? ]oil
[ boolean? ]Any of the following strings:
"Brazilian"
"Chinese"
"English"
"French"
"German"
"Italian"
"Japanese"
"Korean"
"Polish"
"Russian"
"Spanish"