Skip to content

Commit 2f0729a

Browse files
committed
fix challenge unlock counter
1 parent dfc5cba commit 2f0729a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lovely/challenge.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,41 @@ challenge_unlocked = challenge_unlocked or G.PROFILES[G.SETTINGS.profile].all_un
2020
"""
2121
match_indent = true
2222

23+
# function G.UIDEF.challenges() - fix challenge unlock count
24+
[[patches]]
25+
[patches.pattern]
26+
target = "functions/UI_definitions.lua"
27+
pattern = """
28+
function G.UIDEF.challenges(from_game_over)
29+
"""
30+
position = 'after'
31+
payload = """
32+
local unlock_count = 0
33+
"""
34+
match_indent = true
35+
36+
# function G.UIDEF.challenges() - fix challenge unlock count p2
37+
[[patches]]
38+
[patches.pattern]
39+
target = "functions/UI_definitions.lua"
40+
pattern = """
41+
local _ch_tab = {comp = _ch_comp, unlocked = G.PROFILES[G.SETTINGS.profile].challenges_unlocked}
42+
"""
43+
position = 'at'
44+
payload = """
45+
for k, v in ipairs(G.CHALLENGES) do
46+
if (v.unlocked and type(v.unlocked) == 'function' and v:unlocked())
47+
or (v.unlocked == true)
48+
or (G.PROFILES[G.SETTINGS.profile].all_unlocked)
49+
or (not v.unlocked and (_ch_comp+5 <= k)) then
50+
unlock_count = unlock_count + 1
51+
end
52+
end
53+
54+
local _ch_tab = {comp = _ch_comp, unlocked = unlock_count or G.PROFILES[G.SETTINGS.profile].challenges_unlocked}
55+
"""
56+
match_indent = true
57+
2358
# Add button colour
2459
[[patches]]
2560
[patches.pattern]

0 commit comments

Comments
 (0)