Builder
Contains utility functions for builders.
info
This module can only be used in Entity scripts.
Functions
getPersistentData(key)
Returns persistent data stored.
Parameters
- key — A string containing the key used to identify the data cache.
Example
Get the portal destination when the world starts and changing the portal destination to the one stored in the Builder persistent data.
function onStart()
local destination = Builder.getPersistentData("portalDestination")
Portal.setDestination(destination, Players.All)
end
setPersistentData(key, value)
Stores data in a cache specific to the builder of the world.
Parameters
- key — A string containing the key used to identify the data cache.
- value — The data to store in the cache.
Example
Set portal destination when the player score is higher than 100.
-- custom function added to an event previously
local function onPlayerScore(clientId)
local playerScore = Players.getPersistentData(clientId, "score")
if playerScore > 100 then
Builder.setPersistentData("portalDestination", 'scs2')
end
end
hasPersistentData(key)
Returns true if the cache has a value with the specified key.
Parameters
- key — String identifier for the data value.