From 2d1d34409352b12c9166beb3e72779970e157112 Mon Sep 17 00:00:00 2001 From: matix Date: Thu, 6 Dec 2018 23:51:21 -0800 Subject: [PATCH 1/2] settings now save on a per-char basis --- recast.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recast.lua b/recast.lua index 9d35874..f4c6acc 100644 --- a/recast.lua +++ b/recast.lua @@ -92,7 +92,7 @@ end ---------------------------------------------------------------------------------------------------- ashita.register_event('load', function() -- Attempt to load the fps configuration.. - recast_config = ashita.settings.load_merged(_addon.path .. 'settings/settings.json', recast_config); + recast_config = ashita.settings.load_merged(_addon.path .. 'settings/' .. AshitaCore:GetDataManager():GetParty():GetMemberName(0) .. '.settings.json', recast_config); -- Create our font object.. local f = AshitaCore:GetFontManager():Create('__recast_addon'); @@ -117,7 +117,7 @@ ashita.register_event('unload', function() recast_config.font.position = { f:GetPositionX(), f:GetPositionY() }; -- Save the configuration.. - ashita.settings.save(_addon.path .. 'settings/settings.json', recast_config); + ashita.settings.save(_addon.path .. 'settings/' .. AshitaCore:GetDataManager():GetParty():GetMemberName(0) .. '.settings.json', recast_config); -- Unload our font object.. AshitaCore:GetFontManager():Delete('__recast_addon'); -- 2.41.0.windows.1 From 1faddc2012781ae249638a3df3a2ca95413c16b5 Mon Sep 17 00:00:00 2001 From: matix Date: Fri, 7 Dec 2018 02:36:06 -0800 Subject: [PATCH 2/2] added login/player name detection --- recast.lua | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/recast.lua b/recast.lua index f4c6acc..f5f6acb 100644 --- a/recast.lua +++ b/recast.lua @@ -47,7 +47,7 @@ local default_config = }; local recast_config = default_config; local SCHJP = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - +local logged = false; --------------------------------------------------------------------------------------------------- -- func: color_recast_entry -- desc: Colors a recast entry based on the time left to use it.. @@ -91,8 +91,12 @@ end -- desc: Event called when the addon is being loaded. ---------------------------------------------------------------------------------------------------- ashita.register_event('load', function() - -- Attempt to load the fps configuration.. - recast_config = ashita.settings.load_merged(_addon.path .. 'settings/' .. AshitaCore:GetDataManager():GetParty():GetMemberName(0) .. '.settings.json', recast_config); + -- Attempt to load the configuration.. + local party = AshitaCore:GetDataManager():GetParty(); + if (party:GetMemberServerId(0) ~= false) then + logged = true; + recast_config = ashita.settings.load_merged(_addon.path .. 'settings/' .. party:GetMemberName(0) .. '.settings.json', recast_config); + end -- Create our font object.. local f = AshitaCore:GetFontManager():Create('__recast_addon'); @@ -235,6 +239,18 @@ ashita.register_event('incoming_packet', function(id, size, data) end return false; end - + -- on login/logoff from atom0s @ https://forums.ashitaxi.com/viewtopic.php?f=17&t=240 + if (id == 0x000A) then + if (logged == false) then + logged = true; + recast_config = ashita.settings.load_merged(_addon.path .. 'settings/' .. struct.unpack('s', data, 0x84 + 1) .. '.settings.json', recast_config); + end + end + if (id == 0x000B) then + local flag = struct.unpack('b', data, 0x04 + 1); + if (flag) then + logged = false; + end + end return false; end); \ No newline at end of file -- 2.41.0.windows.1