local statueCountingStorage = 45000
local statues = {
-- [actionId] = {storageKey = xxxxx, experience = {min, max}},
[45001] = {storageKey = 45001, experience = {100, 1000}},
[45002] = {storageKey = 45002, experience = {100, 1000}},
[45049] = {storageKey = 45049, experience = {100, 1000}},
[45050] = {storageKey = 45050, experience = {100, 1000}}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local statue = statues[item:getActionId()]
local storage = player:getStorageValue(statue.storageKey)
local statueStorage = player:getStorageValue(statueCountingStorage)
local totalStatueCount = 0
for _ in pairs(statues) do
totalStatueCount = totalStatueCount + 1
end
local statueText = statueCount .. "/" .. totalStatueCount .. " exp statues"
if storage == 1 then
player:say(statueText .. " have been located.", TALKTYPE_MONSTER_SAY, false, player, toPosition)
return true
end
local statueCount = math.max(statueStorage), 0) + 1
player:setStorageValue(statueCountingStorage, statueCount)
player:setStorageValue(statue.storageKey, 1)
local experienceToAdd = math.random(statue.experience[1], statue.experience[2])
player:addExperience(experienceToAdd, true)
player:say("Discovered " .. statueText .. "!\nYou gain " .. experienceToAdd .. " experience!", TALKTYPE_MONSTER_SAY, false, player, toPosition)
return true
end