Modding:Lua/Tables/Storage

From Starbounder - Starbound Wiki
Jump to: navigation, search

Description

Storage is a table used to store information related to a persistent entity, like npcs and objects. It is by default only populated with the information you put into it and otherwise empty.

Any lua type that can be serialized can be put into one, so use this to keep track of information that stays for a long time.

For temporary storage, see the table Self.


It is used in much the same way as "self":

storage.thisIsAVariable = "blue"

will set (and create if needed) the variable named thisIsAVariable to the string "blue".

storage.haveIWon = false

will set/create the variable named haveIWon to the boolean false.

The values will persist across game sessions (i.e. quitting the game and starting it later), but will not survive the object breaking and being placed again. Make sure your script has the function die() in it, and use that to do any necessary cleanup before the object breaks (such as dropping items in it, or exploding if you left nuclear fuel in it or something).

Quick Navigation

Quick Navigation