-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
87 lines (68 loc) · 2.22 KB
/
main.lua
File metadata and controls
87 lines (68 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
local mod_path = "" .. SMODS.current_mod.path
SMODS.current_mod.badge_colour = SMODS.Gradient {
key = "flame_badge",
colours = {
HEX('B52A2A'),
HEX('6F0C0C'),
},
cycle = 4,
}
SMODS.current_mod.badge_text_colour = SMODS.Gradient {
key = "flame_badge_text",
colours = {
HEX('F5EF4A'),
HEX('D0CA1D'),
},
cycle = 2,
}
SMODS.current_mod.optional_features = function()
return { retrigger_joker = true, cardareas = { discard = true } }
end
for _, f in ipairs(NFS.getDirectoryItems(mod_path .. "lib")) do
assert(SMODS.load_file("lib/" .. f))()
end
-- we're using regtable to force a specific collection order by sorting before registering
local regtable = {}
for _, f in ipairs(NFS.getDirectoryItems(mod_path .. "items")) do
local objs = assert(SMODS.load_file("items/" .. f))() or {}
for _, o in ipairs(objs) do table.insert(regtable, o) end
end
for _, f in ipairs(NFS.getDirectoryItems(mod_path .. "crossmod")) do
local key, _ = string.gsub(f, "%..*$", "")
if next(SMODS.find_mod(key)) or key == "multi" then
local objs = assert(SMODS.load_file("crossmod/" .. f))() or {}
for _, o in ipairs(objs) do
o.order = 10 -- put crossmod jokers at the VERY end
o.pools = o.pools or {}
o.pools.crossmod = true
table.insert(regtable, o)
end
end
end
table.sort(regtable, function(a, b)
-- grouping jokers by global order
if (a.order or 0) < (b.order or 0) then return true end
if (a.order or 0) > (b.order or 0) then return false end
-- put original jokers before reference jokers
if not a.pools and b.pools then return true end
if not b.pools and a.pools then return false end
-- sorting by rarities
-- num/num and str/str can be directly compared
-- otherwise put the vanilla rarity first
if a.rarity ~= b.rarity then
if type(a.rarity) == type(b.rarity) then
return a.rarity < b.rarity
else
return type(a.rarity) == "number"
end
end
-- alphabetical sort
-- since name isnt used, this is a handy way to force subsort order
return string.lower(a.name) < string.lower(b.name)
end)
for _, o in ipairs(regtable) do
SMODS.current_mod.debug_info = o.name
SMODS[o.object_type](o)
SMODS.current_mod.debug_info = nil
end
-- its probably fine to ignore sorting for crossmods