diff --git a/core/settings.lua b/core/settings.lua index 94744d0..15f301f 100644 --- a/core/settings.lua +++ b/core/settings.lua @@ -24,6 +24,7 @@ local settings = { use_salvage_filter_toggle = false, affix_salvage_count = 0, greater_affix_count = 0, + use_alfred = false, } function settings:update_settings() @@ -48,6 +49,7 @@ function settings:update_settings() settings.use_salvage_filter_toggle = gui.elements.use_salvage_filter_toggle:get() settings.affix_salvage_count = gui.elements.affix_salvage_count:get() settings.greater_affix_count = gui.elements.greater_affix_count:get() + settings.use_alfred = gui.elements.use_alfred:get() end return settings \ No newline at end of file diff --git a/core/task_manager.lua b/core/task_manager.lua index b3b37e1..01c04f6 100644 --- a/core/task_manager.lua +++ b/core/task_manager.lua @@ -45,7 +45,7 @@ function task_manager.get_current_task() return current_task end -local task_files = { "town_salvage" , "walking_to_horde", "open_chests" , "exit_horde" ,"start_dungeon", "enter_horde", "horde" } +local task_files = { "alfred", "town_salvage" , "walking_to_horde", "open_chests" , "exit_horde" ,"start_dungeon", "enter_horde", "horde" } for _, file in ipairs(task_files) do local task = require("tasks." .. file) task_manager.register_task(task) diff --git a/gui.lua b/gui.lua index 3db3caa..974bc0f 100644 --- a/gui.lua +++ b/gui.lua @@ -46,6 +46,7 @@ gui.elements = { affix_salvage_count = slider_int:new(0, 3, 1, get_hash(plugin_label .. "affix_salvage_count")), -- 0 is a default value movement_spell_to_objective = create_checkbox(true, "movement_spell_to_objective"), use_evade_as_movement_spell = create_checkbox(true, "use_evade_as_movement_spell"), + use_alfred = create_checkbox(false, "use_alfred") } function gui.render() @@ -75,6 +76,12 @@ function gui.render() gui.elements.affix_salvage_count:render("Min No. affixes to keep", "Minimum number of matching affixes to keep") end end + if PLUGIN_alfred_the_butler then + local alfred_status = PLUGIN_alfred_the_butler.get_status() + if alfred_status.enabled then + gui.elements.use_alfred:render("Use alfred", "use alfred to manage town tasks") + end + end -- Updated chest type selector to use the new enum structure gui.elements.chest_type_selector:render("Chest Type", gui.chest_types_options, "Select the type of chest to open") if not gui.elements.salvage_toggle:get() then diff --git a/tasks/alfred.lua b/tasks/alfred.lua new file mode 100644 index 0000000..8a48d99 --- /dev/null +++ b/tasks/alfred.lua @@ -0,0 +1,52 @@ +local plugin_label = "infernal_horde" -- change to your plugin name + +local settings = require 'core.settings' +-- need use_alfred to enable +-- settings.use_alfred = true + +local status_enum = { + IDLE = 'idle', + WAITING = 'waiting for alfred to complete', +} +local task = { + name = 'alfred_running', -- change to your choice of task name + status = status_enum['IDLE'] +} + +local function reset() + PLUGIN_alfred_the_butler.pause(plugin_label) + -- add more stuff here if you need to do something after alfred is done + task.status = status_enum['IDLE'] +end + +function task.shouldExecute() + if settings.use_alfred and PLUGIN_alfred_the_butler then + local status = PLUGIN_alfred_the_butler.get_status() + -- add additional conditions to trigger if required + if status.enabled and + status.inventory_full and + (status.sell_count > 0 or status.salvage_count > 0) + then + return true + elseif task.status == status_enum['WAITING'] then + return true + end + end + return false +end + +function task.Execute() + if task.status == status_enum['IDLE'] then + PLUGIN_alfred_the_butler.resume() + -- PLUGIN_alfred_the_butler.trigger_tasks(plugin_label,reset) + PLUGIN_alfred_the_butler.trigger_tasks_with_teleport(plugin_label,reset) + task.status = status_enum['WAITING'] + end +end + +if settings.enabled and settings.use_alfred and PLUGIN_alfred_the_butler then + -- do an initial reset + reset() +end + +return task \ No newline at end of file