Data management based on a key table. Any key in the table will be synchronized on Players
Modules = {
playerData = "github.com/BucheGithub/modzh/playerData:20105ef",
}
myDataKeys = {
"health",
"atk",
"def",
}
playerData:init(myDataKeys)
Player.health = 100
Player.atk = 30
Player.def = 10
-- Created local data
playerData:save(Player)
-- Data is now stored in Kvs
Player.health = 0
Player.atk = 0
Player.def = 0
-- Local data is reset
playerData:load(Player)
-- Data loaded from Kvs
-- Player.health is now 100 again
-- Player.atk is now 30 again
-- Player.def is now 10 again
playerData:reset(Player)
-- Reset player entry in Kvs
-- Local data is untouched
playerData:load(Player)
-- Data laoded from Kvs
-- Player.health is now 0
-- Player.atk is now 0
-- Player.def is now 0