diff --git a/logic/player_npc.lua b/logic/player_npc.lua index bc47d5f..5dae6e1 100644 --- a/logic/player_npc.lua +++ b/logic/player_npc.lua @@ -46,18 +46,18 @@ MTSL_LOGIC_PLAYER_NPC = { -- try and load the player local current_player = MTSL_PLAYERS[realm][name] + local return_code = "none" + -- Player was saved before, so load it if current_player then current_player = MTSL_PLAYERS[realm][name] - if MTSLUI_SAVED_VARIABLES:GetShowWelcomeMessage() == 1 then - print(MTSLUI_FONTS.COLORS.TEXT.SUCCESS .. "MTSL: " .. current_player.NAME .. " (" .. current_player.XP_LEVEL .. ", " .. current_player.FACTION .. ") on " .. current_player.REALM .. " loaded") - end - -- Update class, faction & xp_level, just in case MTSL_CURRENT_PLAYER.CLASS = string.lower(player_class) MTSL_CURRENT_PLAYER.XP_LEVEL = xp_level MTSL_CURRENT_PLAYER.FACTION = faction + + return_code = "existing" -- new player so create it and add it else -- Not found so create a new one @@ -69,13 +69,12 @@ MTSL_LOGIC_PLAYER_NPC = { CLASS = player_class, TRADESKILLS = {}, } - -- Get additional player info to save - print(MTSLUI_FONTS.COLORS.TEXT.WARNING .. "MTSL: Saving new player: " .. current_player.NAME .. " (" .. current_player.XP_LEVEL .. ", " .. current_player.FACTION .. ") on " .. current_player.REALM) - print(MTSLUI_FONTS.COLORS.TEXT.WARNING .. "MTSL: Please open all profession windows to save skills") -- new player added so sort the table (first the realms, then for new realm, sort by name MTSL_PLAYERS[realm][name] = current_player MTSL_TOOLS:SortArray(MTSL_PLAYERS) MTSL_TOOLS:SortArrayByProperty(MTSL_PLAYERS[realm], "name") + + return_code = "new" end -- set the loaded or created player as current one @@ -85,7 +84,7 @@ MTSL_LOGIC_PLAYER_NPC = { self:RemoveUnlearnedProfessions() self:UpdatePlayerSkillLevels() - return "none" + return return_code end, ------------------------------------------------------------------------------------------------ diff --git a/ui/event_handler.lua b/ui/event_handler.lua index 61c2a32..bb5d992 100644 --- a/ui/event_handler.lua +++ b/ui/event_handler.lua @@ -17,8 +17,8 @@ MTSLUI_EVENT_HANDLER = { if MTSLUI_TOOLS:SetAddonLocale() then -- load the data for the player local error_loading_player = MTSL_LOGIC_PLAYER_NPC:LoadPlayer() - if error_loading_player ~= "none" then - print(MTSLUI_FONTS.COLORS.TEXT.ERROR .. "MTSL: Could not load player info (Empty " .. error_loading_player .." ..! Try reloading this addon") + if error_loading_player ~= "new" and error_loading_player ~= "existing" then + print(MTSLUI_FONTS.COLORS.TEXT.ERROR .. "MTSL: Could not load player info (Empty " .. error_loading_player .."! Try reloading this addon") self.addon_loaded = 0 else -- Initialise the minimap button @@ -47,6 +47,14 @@ MTSLUI_EVENT_HANDLER = { if MTSLUI_SAVED_VARIABLES:GetShowWelcomeMessage() == 1 then print(MTSLUI_FONTS.COLORS.TEXT.TITLE .. MTSLUI_ADDON.NAME .. MTSLUI_FONTS.COLORS.TEXT.NORMAL .. " (by " .. MTSLUI_ADDON.AUTHOR .. ")" .. MTSLUI_FONTS.COLORS.TEXT.TITLE .. " v" .. MTSLUI_ADDON.VERSION .. " loaded!") print(MTSLUI_FONTS.COLORS.TEXT.TITLE .."MTSL: Using data for phase " .. MTSL_DATA.CURRENT_PATCH_LEVEL .. " (" .. MTSL_LOGIC_WORLD:GetZoneNameById(MTSL_DATA.PHASE_IDS[MTSL_DATA.CURRENT_PATCH_LEVEL]) .. ")") + if error_loading_player == "existing" then + print(MTSLUI_FONTS.COLORS.TEXT.SUCCESS .. "MTSL: " .. MTSL_CURRENT_PLAYER.NAME .. " (" .. MTSL_CURRENT_PLAYER.XP_LEVEL .. ", " .. MTSL_CURRENT_PLAYER.FACTION .. ") on " .. MTSL_CURRENT_PLAYER.REALM .. " loaded") + end + if error_loading_player == "new" then + -- Get additional player info to save + print(MTSLUI_FONTS.COLORS.TEXT.WARNING .. "MTSL: New character: " .. MTSL_CURRENT_PLAYER.NAME .. " (" .. MTSL_CURRENT_PLAYER.XP_LEVEL .. ", " .. MTSL_CURRENT_PLAYER.FACTION .. ") on " .. MTSL_CURRENT_PLAYER.REALM) + print(MTSLUI_FONTS.COLORS.TEXT.WARNING .. "MTSL: Please open all profession windows to save skills!") + end end self.addon_loaded = 1 diff --git a/ui/global_variables.lua b/ui/global_variables.lua index d31e562..aad418d 100644 --- a/ui/global_variables.lua +++ b/ui/global_variables.lua @@ -6,7 +6,7 @@ MTSLUI_ADDON = { AUTHOR = "Thumbkin", NAME = "Missing TradeSkills List (TBC)", - VERSION = "2.5.02", + VERSION = "2.5.03", SERVER_VERSION_PHASES = { -- max build number from server for phase 1, {