Aggressively inline all uses of _G

This commit is contained in:
Emik 2026-06-19 19:01:57 +02:00
parent 7d4198efbd
commit 18e763be35
Signed by: emik
GPG key ID: 6B0CD72A5E503BDF
8 changed files with 57 additions and 39 deletions

View file

@ -65,4 +65,8 @@
"unused-local": "Error", "unused-local": "Error",
"unused-vararg": "Error", "unused-vararg": "Error",
}, },
"Lua.runtime.version": "LuaJIT",
"Lua.workspace.library": [
"${3rd}/love2d/library"
],
} }

View file

@ -3,7 +3,7 @@
"id": "Roland", "id": "Roland",
"name": "Roland", "name": "Roland",
"prefix": "Roland", "prefix": "Roland",
"version": "2.9.12", "version": "2.9.13",
"badge_colour": "8BE9FD", "badge_colour": "8BE9FD",
"display_name": "Roland", "display_name": "Roland",
"main_file": "src/main.lua", "main_file": "src/main.lua",

View file

@ -27,9 +27,8 @@ local back = (function()
tbl.atlas = "back" tbl.atlas = "back"
x = x + 1 x = x + 1
local back = q(SMODS.Back(tbl)) local back = q(SMODS.Back(tbl))
local sleeve = (_G["CardSleeves"] or {}).Sleeve
local _ = sleeve and sleeve { local _ = CardSleeves and CardSleeves.Sleeve {
key = key, key = key,
pos = tbl.pos, pos = tbl.pos,
atlas = "sleeve", atlas = "sleeve",
@ -61,7 +60,7 @@ SMODS.Atlas {
py = 95, py = 95,
} }
local _ = _G["CardSleeves"] and SMODS.Atlas { local _ = CardSleeves and SMODS.Atlas {
key = "sleeve", key = "sleeve",
path = "sleeve.png", path = "sleeve.png",
px = 73, px = 73,

View file

@ -476,15 +476,15 @@ local venerable_visage = blind {
vitriol = function(b) vitriol = function(b)
local vitriol = SMODS.Mods.Roland.config.vitriol local vitriol = SMODS.Mods.Roland.config.vitriol
local resize_to_w, resize_to_h = 320, 200 local resize_to_w, resize_to_h = 320, 200
local is_fullscreen = _G["love"].window.getFullscreen() local is_fullscreen = love.window.getFullscreen()
if vitriol then if vitriol then
_G["love"].window.setFullscreen(false) love.window.setFullscreen(false)
delay(1.5) delay(1.5)
end end
local function jitter() local function jitter()
local x, y = _G["love"].window.getDesktopDimensions() local x, y = love.window.getDesktopDimensions()
return pseudorandom(pseudoseed "RolandVenerableVisageX", 0, x) - x / 2, return pseudorandom(pseudoseed "RolandVenerableVisageX", 0, x) - x / 2,
pseudorandom(pseudoseed "RolandVenerableVisageY", 0, y) - y / 2 pseudorandom(pseudoseed "RolandVenerableVisageY", 0, y) - y / 2
@ -512,15 +512,16 @@ local venerable_visage = blind {
play_sound("gong", v) play_sound("gong", v)
end) end)
---@type number, number, table
local w, h, flags = love.window.getMode()
local len = #G.playing_cards local len = #G.playing_cards
local w, h, flags = _G["love"].window.getMode()
if vitriol then if vitriol then
_G["love"].window.setMode(resize_to_w, resize_to_h) love.window.setMode(resize_to_w, resize_to_h)
_G["love"].resize(resize_to_w, resize_to_h) love.resize(resize_to_w, resize_to_h)
end end
local x, y = _G["love"].window.getPosition() local x, y = love.window.getPosition()
f(G.playing_cards):each(function(v, i) f(G.playing_cards):each(function(v, i)
q { q {
@ -529,7 +530,7 @@ local venerable_visage = blind {
func = function() func = function()
if vitriol then if vitriol then
local x_random, y_random = jitter() local x_random, y_random = jitter()
_G["love"].window.setPosition(x + x_random * i / len, y + y_random * i / len) love.window.setPosition(x + x_random * i / len, y + y_random * i / len)
end end
v:start_dissolve() v:start_dissolve()
@ -543,10 +544,10 @@ local venerable_visage = blind {
trigger = "before", trigger = "before",
delay = 1.5, delay = 1.5,
func = function() func = function()
_G["love"].window.setPosition(x, y) love.window.setPosition(x, y)
_G["love"].window.setMode(w, h, flags) love.window.setMode(w, h, flags)
_G["love"].resize(w, h) love.resize(w, h)
_G["love"].window.setFullscreen(is_fullscreen) love.window.setFullscreen(is_fullscreen)
end, end,
} }

View file

@ -1,19 +1,8 @@
---@meta ---@meta
---@alias Attributes "mult"|"chips"|"xmult"|"xchips"|"score"|"xscore"|"blindsize"|"xblindsize"|"balance"|"swap"|"retrigger"|"scaling"|"reset"|"suit"|"diamonds"|"hearts"|"spades"|"clubs"|"hand_type"|"rank"|"ace"|"two"|"three"|"four"|"five"|"six"|"seven"|"eight"|"nine"|"ten"|"jack"|"queen"|"king"|"face"|"economy"|"generation"|"destroy_card"|"hands"|"discard"|"hand_size"|"chance"|"joker_slot"|"mod_chance"|"copying"|"full_deck"|"passive"|"joker"|"tarot"|"planet"|"spectral"|"enhancements"|"seals"|"editions"|"tag"|"skip"|"modify_card"|"perma_bonus"|"prevents_death"|"boss_blind"|"reroll"|"on_sell"|"sell_value"|"food"|"space"|"bakery_double_sided"|"bakery_usable"|"bakery_werewolf" ---@alias Attributes "mult"|"chips"|"xmult"|"xchips"|"score"|"xscore"|"blindsize"|"xblindsize"|"balance"|"swap"|"retrigger"|"scaling"|"reset"|"suit"|"diamonds"|"hearts"|"spades"|"clubs"|"hand_type"|"rank"|"ace"|"two"|"three"|"four"|"five"|"six"|"seven"|"eight"|"nine"|"ten"|"jack"|"queen"|"king"|"face"|"economy"|"generation"|"destroy_card"|"hands"|"discard"|"hand_size"|"chance"|"joker_slot"|"mod_chance"|"copying"|"full_deck"|"passive"|"joker"|"tarot"|"planet"|"spectral"|"enhancements"|"seals"|"editions"|"tag"|"skip"|"modify_card"|"perma_bonus"|"prevents_death"|"boss_blind"|"reroll"|"on_sell"|"sell_value"|"food"|"space"|"bakery_double_sided"|"bakery_usable"|"bakery_werewolf"
SMODS.Mods.Roland.config = require "config"
---@type Card[] ---@type Card[]
CardArea.cards = CardArea.cards CardArea.cards = CardArea.cards
---@type userdata|{getWidth: fun(self: self): number}
SMODS.Atlas.image_data = SMODS.Atlas.image_data
--- @type { constants?: { TEN: table }, new: (fun(self: self, arr?: number[], sign?: number, noNormalize?: boolean): table), pow: (fun(x: number, y: number): number) }
_G["Big"] = _G["Big"]
--- @type fun(area: CardArea, ...: ...): Card
create_card_for_shop = create_card_for_shop
--- @overload fun(tbl: SMODS.Joker): SMODS.GameObject --- @overload fun(tbl: SMODS.Joker): SMODS.GameObject
Bakery_API.Charm = Bakery_API.Charm Bakery_API.Charm = Bakery_API.Charm
@ -24,6 +13,32 @@ function Bakery_API.credit(obj)
error(obj) error(obj)
end end
---@type table
Balatest = Balatest
--- @type { constants?: { TEN: table }, new: (fun(self: self, arr?: number[], sign?: number, noNormalize?: boolean): table), pow: (fun(x: number, y: number): number) }
Big = Big
--- @type table
CardSleeves = CardSleeves
--- @type fun(obj: SMODS.Back): SMODS.Back
CardSleeves.Sleeve = CardSleeves.Sleeve
--- @type fun(area: CardArea, ...: ...): Card
create_card_for_shop = create_card_for_shop
SMODS.Mods.Roland.config = require "config"
---@type userdata|{getWidth: fun(self: self): number}
SMODS.Atlas.image_data = SMODS.Atlas.image_data
--- @type table
Talisman = Talisman
--- @type fun(obj: any): number
to_number = to_number
-- This exists to remove the @deprecated warning. -- This exists to remove the @deprecated warning.
---Returns the elements from the given `list`. This function is equivalent to ---Returns the elements from the given `list`. This function is equivalent to
---```lua ---```lua

View file

@ -21,14 +21,13 @@ local function protect_ev(fun)
return Event { return Event {
blocking = false, blocking = false,
no_delete = true, no_delete = true,
func = function() func = protect(function()
if not Bakery_API or not Bakery_API.credit then if not Bakery_API or not Bakery_API.credit then
return false return false
end end
Bakery_API.credit(fun) Bakery_API.credit(fun)
return true end),
end,
} }
else else
fun.func = protect(fun.func or fun[1]) fun.func = protect(fun.func or fun[1])

View file

@ -63,7 +63,7 @@ f {"challenge", "spectral", "edition", "tweaks", "blind", "charm", "joker", "tar
assert(SMODS.load_file("src/" .. v .. ".lua"))(qol) assert(SMODS.load_file("src/" .. v .. ".lua"))(qol)
end) end)
if _G["Balatest"] then if Balatest then
f {"joker", "blind", "spectral"}:each(function(v) f {"joker", "blind", "spectral"}:each(function(v)
assert(SMODS.load_file("src/tests/" .. v .. ".tests.lua"))(qol) assert(SMODS.load_file("src/tests/" .. v .. ".tests.lua"))(qol)
end) end)
@ -107,7 +107,7 @@ function SMODS.current_mod.config_tab()
toggle "equinox_assist", toggle "equinox_assist",
SMODS.Mods.DebugPlus and toggle "import_funky", SMODS.Mods.DebugPlus and toggle "import_funky",
G.P_CENTERS.c_Bakery_Scribe and toggle "scribable_basket", G.P_CENTERS.c_Bakery_Scribe and toggle "scribable_basket",
_G["Talisman"] and toggle "harsh_ante_scaling", Talisman and toggle "harsh_ante_scaling",
}, },
}}, }},
} }

