Aggressively inline all uses of _G
This commit is contained in:
parent
7d4198efbd
commit
18e763be35
8 changed files with 57 additions and 39 deletions
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
|
@ -65,4 +65,8 @@
|
|||
"unused-local": "Error",
|
||||
"unused-vararg": "Error",
|
||||
},
|
||||
"Lua.runtime.version": "LuaJIT",
|
||||
"Lua.workspace.library": [
|
||||
"${3rd}/love2d/library"
|
||||
],
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
"id": "Roland",
|
||||
"name": "Roland",
|
||||
"prefix": "Roland",
|
||||
"version": "2.9.12",
|
||||
"version": "2.9.13",
|
||||
"badge_colour": "8BE9FD",
|
||||
"display_name": "Roland",
|
||||
"main_file": "src/main.lua",
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@ local back = (function()
|
|||
tbl.atlas = "back"
|
||||
x = x + 1
|
||||
local back = q(SMODS.Back(tbl))
|
||||
local sleeve = (_G["CardSleeves"] or {}).Sleeve
|
||||
|
||||
local _ = sleeve and sleeve {
|
||||
local _ = CardSleeves and CardSleeves.Sleeve {
|
||||
key = key,
|
||||
pos = tbl.pos,
|
||||
atlas = "sleeve",
|
||||
|
|
@ -61,7 +60,7 @@ SMODS.Atlas {
|
|||
py = 95,
|
||||
}
|
||||
|
||||
local _ = _G["CardSleeves"] and SMODS.Atlas {
|
||||
local _ = CardSleeves and SMODS.Atlas {
|
||||
key = "sleeve",
|
||||
path = "sleeve.png",
|
||||
px = 73,
|
||||
|
|
|
|||
|
|
@ -476,15 +476,15 @@ local venerable_visage = blind {
|
|||
vitriol = function(b)
|
||||
local vitriol = SMODS.Mods.Roland.config.vitriol
|
||||
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
|
||||
_G["love"].window.setFullscreen(false)
|
||||
love.window.setFullscreen(false)
|
||||
delay(1.5)
|
||||
end
|
||||
|
||||
local function jitter()
|
||||
local x, y = _G["love"].window.getDesktopDimensions()
|
||||
local x, y = love.window.getDesktopDimensions()
|
||||
|
||||
return pseudorandom(pseudoseed "RolandVenerableVisageX", 0, x) - x / 2,
|
||||
pseudorandom(pseudoseed "RolandVenerableVisageY", 0, y) - y / 2
|
||||
|
|
@ -512,15 +512,16 @@ local venerable_visage = blind {
|
|||
play_sound("gong", v)
|
||||
end)
|
||||
|
||||
---@type number, number, table
|
||||
local w, h, flags = love.window.getMode()
|
||||
local len = #G.playing_cards
|
||||
local w, h, flags = _G["love"].window.getMode()
|
||||
|
||||
if vitriol then
|
||||
_G["love"].window.setMode(resize_to_w, resize_to_h)
|
||||
_G["love"].resize(resize_to_w, resize_to_h)
|
||||
love.window.setMode(resize_to_w, resize_to_h)
|
||||
love.resize(resize_to_w, resize_to_h)
|
||||
end
|
||||
|
||||
local x, y = _G["love"].window.getPosition()
|
||||
local x, y = love.window.getPosition()
|
||||
|
||||
f(G.playing_cards):each(function(v, i)
|
||||
q {
|
||||
|
|
@ -529,7 +530,7 @@ local venerable_visage = blind {
|
|||
func = function()
|
||||
if vitriol then
|
||||
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
|
||||
|
||||
v:start_dissolve()
|
||||
|
|
@ -543,10 +544,10 @@ local venerable_visage = blind {
|
|||
trigger = "before",
|
||||
delay = 1.5,
|
||||
func = function()
|
||||
_G["love"].window.setPosition(x, y)
|
||||
_G["love"].window.setMode(w, h, flags)
|
||||
_G["love"].resize(w, h)
|
||||
_G["love"].window.setFullscreen(is_fullscreen)
|
||||
love.window.setPosition(x, y)
|
||||
love.window.setMode(w, h, flags)
|
||||
love.resize(w, h)
|
||||
love.window.setFullscreen(is_fullscreen)
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,8 @@
|
|||
---@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"
|
||||
SMODS.Mods.Roland.config = require "config"
|
||||
|
||||
---@type Card[]
|
||||
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
|
||||
Bakery_API.Charm = Bakery_API.Charm
|
||||
|
||||
|
|
@ -24,6 +13,32 @@ function Bakery_API.credit(obj)
|
|||
error(obj)
|
||||
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.
|
||||
---Returns the elements from the given `list`. This function is equivalent to
|
||||
---```lua
|
||||
|
|
|
|||
|
|
@ -21,14 +21,13 @@ local function protect_ev(fun)
|
|||
return Event {
|
||||
blocking = false,
|
||||
no_delete = true,
|
||||
func = function()
|
||||
func = protect(function()
|
||||
if not Bakery_API or not Bakery_API.credit then
|
||||
return false
|
||||
end
|
||||
|
||||
Bakery_API.credit(fun)
|
||||
return true
|
||||
end,
|
||||
end),
|
||||
}
|
||||
else
|
||||
fun.func = protect(fun.func or fun[1])
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ f {"challenge", "spectral", "edition", "tweaks", "blind", "charm", "joker", "tar
|
|||
assert(SMODS.load_file("src/" .. v .. ".lua"))(qol)
|
||||
end)
|
||||
|
||||
if _G["Balatest"] then
|
||||
if Balatest then
|
||||
f {"joker", "blind", "spectral"}:each(function(v)
|
||||
assert(SMODS.load_file("src/tests/" .. v .. ".tests.lua"))(qol)
|
||||
end)
|
||||
|
|
@ -107,7 +107,7 @@ function SMODS.current_mod.config_tab()
|
|||
toggle "equinox_assist",
|
||||
SMODS.Mods.DebugPlus and toggle "import_funky",
|
||||
G.P_CENTERS.c_Bakery_Scribe and toggle "scribable_basket",
|
||||
_G["Talisman"] and toggle "harsh_ante_scaling",
|
||||
Talisman and toggle "harsh_ante_scaling",
|
||||
},
|
||||
}},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,11 +94,11 @@ local orig_get_blind_amount = get_blind_amount
|
|||
---@param ante number
|
||||
---@return table|number
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
function get_blind_amount(ante, ...)
|
||||
|
|
@ -112,10 +112,10 @@ function get_blind_amount(ante, ...)
|
|||
return 1 / 0
|
||||
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
|
||||
(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
|
||||
(big.constants and big.constants.TEN or big:new {10}):pow(rem)))
|
||||
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 / 2 >= loop and Big:new {rem, ante / loop} or
|
||||
(Big.constants and Big.constants.TEN or Big:new {10}):pow(rem)))
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue