Skip to content

Commit 978e370

Browse files
committed
Use SMODS.challenge_is_unlocked()
1 parent 42f446c commit 978e370

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

lovely/challenge.toml

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,26 @@ priority = -5
88
[patches.pattern]
99
target = "functions/UI_definitions.lua"
1010
pattern = "local challenge_unlocked = G.PROFILES[G.SETTINGS.profile].challenges_unlocked and (G.PROFILES[G.SETTINGS.profile].challenges_unlocked >= k)"
11-
position = 'after'
12-
payload = """
13-
if v.unlocked and type(v.unlocked) == 'function' then
14-
challenge_unlocked = v:unlocked()
15-
elseif type(v.unlocked) == 'boolean' then
16-
challenge_unlocked = v.unlocked
17-
end
18-
challenge_unlocked = challenge_unlocked or G.PROFILES[G.SETTINGS.profile].all_unlocked
19-
20-
"""
11+
position = 'at'
12+
payload = "local challenge_unlocked = SMODS.challenge_is_unlocked(v, k)"
2113
match_indent = true
2214

2315
# function G.UIDEF.challenges() - fix challenge unlock count
2416
[[patches]]
2517
[patches.pattern]
2618
target = "functions/UI_definitions.lua"
2719
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 = """
4120
local _ch_tab = {comp = _ch_comp, unlocked = G.PROFILES[G.SETTINGS.profile].challenges_unlocked}
4221
"""
4322
position = 'at'
4423
payload = """
24+
local unlock_count = 0
4525
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
26+
if SMODS.challenge_is_unlocked(v, k) then
5027
unlock_count = unlock_count + 1
5128
end
5229
end
53-
54-
local _ch_tab = {comp = _ch_comp, unlocked = unlock_count or G.PROFILES[G.SETTINGS.profile].challenges_unlocked}
30+
local _ch_tab = {comp = _ch_comp, unlocked = unlock_count}
5531
"""
5632
match_indent = true
5733

0 commit comments

Comments
 (0)