View file

@ -94,11 +94,11 @@ local orig_get_blind_amount = get_blind_amount
---@param ante number ---@param ante number
---@return table|number ---@return table|number
local function blind(ante) local function blind(ante)
return ante == 39 and 1e294 or (_G["to_number"] or f.id)(orig_get_blind_amount(ante)) return ante == 39 and 1e294 or (to_number or f.id)(orig_get_blind_amount(ante))
end end
local function no_harsh_ante_scaling() local function no_harsh_ante_scaling()
return not _G["Talisman"] or not SMODS.Mods.Roland.config.harsh_ante_scaling return not Talisman or not SMODS.Mods.Roland.config.harsh_ante_scaling
end end
function get_blind_amount(ante, ...) function get_blind_amount(ante, ...)
@ -112,10 +112,10 @@ function get_blind_amount(ante, ...)
return 1 / 0 return 1 / 0
end end
local big, rem = _G["Big"], tonumber(blind((ante % loop) + 1)) local rem = tonumber(blind((ante % loop) + 1))
return ante / 15 >= loop and big:new(f(blind(ante - (loop * 15))):map(f.const(10)):table()) or return ante / 15 >= loop and Big:new(f(blind(ante - (loop * 15))):map(f.const(10)):table()) or
(ante / 9 >= loop and big:new(f(ante / loop - 8):map(f.const(10)):concat {rem}:table()) or (ante / 9 >= loop and Big:new(f(ante / loop - 8):map(f.const(10)):concat {rem}:table()) or
(ante / 2 >= loop and big:new {rem, ante / loop} or (ante / 2 >= loop and Big:new {rem, ante / loop} or
(big.constants and big.constants.TEN or big:new {10}):pow(rem))) (Big.constants and Big.constants.TEN or Big:new {10}):pow(rem)))
end end