Property¶
Properties are what is used to describe the game data structure.
Constructors¶
The following functions are all returning objects which should be considered of type Property
.
newBoolean¶
Property.newBoolean(defaultValue: boolean)
true
or false
). newNumber¶
Property.newNumber(defaultValue: number)
newInteger¶
Property.newInteger(defaultValue: number)
newPositiveInteger¶
Property.newPositiveInteger(defaultValue: number)
newString¶
Property.newString(defaultValue: string)
newList¶
Property.newList(elementProperty: Property, getDefault: function?)
elementProperty
. For example, to create a list of integers:
local listOfInteger = Property.newList(Property.newInteger())
To create a list of booleans, with a default value being with one element equals to true
:
local list = Property.newList(
Property.newBoolean(),
function() return { true } end
)
newObject¶
Property.newObject(interface: { string: Property })
For values which are dictionary-like tables in Lua. Each field of the interface must be a string made only from letters, numbers or underscores. Example:
local object = Property.newObject(
newPlayerMoney = Property.newPositiveInteger(100),
)
You can nest objects if you want to:
local object = Property.newObject({
newPlayerMoney = Property.newPositiveInteger(100),
featureFlags = Property.newObject({
useCheaperItems = Property.newBoolean(false),
allowDepositToBank = Property.newBoolean(true),
}),
})