settings now save on a per-char basis #2

Open
matix wants to merge 2 commits from matix/recast:master into master
  1. 26
      recast.lua

26
recast.lua

@ -47,7 +47,7 @@ local default_config =
}; };
local recast_config = default_config; local recast_config = default_config;
local SCHJP = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; local SCHJP = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
local logged = false;
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
-- func: color_recast_entry -- func: color_recast_entry
-- desc: Colors a recast entry based on the time left to use it.. -- 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. -- desc: Event called when the addon is being loaded.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
ashita.register_event('load', function() ashita.register_event('load', function()
-- Attempt to load the fps configuration.. -- Attempt to load the configuration..
recast_config = ashita.settings.load_merged(_addon.path .. 'settings/settings.json', recast_config); 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.. -- Create our font object..
local f = AshitaCore:GetFontManager():Create('__recast_addon'); local f = AshitaCore:GetFontManager():Create('__recast_addon');
@ -117,7 +121,7 @@ ashita.register_event('unload', function()
recast_config.font.position = { f:GetPositionX(), f:GetPositionY() }; recast_config.font.position = { f:GetPositionX(), f:GetPositionY() };
-- Save the configuration.. -- 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.. -- Unload our font object..
AshitaCore:GetFontManager():Delete('__recast_addon'); AshitaCore:GetFontManager():Delete('__recast_addon');
@ -235,6 +239,18 @@ ashita.register_event('incoming_packet', function(id, size, data)
end end
return false; return false;
end 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; return false;
end); end);
Loading…
Cancel
Save