Hello guys 
I really hope you can help me on this one. I've spent so much time on debugging but without any success.
So here's my problem with loading map attributes on startup.
Canary has a file called map_attributes_loader.lua which is being loaded on startup to set up action ids, unique ids, .. and so on..
this was working for me in the beginning. one day it stopped working and since that day im trying to solve the issue.
At first i started printing out if every category is loaded map_attributes_loader.lua
console output:
there are some errors but my Id's im testing (dead trees for black knight quest) only have set the action id and no unique id. this is the part of the script in chest.lua:
it's all about unique id 5006 and 5007 right now. I have searched the map for those unique id's but they are free.
Ive also tried changing my map to the original otservbr map and it worked initially. then i restarted a few times and it did not work anymore.
So i started debugging the function loadLuaMapUnique() in functions.php and printed all the ids which are available in ChestUnique and saw my id's were missing in ChestUnique. However some of them are set correctly and some of then not. this is the code and the result:
If you take a look at the result the lowest id you can see is 5017. but it should be 5000. somehow some of the entries in ChestUnique are missing when looping through them on startup.
I have no idea why there is such a strange behaviour on setting those unique ids.
Hopefully someone can help me out with that. this is driving me crazy

I really hope you can help me on this one. I've spent so much time on debugging but without any success.
So here's my problem with loading map attributes on startup.
Canary has a file called map_attributes_loader.lua which is being loaded on startup to set up action ids, unique ids, .. and so on..
this was working for me in the beginning. one day it stopped working and since that day im trying to solve the issue.
At first i started printing out if every category is loaded map_attributes_loader.lua
LUA:
local function loadMapActionsAndUniques()
print("Chest Action")
loadLuaMapAction(ChestAction)
print("Chest Unique")
loadLuaMapUnique(ChestUnique)
print("Corpse Action")
loadLuaMapAction(CorpseAction)
print("Corpse Unique")
loadLuaMapUnique(CorpseUnique)
print("Door Action")
loadLuaMapAction(KeyDoorAction)
print("LevelDoorAction")
loadLuaMapAction(LevelDoorAction)
print("DoorAction")
loadLuaMapAction(QuestDoorAction)
print("QuestDoorUnique")
loadLuaMapUnique(QuestDoorUnique)
print("Item Action")
loadLuaMapAction(ItemAction)
print("Item Unique")
loadLuaMapUnique(ItemUnique)
print("Item Unmovable Action")
loadLuaMapAction(ItemUnmovableAction)
print("Lever Action")
loadLuaMapAction(LeverAction)
print("Lever Unique")
loadLuaMapUnique(LeverUnique)
print("Teleport Action")
loadLuaMapAction(TeleportAction)
print("Teleport Unique")
loadLuaMapUnique(TeleportUnique)
print("Teleport Item Action")
loadLuaMapAction(TeleportItemAction)
print("Teleport Item Unique")
loadLuaMapUnique(TeleportItemUnique)
print("Tile Action")
loadLuaMapAction(TileAction)
print("Tile Unique")
loadLuaMapUnique(TileUnique)
print("Tile Pick Action")
loadLuaMapAction(TilePickAction)
print("Create Item On Map")
CreateMapItem(CreateItemOnMap)
print("Quest Keys Update")
updateKeysStorage(QuestKeysUpdate)
end
console output:
Code:
Chest Action
Chest Unique
[2024-03-09 22:22:49.193] [error] [loadLuaMapUnique] - Wrong item id 2472 found
[2024-03-09 22:22:49.193] [warning] Unique id: 6013, position ( 32171, 32197, 7 )
Corpse Action
Corpse Unique
Door Action
LevelDoorAction
DoorAction
QuestDoorUnique
Item Action
[2024-03-09 22:22:49.205] [error] [loadLuaMapAction] - Wrong item id 12725 found
[2024-03-09 22:22:49.205] [warning] Action id: 40005, position ( 32080, 32183, 8 )
Item Unique
[2024-03-09 22:22:49.207] [error] [loadLuaMapUnique] - Wrong item id 12764 found
[2024-03-09 22:22:49.207] [warning] Unique id: 40048, position ( 32058, 32132, 10 )
Item Unmovable Action
Lever Action
Lever Unique
Teleport Action
Teleport Unique
Teleport Item Action
Teleport Item Unique
Tile Action
[2024-03-09 22:22:49.213] [error] [loadLuaMapAction] - Wrong item id 417 found
[2024-03-09 22:22:49.214] [warning] Action id: 50336, position ( 32096, 32191, 8 )
[2024-03-09 22:22:49.214] [error] [loadLuaMapAction] - Wrong item id 417 found
[2024-03-09 22:22:49.215] [warning] Action id: 50340, position ( 32085, 32145, 10 )
[2024-03-09 22:22:49.215] [error] [loadLuaMapAction] - Wrong item id 4515 found
[2024-03-09 22:22:49.215] [warning] Action id: 50342, position ( 32088, 32147, 6 )
[2024-03-09 22:22:49.216] [error] [loadLuaMapAction] - Wrong item id 352 found
[2024-03-09 22:22:49.216] [warning] Action id: 50344, position ( 32059, 32135, 10 )
[2024-03-09 22:22:49.217] [error] [loadLuaMapAction] - Wrong item id 8230 found
[2024-03-09 22:22:49.219] [warning] Action id: 50315, position ( 32096, 32194, 7 )
[2024-03-09 22:22:49.219] [error] [loadLuaMapAction] - Wrong item id 499 found
[2024-03-09 22:22:49.220] [warning] Action id: 50348, position ( 32146, 32187, 9 )
[2024-03-09 22:22:49.220] [error] [loadLuaMapAction] - Wrong item id 870 found
[2024-03-09 22:22:49.220] [warning] Action id: 50319, position ( 32091, 32169, 7 )
[2024-03-09 22:22:49.221] [error] [loadLuaMapAction] - Wrong item id 417 found
[2024-03-09 22:22:49.221] [warning] Action id: 50354, position ( 32108, 32190, 8 )
[2024-03-09 22:22:49.222] [error] [loadLuaMapAction] - Wrong item id 194 found
[2024-03-09 22:22:49.222] [warning] Action id: 50356, position ( 31986, 32158, 7 )
[2024-03-09 22:22:49.223] [error] [loadLuaMapAction] - Wrong item id 194 found
[2024-03-09 22:22:49.223] [warning] Action id: 50358, position ( 31977, 32151, 7 )
[2024-03-09 22:22:49.224] [error] [loadLuaMapAction] - Wrong item id 870 found
[2024-03-09 22:22:49.224] [warning] Action id: 50335, position ( 32096, 32200, 7 )
[2024-03-09 22:22:49.225] [error] [loadLuaMapAction] - Wrong item id 8230 found
[2024-03-09 22:22:49.225] [warning] Action id: 50337, position ( 32089, 32157, 9 )
[2024-03-09 22:22:49.225] [error] [loadLuaMapAction] - Wrong item id 417 found
[2024-03-09 22:22:49.226] [warning] Action id: 50339, position ( 32080, 32146, 10 )
[2024-03-09 22:22:49.227] [error] [loadLuaMapAction] - Wrong item id 870 found
[2024-03-09 22:22:49.227] [warning] Action id: 50316, position ( 32101, 32204, 7 )
[2024-03-09 22:22:49.228] [error] [loadLuaMapAction] - Wrong item id 353 found
[2024-03-09 22:22:49.228] [warning] Action id: 50345, position ( 32059, 32136, 9 )
[2024-03-09 22:22:49.229] [error] [loadLuaMapAction] - Wrong item id 4515 found
[2024-03-09 22:22:49.229] [warning] Action id: 50351, position ( 32065, 32156, 7 )
[2024-03-09 22:22:49.229] [error] [loadLuaMapAction] - Wrong item id 194 found
[2024-03-09 22:22:49.230] [warning] Action id: 50357, position ( 31976, 32151, 7 )
[2024-03-09 22:22:49.230] [error] [loadLuaMapAction] - Wrong item id 194 found
[2024-03-09 22:22:49.230] [warning] Action id: 50355, position ( 31968, 32148, 7 )
[2024-03-09 22:22:49.231] [error] [loadLuaMapAction] - Wrong item id 355 found
[2024-03-09 22:22:49.231] [warning] Action id: 50353, position ( 31999, 32142, 7 )
[2024-03-09 22:22:49.232] [error] [loadLuaMapAction] - Wrong item id 353 found
[2024-03-09 22:22:49.232] [warning] Action id: 50359, position ( 31977, 32149, 8 )
Tile Unique
[2024-03-09 22:22:49.235] [error] [loadLuaMapUnique] - Wrong item id 385 found
[2024-03-09 22:22:49.235] [warning] Unique id: 25024, position ( 32138, 32132, 7 )
Tile Pick Action
Create Item On Map
Quest Keys Update
there are some errors but my Id's im testing (dead trees for black knight quest) only have set the action id and no unique id. this is the part of the script in chest.lua:
LUA:
ChestAction = {
--[[
-- Example of usage
[5000] = {
itemId = xxxx,
itemPos = {
{x = xxxxx, y = xxxxx, z = x},
{x = xxxxx, y = xxxxx, z = x}
},
action = xxxx,
reward = {{xxxx, 1}},
storage = storage
},]]
-- Keys quest
[5000] = {
itemId = false,
itemPos = {
{ x = 33057, y = 31029, z = 7 },
{ x = 33055, y = 31029, z = 7 },
{ x = 33053, y = 31029, z = 7 },
},
},
-- The New Frontier Quest
[5001] = { -- Reward Outfit
itemId = 5862,
itemPos = {
{ x = 33053, y = 31020, z = 7 },
},
},
-- Key 5010 (dead tree black knight quest)
[5002] = {
isKey = true,
itemId = 3634,
itemPos = {
{ x = 32813, y = 31964, z = 7 },
{ x = 32800, y = 31959, z = 7 },
},
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID5010,
},
}
ChestUnique = {
-- Keys quest
-- data\scripts\actions\system\quest_reward_key.lua
-- Deeper fibula quest key 3496
[5000] = {
isKey = true,
itemId = 387,
itemPos = { x = 32219, y = 32401, z = 10 },
reward = { { 2972, 1 } },
storage = Storage.Quest.Key.ID3980,
},
-- Panpipe quest key 3791
[5001] = {
isKey = true,
itemId = 1777,
itemPos = { x = 32652, y = 32107, z = 7 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID4055,
},
-- Dawnport quest key 0010 chest
[5002] = {
isKey = true,
itemId = 2434,
itemPos = { x = 32068, y = 31895, z = 3 },
reward = { { 21392, 1 } },
storage = Storage.Quest.Key.ID0010,
},
-- Emperor's cookies quest
[5003] = { -- key 3800
isKey = true,
itemId = 2472,
itemPos = { x = 32605, y = 31908, z = 3 },
reward = { { 2970, 1 } },
storage = Storage.Quest.Key.ID3800,
},
-- Emperor's cookies quest
[5004] = { -- bag with cookies and key 3801
isKey = true,
itemId = 2472,
itemPos = { x = 32648, y = 31905, z = 3 },
container = 2853,
reward = { { 2970, 1 }, { 3598, 27 } },
weight = 12.00,
storage = Storage.Quest.U6_1.EmperorsCookies.Rewards.Cookies,
keyAction = Storage.Quest.Key.ID3801,
},
-- Emperor's cookies quest
[5005] = { -- key 3802
isKey = true,
itemId = 2472,
itemPos = { x = 32599, y = 31923, z = 6 },
reward = { { 2970, 1 } },
storage = Storage.Quest.Key.ID3802,
},
-- Black knight quest key 5010
[5006] = {
isKey = true,
itemId = 3634,
itemPos = { x = 32800, y = 31959, z = 7 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID5010,
},
[5007] = {
isKey = true,
itemId = 3634,
itemPos = { x = 32813, y = 31964, z = 7 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID5010,
},
[5008] = {
isKey = true,
itemId = 2472,
itemPos = { x = 32201, y = 31571, z = 10 },
container = 2853,
reward = { { 2970, 1 }, { 3031, 23 }, { 3147, 1 }, { 3298, 4 }, { 3384, 1 } },
weight = 80.00,
storage = Storage.Quest.Key.ID4502,
keyAction = Storage.Quest.Key.ID4502,
},
[5009] = {
isKey = true,
itemId = 2434,
itemPos = { x = 32411, y = 32155, z = 15 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID3620,
},
[5010] = {
isKey = true,
itemId = 2434,
itemPos = { x = 32411, y = 32155, z = 15 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID3620,
},
[5011] = {
isKey = true,
itemId = 3634,
itemPos = { x = 32497, y = 31887, z = 7 },
reward = { { 2970, 1 } },
storage = Storage.Quest.Key.ID3899,
},
[5012] = {
isKey = true,
itemId = 23740,
itemPos = { x = 33377, y = 31321, z = 1 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID0909,
timerStorage = Storage.TheSecretLibrary.FalconBastionChestsTimer.Key0909,
time = 24, -- hour
},
-- Bear Room Quest (rookgaard) key 4601
[5013] = {
isKey = true,
itemId = 2472,
itemPos = { x = 32150, y = 32112, z = 12 },
reward = { { 2970, 1 } },
storage = Storage.Quest.Key.ID4601,
},
-- Katana Quest (rookgaard) key 4603
[5014] = {
isKey = true,
itemId = 4240,
itemPos = { x = 32176, y = 32132, z = 9 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID4603,
},
-- Key 3600
[5015] = {
isKey = true,
itemId = 4285,
itemPos = { x = 32509, y = 32181, z = 13 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID3600,
},
-- Key 3667
[5016] = {
isKey = true,
itemId = 3204,
itemPos = { x = 32576, y = 32216, z = 15 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID3667,
},
-- Key 3610
[5017] = {
isKey = true,
itemId = 387,
itemPos = { x = 32589, y = 32100, z = 14 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID3610,
},
-- Key 3520
[5018] = {
isKey = true,
itemId = 2473,
itemPos = { x = 32376, y = 31802, z = 7 },
reward = { { 2973, 1 } },
storage = Storage.Quest.Key.ID3520,
},
-- Key 3301 (outlaw camp key 1)
[5019] = {
isKey = true,
itemId = 3634,
itemPos = { x = 32617, y = 32250, z = 7 },
reward = { { 2970, 1 } },
storage = Storage.Quest.Key.ID3301,
},
-- Key 3302 (outlaw camp key 2)
[5020] = {
isKey = true,
itemId = 3634,
itemPos = { x = 32609, y = 32244, z = 7 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID3302,
},
-- Key 3303 (outlaw camp key 3)
[5021] = {
isKey = true,
itemId = 3634,
itemPos = { x = 32651, y = 32244, z = 7 },
reward = { { 2970, 1 } },
storage = Storage.Quest.Key.ID3303,
},
-- Key 3304 (outlaw camp key 4)
[5022] = {
isKey = true,
itemId = 2472,
itemPos = { x = 32623, y = 32187, z = 9 },
reward = { { 2972, 1 } },
storage = Storage.Quest.Key.ID3304,
},
-- Key 3008 (Draconia Quest)
[5023] = {
isKey = true,
itemId = 2435,
itemPos = { x = 32800, y = 31582, z = 2 },
reward = { { 2969, 1 } },
storage = Storage.Quest.Key.ID3008,
},
-- The Pits of Inferno - Key 3700
[5024] = {
isKey = true,
itemId = 2472,
itemPos = { x = 32842, y = 32225, z = 8 },
reward = { { 2971, 1 } },
storage = Storage.Quest.Key.ID3700,
},
-- and so on....
}
it's all about unique id 5006 and 5007 right now. I have searched the map for those unique id's but they are free.
Ive also tried changing my map to the original otservbr map and it worked initially. then i restarted a few times and it did not work anymore.
So i started debugging the function loadLuaMapUnique() in functions.php and printed all the ids which are available in ChestUnique and saw my id's were missing in ChestUnique. However some of them are set correctly and some of then not. this is the code and the result:
LUA:
function loadLuaMapUnique(tablename)
-- It load uniques
for index, value in pairs(tablename) do
local tile = Tile(value.itemPos)
local item
print("index=" .. index .. " value=" .. value.itemId)
-- Checks if the position is valid
if tile then
-- Checks that you have no items created
if not value.itemId == false and tile:getItemCountById(value.itemId) == 0 then
logger.error("[loadLuaMapUnique] - Wrong item id {} found", value.itemId)
logger.warn("Unique id: {}, position {}", index, tile:getPosition():toString())
break
end
if tile:getItemCountById(value.itemId) < 1 or value.itemId == false then
logger.warn("[loadLuaMapUnique] - Wrong item id {} found", value.itemId)
logger.warn("Unique id: {}, position {}, item id: wrong", index, tile:getPosition():toString())
break
end
item = tile:getItemById(value.itemId)
-- If he found the item, add the unique id
if item then
item:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, index)
end
end
end
end
Code:
index=6069 value=4024
index=5017 value=387
index=14017 value=24875
index=6241 value=2480
index=6006 value=4240
index=6145 value=2469
index=6177 value=2469
index=6102 value=2469
index=6134 value=2469
index=6273 value=2469
index=6038 value=2469
index=6070 value=2469
index=5018 value=2473
index=14019 value=24877
index=6242 value=2469
index=6007 value=2472
index=6146 value=2472
index=6178 value=2473
index=6103 value=2473
index=6135 value=2472
index=6274 value=2433
index=6039 value=2473
index=6071 value=2469
index=5019 value=3634
index=14021 value=2478
index=6243 value=2433
index=6008 value=4024
index=6147 value=2472
index=6179 value=2472
index=6104 value=2472
index=6136 value=2472
index=6275 value=2434
index=6040 value=2473
index=5020 value=3634
index=14023 value=2478
index=6244 value=1983
index=6009 value=4024
index=6148 value=2472
index=6180 value=4285
index=6105 value=23741
index=6137 value=2472
index=6276 value=2434
index=6041 value=2469
index=6073 value=2469
index=5021 value=3634
index=14025 value=2472
index=6245 value=2433
index=6010 value=4240
index=6149 value=2469
index=14091 value=2472
index=6106 value=23740
index=6138 value=2472
index=6277 value=2434
index=6042 value=2469
index=6074 value=2469
index=5022 value=2472
index=14027 value=2472
index=6246 value=2473
index=6011 value=4025
index=6150 value=2469
index=6182 value=9226
index=6107 value=23741
index=6139 value=2472
index=6278 value=1987
index=6043 value=2469
index=6075 value=2472
index=5023 value=2435
index=14029 value=2473
index=6247 value=2433
index=6012 value=4240
index=6151 value=2473
index=6183 value=1983
index=6108 value=23741
index=6140 value=2480
index=6279 value=4024
index=6044 value=2469
index=5024 value=2472
index=6216 value=2523
index=14031 value=2473
index=6248 value=2473
index=6013 value=2472
[2024-03-09 22:42:34.992] [error] [loadLuaMapUnique] - Wrong item id 2472 found
[2024-03-09 22:42:34.993] [warning] Unique id: 6013, position ( 32171, 32197, 7 )
If you take a look at the result the lowest id you can see is 5017. but it should be 5000. somehow some of the entries in ChestUnique are missing when looping through them on startup.
I have no idea why there is such a strange behaviour on setting those unique ids.
Hopefully someone can help me out with that. this is driving me crazy