local explorationPoints = {
--[[
[actionid] = { explorationName = "name",
{uniqueid, "text"},
{uniqueid, "text"}
}
[1111] = { explorationName = "The Great Trees",
{1112, "The White Tree"},
{1113, "The Green Tree"}, -- 1112, 1113, 1114 are UniqueID's
{1114, "The Black Tree"} -- the text will show as "You have found 1/3 of The Great Trees! The Black Tree discovered!"
},
[2222] = { explorationName = "The Trees of Wealth"
{2222, "The Gold Tree"},
{2223, "The Platinum Tree"},
{2224, "The Crystal Tree"}
}
--]]
[5000] = { explorationName = "The Hidden Statues", -- actionid
{5001, "aaaaaaaaaaaaaa"}, -- uniqueid
{5002, "aaaaaaaaaaaaaa"},
{5003, "aaaaaaaaaaaaaa"},
{5004, "aaaaaaaaaaaaaa"},
{5005, "aaaaaaaaaaaaaa"},
{5006, "aaaaaaaaaaaaaa"},
{5007, "aaaaaaaaaaaaaa"},
{5008, "aaaaaaaaaaaaaa"},
{5009, "aaaaaaaaaaaaaa"},
{5010, "aaaaaaaaaaaaaa"},
{5011, "aaaaaaaaaaaaaa"},
{5012, "aaaaaaaaaaaaaa"},
{5013, "aaaaaaaaaaaaaa"},
{5014, "aaaaaaaaaaaaaa"},
{5015, "aaaaaaaaaaaaaa"},
{5016, "aaaaaaaaaaaaaa"},
{5017, "aaaaaaaaaaaaaa"},
{5018, "aaaaaaaaaaaaaa"},
{5019, "aaaaaaaaaaaaaa"},
{5020, "aaaaaaaaaaaaaa"},
{5021, "aaaaaaaaaaaaaa"},
{5022, "aaaaaaaaaaaaaa"},
{5023, "aaaaaaaaaaaaaa"},
{5024, "aaaaaaaaaaaaaa"},
{5025, "aaaaaaaaaaaaaa"},
{5026, "aaaaaaaaaaaaaa"},
{5027, "aaaaaaaaaaaaaa"},
{5028, "aaaaaaaaaaaaaa"},
{5029, "aaaaaaaaaaaaaa"},
{5030, "aaaaaaaaaaaaaa"},
{5031, "aaaaaaaaaaaaaa"},
{5032, "aaaaaaaaaaaaaa"},
{5033, "aaaaaaaaaaaaaa"},
{5034, "aaaaaaaaaaaaaa"},
{5035, "aaaaaaaaaaaaaa"},
{5036, "aaaaaaaaaaaaaa"},
{5037, "aaaaaaaaaaaaaa"},
{5038, "aaaaaaaaaaaaaa"},
{5039, "aaaaaaaaaaaaaa"},
{5040, "aaaaaaaaaaaaaa"},
},
[5041] = { explorationName = "The Great Tree's", -- actionid
{5042, "abc123"}, -- uniqueid
{5042, "abc123"}
}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey) -- you might need to remove isHotkey, idk
-- confirm if actionid is in table
local actionID = item:getActionId()
if not explorationPoints[actionID] then
print("LUA ERROR: Exploration point actionid (" .. actionID .. ") is not in the table.")
return true
end
-- confirm if uniqueid is setup on the item
local uniqueID = item:getUniqueId()
if uniqueID < 1 then
print("LUA ERROR: Exploration point uniqueid (" .. uniqueID .. ") is not setup on the item.")
return true
end
-- confirm that uniqueid is in the table
-- update index
local index = explorationPoints[actionID]
local explorationCount = #index
for i = 1, explorationCount do
if index[i][1] == uniqueID then
index = index[i]
break
end
if i == explorationCount then
print("LUA ERROR: Exploration point uniqueid (" .. uniqueID .. ") is not found in the table.")
return true
end
end
-- confirm if quest has been completed previously
local actionidStorageValue = player:getStorageValue(actionID)
local uniqueidStorageValue = player:getStorageValue(uniqueID)
local explorationText = explorationPoints[actionID].explorationName
if actionidStorageValue == explorationCount or uniqueidStorageValue == 1 then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You have already " .. (uniqueidStorageValue ~= 1 and "finished the exploration of " .. explorationText .. "" or "found this exploration point") .. ".")
return true
end
-- update quest status
player:setStorageValue(actionID, actionidStorageValue + 1)
player:setStorageValue(uniqueID, uniqueidStorageValue + 1)
player:say("You have found " .. actionidStorageValue + 1 .. "/" .. explorationCount .. " of\n" .. explorationText .. "!\n\n" .. index[2] .. " discovered!", TALKTYPE_MONSTER_SAY)
-- if quest completed, delay finish text by 2 seconds
-- (delayed, so that it doesn't over-take the orange text completely)
if actionidStorageValue == explorationCount then
local playerID = player:getId()
addEvent(function(playerID, explorationText)
local player = Player(playerID)
if not player then
return true
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have finished exploring\n" .. explorationText .. "!")
end, 2000)
end
return true
end