-
Notifications
You must be signed in to change notification settings - Fork 1
Data Storage
KabanFriends edited this page Dec 3, 2022
·
2 revisions
Each level has a data storage where you can write and read values, and the data will be stored permanently. Each data has a key and the data can be either a string, a number or a boolean. To see a list of functions to manipulate data storage, see this section in the documentation.
function onPlayerJoin(e)
local p = e.player
if level.dataExists(p.name .. ".clicks") then
-- Get how many times the player has clicked before
p.clicks = level.readData(p.name .. ".clicks")
end
end
function onPlayerPressLeftClick(e)
local p = e.player
p.clicks = p.clicks + 1
p.message("You left clicked " .. tostring(p.clicks) .. " tiems!")
-- Write how many times the player has clicked
level.writeData(p.name .. ".clicks", p.clicks)
end