Module ContainerUnit
Containers are elements designed to store items and resources.
Element class:
- ContainerSmallGroup (for XS item containers)
- ContainerMediumGroup (for S item containers)
- ContainerLargeGroup (for M item containers)
- ContainerXLGroup (for L item containers)
- ContainerXXLGroup (for XL item containers)
- ContainerXXXLGroup (for expanded XL item containers)
- MissionContainer
- AtmoFuelContainer
- SpaceFuelContainer
- RocketFuelTank
Extends: Element
Functions
getSelfMass () | Returns the mass of the container element (as if it were empty). |
getItemsMass () | Returns the container content mass (the sum of the mass of all the items it contains). |
getItemsVolume () | Returns the container content volume (the sum of the volume of all items it contains). |
getMaxVolume () | Returns the maximum volume of the container. |
getItemsList () | Deprecated: Returns the list of items in the container, as a json string you need to parse with json.decode. |
getContent () | Returns a table describing the contents of the container, as a pair itemId and quantity per slot. |
acquireStorage () | Deprecated:Initiate the acquisition of the storage in the container, required before calls to getItemsList. |
updateContent () | Send a request to get an update of the content of the container, limited to one call allowed per 30 seconds. |
getWidgetData () | Get element data as JSON. |
EVENT_storageAcquired () | Deprecated: Event: The access to the container storage is granted. |
EVENT_onContentUpdate () | Event: Emitted when the container content is updated (storage update or after a manual request made with updateContent()). |
Functions
- getSelfMass ()
-
Returns the mass of the container element (as if it were empty).
Returns:
-
float
The mass of the container in kilograms.
- getItemsMass ()
-
Returns the container content mass (the sum of the mass of all the items it contains).
Returns:
-
float
The total mass of the contents of the container, excluding the container's own mass, in kilograms.
- getItemsVolume ()
-
Returns the container content volume (the sum of the volume of all items it contains).
Returns:
-
float
The total volume of the contents of the container in liters.
- getMaxVolume ()
-
Returns the maximum volume of the container.
Returns:
-
float
The maximum volume of the container in liters.
- getItemsList ()
-
Deprecated: Returns the list of items in the container, as a json string you need to parse with json.decode.
Returns:
-
jsonstr
The container content as a json list of json objects with fields: name, quantity, unitVolume, unitMass, type, class
- getContent ()
-
Returns a table describing the contents of the container, as a pair itemId and quantity per slot.
Note: You have to request the contents of the container from the server by calling updateContent first.
Returns:
-
table
The contents of the container as a table with fields {[int] id, [float] quantity} per slot.
See also:
- acquireStorage ()
-
Deprecated:Initiate the acquisition of the storage in the container, required before calls to getItemsList.
Simply wait for the event 'storageAcquired' to be emitted by the container, and you can then use the storage related
functions.
Note: This is rate-limited to 10 queries / 5 minutes. Attempting to call more frequently will result in console error messages.
This method is deprecated: updateContent should be used instead.
See also:
- updateContent ()
-
Send a request to get an update of the content of the container, limited to one call allowed per 30 seconds. The
onContentUpdate event is emitted by the container when the content is updated.
Returns:
-
float
If the request is not yet possible, returns the remaining time to wait for in seconds.
See also:
- getWidgetData ()
-
Get element data as JSON.
Fuel containers (element classes
AtmoFuelContainer
,SpaceFuelContainer
, andRocketFuelTank
) have afuel_container
widget, which contains the following fields (bold fields are visible when making custom use of the widget):- percentage (float) The percent full.
- timeLeft (float) Time in seconds, pass "" to leave blank.
- name (string) The name of the element.
- helperId (string)
fuel_container_atmo_fuel
|fuel_container_space_fuel
|fuel_container_rocket_fuel
- type (string)
fuel_container
Returns:
-
string
Data as JSON.
- EVENT_storageAcquired ()
-
Deprecated: Event: The access to the container storage is granted. Required before using getItemsList, for example.
Note: This is documentation of an event handler, not a callable method.
This event is deprecated: EVENT_onContentUpdate should be used instead.
See also:
- EVENT_onContentUpdate ()
-
Event: Emitted when the container content is updated (storage update or after a manual request made with updateContent()).
Note: This is documentation of an event handler, not a callable method.
See also: