diff --git a/data/libs/hazard_lib.lua b/data/libs/hazard_lib.lua index d10650a81b6..c13f120f740 100644 --- a/data/libs/hazard_lib.lua +++ b/data/libs/hazard_lib.lua @@ -88,30 +88,22 @@ function Hazard:getPlayerMaxLevel(player) local fromStorage = player:getStorageValue(self.storageMax) return fromStorage <= 0 and 1 or fromStorage end - local fromKV = player:kv():scoped(self.name):get("maxLevel") + local fromKV = player:kv():scoped(self.name):get("maxLevel") or 1 + return fromKV <= 0 and 1 or fromKV end function Hazard:levelUp(player) - if self.storageMax and self.storageCurrent then - local current = self:getPlayerCurrentLevel(player) - local max = self:getPlayerMaxLevel(player) - if current == max then - self:setPlayerMaxLevel(player, max + 1) - end - return - end - - local current = player:kv(self.name):get("currentLevel") - local max = player:kv(self.name):get("maxLevel") + local current = self:getPlayerCurrentLevel(player) + local max = self:getPlayerMaxLevel(player) if current == max then - player:kv(self.name):set("maxLevel", max + 1) + self:setPlayerMaxLevel(player, max + 1) end end function Hazard:setPlayerMaxLevel(player, level) - if level > self.maxLevelLevel then - level = self.maxLevelLevel + if level > self.maxLevel then + level = self.maxLevel end if self.storageMax then