Skip to content

Commit

Permalink
Merge pull request #3 from Leoc76101111/ZEWX-HORDE-OVERHAUL
Browse files Browse the repository at this point in the history
Integrate alfred
  • Loading branch information
Letrico authored Nov 13, 2024
2 parents 4e64ced + 9991461 commit 275c92f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
2 changes: 1 addition & 1 deletion core/task_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions tasks/alfred.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 275c92f

Please sign in to comment.