Hi, I've started working on an addon that revamps the Teleport dialog and the HearthStone dialog to fix those inconsistent map names.
Example: Dead Thicket, Lightwood should be Lightwood, Dead Thicket .... First the map name and then the zone
I have the code part for the locations list done:
Code:
function normalizeLocationName(name)
local maps = {
"Novograd",
"Lightwood",
"Siveria",
"Frozen Frontier",
"Darkwater",
"Tenebra",
"Asee-Teph",
"Eljune",
"Coba Plateau"
};
for i, mapName in pairs(maps) do
local pos = string.find(name, mapName);
if pos and pos > 1 then
return mapName .. ", " .. string.sub(name, 1, pos - 3);
end
end
return name;
end
-------------------------------------------------------------------------------
function getSortedLocations()
local locations = {};
local avatarTpLocations = avatar.GetTeleportLocations()
for id, objectId in avatarTpLocations do
local info = avatar.GetTeleportLocationInfo(objectId)
if info then
table.insert(locations, {
id = info.id,
name = normalizeLocationName(userMods.FromWString(info.name))
});
end
end
table.sort(locations, function (a,
return a.name < b.name;
end);
return locations;
end
I also cleared the list of locations (populated by the script). The problem is I don't have the widget resource object to be able to call:
Code:
mainForm:CreateWidgetByDesc( wtTeleportButtonDesc )
I would use the one already defined by the game but I couldn't do it because it isn't named. Can anyone help me with this?
PS: I learned the LUA programming language so that isn't a problem. The allods API is giving me a hard time.