Skip to content

Commit

Permalink
fix settings not clearing on AP connect; add achievement setting auto…
Browse files Browse the repository at this point in the history
…tracking; add deathlink setting autotracking
  • Loading branch information
nbrochu committed Oct 7, 2023
1 parent 6d31599 commit 40ac6d9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 10 deletions.
Binary file added images/settings/deathlink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions items/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,11 @@
"type": "toggle",
"img": "/images/settings/achievements_all.png",
"codes": "achievements_all"
},
{
"name": "Deathlink",
"type": "toggle",
"img": "/images/settings/deathlink.png",
"codes": "deathlink"
}
]
28 changes: 28 additions & 0 deletions layouts/deathlink.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"deathlink_layout": {
"type": "array",
"orientation": "vertical",
"margin": "0,0",
"content": [
{
"type": "array",
"orientation": "vertical",
"margin": "0,0",
"content": [
{
"type": "itemgrid",
"item_size": "4, 4",
"item_margin": "2, 2",
"item_h_alignment": "center",
"h_alignment": "left",
"rows": [
[
"deathlink"
]
]
}
]
}
]
}
}
12 changes: 12 additions & 0 deletions layouts/tracker.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
"key": "achievements_layout"
}
},
{
"type": "group",
"header": "Deathlink",
"dock": "left",
"margin": "0,0,3,0",
"content": {
"type": "layout",
"h_alignment": "center",
"v_alignment": "center",
"key": "deathlink_layout"
}
},
{
"type": "group",
"header": "Progression Items",
Expand Down
50 changes: 40 additions & 10 deletions scripts/autotracking/archipelago.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ function onClear(slotData)
end

-- Reset Settings
Tracker:FindObjectForCode("goal_mechanical_bosses").Active = false
Tracker:FindObjectForCode("goal_plantera").Active = false
Tracker:FindObjectForCode("goal_golem").Active = false
Tracker:FindObjectForCode("goal_empress_of_light").Active = false
Tracker:FindObjectForCode("goal_lunatic_cultist").Active = false
Tracker:FindObjectForCode("goal_moon_lord").Active = false
Tracker:FindObjectForCode("goal_zenith").Active = false

if slotData['goal'] then
local goalValue = slotData['goal'][1]
local goalTrackerKey = nil
Expand All @@ -64,22 +72,44 @@ function onClear(slotData)
goalTrackerKey = "goal_moon_lord"
elseif goalValue == "Zenith" then
goalTrackerKey = "goal_zenith"
else
return
end

local goalTrackerObject = Tracker:FindObjectForCode(goalTrackerKey)
if goalTrackerKey then
local goalTrackerObject = Tracker:FindObjectForCode(goalTrackerKey)
goalTrackerObject.Active = true
end
end

Tracker:FindObjectForCode("achievements_none").Active = false
Tracker:FindObjectForCode("achievements_exclude_fishing").Active = false
Tracker:FindObjectForCode("achievements_exclude_grindy").Active = false
Tracker:FindObjectForCode("achievements_all").Active = false

if slotData['achievements'] then
local achievementValue = slotData['achievements']
local achievementTrackerKey = nil

if achievementValue == 0 then
achievementTrackerKey = "achievements_none"
elseif achievementValue == 1 then
achievementTrackerKey = "achievements_exclude_grindy"
elseif achievementValue == 2 then
achievementTrackerKey = "achievements_exclude_fishing"
elseif achievementValue == 3 then
achievementTrackerKey = "achievements_all"
end

goalTrackerObject.Active = true
if achievementTrackerKey then
local achievementTrackerObject = Tracker:FindObjectForCode(achievementTrackerKey)
achievementTrackerObject.Active = true
end
end

-- if slotData['achievements'] then
-- Wait until this is stored in slot data to know how to handle it
-- For now, force all achievements on and let the user switch the setting manually if needed
local achievementTrackerObject = Tracker:FindObjectForCode("achievements_all")
Tracker:FindObjectForCode("deathlink").Active = false

achievementTrackerObject.Active = true
-- end
if slotData['deathlink'] == true then
Tracker:FindObjectForCode("deathlink").Active = true
end
end


Expand Down
1 change: 1 addition & 0 deletions scripts/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Tracker:AddLocations("locations/locations.json")
Tracker:AddLayouts("layouts/tabs.json")
Tracker:AddLayouts("layouts/goals.json")
Tracker:AddLayouts("layouts/achievements.json")
Tracker:AddLayouts("layouts/deathlink.json")
Tracker:AddLayouts("layouts/items.json")

Tracker:AddLayouts("layouts/tracker.json")
Expand Down

0 comments on commit 40ac6d9

Please sign in to comment.