Skip to content

Commit

Permalink
Merge branch 'main' into quantum_enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
MathIsFun0 committed Dec 23, 2024
2 parents 0dc91f0 + a83b581 commit 7f28169
Show file tree
Hide file tree
Showing 21 changed files with 297 additions and 285 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Introduction

Steamodded is a mod loader and injector for the game Balatro. Much like the [LÖVE2D engine](https://love2d.org/wiki/Main_Page) itself, it is built using [Lua](https://www.lua.org/). It is made with modularity and extensibility in mind, providing a large selection of APIs and other features to facilitate bringing your ideas to life.
Steamodded is a mod loader and injector for the game Balatro. Much like the [LÖVE framework](https://love2d.org/wiki/Main_Page) itself, it is built using [Lua](https://www.lua.org/). It is made with modularity and extensibility in mind, providing a large selection of APIs and other features to facilitate bringing your ideas to life.

## Installation

Expand Down
14 changes: 9 additions & 5 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
# Documentation
## To do
- Stake
- Seal


- Challenge
- Sticker
- DeckSkin

## In progress
- Enhancement

## Done

- Achievement
- Atlas
- Center (Joker, Consumable, Voucher, Back)
- Center (Joker, Consumable, Voucher, Back, Booster)
- Blind
- ConsumableType
- ObjectType
- UndiscoveredSprite
- Edition
- Language
- Sound
- Stake
- PokerHand
- Suit
- Rank
- Seal
- Sticker
- Rarity
- Tag
4 changes: 2 additions & 2 deletions example_mods/Mods/EditionExamples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Again, you'd have to write it yourself.

## Working with Shaders
[ionized.fs](assets/shaders/ionized.fs) has shader code explanation with comments.
For a general guide, look at [LOVE2D introduction to shaders](https://blogs.love2d.org/content/beginners-guide-shaders).
For a general guide, look at [LÖVE introduction to shaders](https://blogs.love2d.org/content/beginners-guide-shaders).

If you want to see vanilla Balatro shaders, unzip the Balatro.exe and go to `resources/shaders` folder.

Expand All @@ -34,4 +34,4 @@ To see values for default externs, check out `engine/sprite.lua` -> `Sprite:draw
- [Inigo Quilez articles](https://iquilezles.org/articles/) - in-depth articles on algorithms and techniques you could use in shaders. A lot of those are for 3D, but there's some 2D stuff as well.
- [Shadertoy](https://www.shadertoy.com) - tons of shaders from other people to learn from. A lot of them are pretty complex and 3D, but you can find simple 2D ones.

Note: in all resources the language is slightly different from LOVE2D shaders language, but the logic works the same way.
Note: in all resources the language is slightly different from LÖVE shaders language, but the logic works the same way.
12 changes: 6 additions & 6 deletions lovely/blind.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ end'''
[[patches]]
[patches.pattern]
target = 'blind.lua'
pattern = 'return disp_text'
position = 'before'
pattern = 'function Blind:get_loc_debuff_text()'
position = 'after'
match_indent = true
payload = '''
local obj = self.config.blind
if obj.get_loc_debuff_text and type(obj.get_loc_debuff_text) == 'function' then
return obj:get_loc_debuff_text()
end'''
local obj = self.config.blind
if obj.get_loc_debuff_text and type(obj.get_loc_debuff_text) == 'function' then
return obj:get_loc_debuff_text()
end'''

# Blind:set_text()
[[patches]]
Expand Down
10 changes: 9 additions & 1 deletion lovely/blind_ui.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,12 @@ pattern = '''
[\t ]*G\.GAME\.blind:juice_up\(\)'''
position = 'at'
payload = 'SMODS.juice_up_blind()'
line_prepend = '$indent'
line_prepend = '$indent'

# remove statically added 1 from The Wheel's collection description
[[patches]]
[patches.regex]
target = 'functions/UI_definitions.lua'
pattern = '''\(k ==1 and blind\.name == 'The Wheel' and '1' or ''\)\.\.'''
position = 'at'
payload = ''
42 changes: 42 additions & 0 deletions lovely/center.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ payload = '''
if _c.locked_loc_vars and type(_c.locked_loc_vars) == 'function' then
local res = _c:locked_loc_vars(info_queue) or {}
loc_vars = res.vars or {}
specific_vars = specific_vars or {}
specific_vars.not_hidden = res.not_hidden or specific_vars.not_hidden
elseif $rest'''

Expand Down Expand Up @@ -443,3 +444,44 @@ local obj = self.config.center
if obj.calc_dollar_bonus and type(obj.calc_dollar_bonus) == 'function' then
return obj:calc_dollar_bonus(self)
end'''

# Card:draw()
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '--If the card has any edition/seal, add that here'
position = 'before'
match_indent = true
payload = '''
local center = self.config.center
if center.draw and type(center.draw) == 'function' then
center:draw(self, layer)
end
if center.set == 'Default' or center.set == 'Enhanced' and not center.replace_base_card then
if not center.no_suit then
local suit = SMODS.Suits[self.base.suit] or {}
if suit.draw and type(suit.draw) == 'function' then
suit:draw(self, layer)
end
end
if not center.no_rank then
local rank = SMODS.Ranks[self.base.value] or {}
if rank.draw and type(rank.draw) == 'function' then
rank:draw(self, layer)
end
end
end
'''

[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = 'if self.seal then'
position = 'at'
match_indent = true
payload = '''
local seal = G.P_SEALS[self.seal or {}] or {}
if type(seal.draw) == 'function' then
seal:draw(self, layer)
elseif self.seal then
'''
10 changes: 7 additions & 3 deletions lovely/edition.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ payload = '''
if self.edition then
for k, v in pairs(G.P_CENTER_POOLS.Edition) do
if self.edition[v.key:sub(3)] and v.shader then
self.children.center:draw_shader(v.shader, nil, self.ARGS.send_to_shader)
if self.children.front and self.ability.effect ~= 'Stone Card' and not self.config.center.replace_base_card then
self.children.front:draw_shader(v.shader, nil, self.ARGS.send_to_shader)
if type(v.draw) == 'function' then
v:draw(self, layer)
else
self.children.center:draw_shader(v.shader, nil, self.ARGS.send_to_shader)
if self.children.front and self.ability.effect ~= 'Stone Card' and not self.config.center.replace_base_card then
self.children.front:draw_shader(v.shader, nil, self.ARGS.send_to_shader)
end
end
end
end
Expand Down
66 changes: 66 additions & 0 deletions lovely/fixes.toml
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,69 @@ pattern = """G.GAME.current_round.reroll_cost = math.max(0, G.GAME.current_round
position = 'at'
match_indent = true
payload = """G.GAME.current_round.reroll_cost = math.max(0, G.GAME.current_round.reroll_cost - center_table.extra)"""


# Add h_chips as a viable hand effect
[[patches]]
[patches.pattern]
target = 'functions/state_events.lua'
pattern = '''card_eval_status_text(G.hand.cards[i], 'h_mult', effects[ii].h_mult, percent)
end'''
position = 'after'
match_indent = true
payload = '''
if effects[ii].h_chips then
if effects[ii].card then juice_card(effects[ii].card) end
hand_chips = mod_chips(hand_chips + effects[ii].h_chips)
update_hand_text({delay = 0}, {chips = hand_chips})
card_eval_status_text(effects[ii].card, 'chips', effects[ii].h_chips, percent)
end
'''

# Fixes Steam API not loading on unix
[[patches]]
[patches.pattern]
target = 'main.lua'
match_indent = true
position = 'after'
pattern = '--To control when steam communication happens, make sure to send updates to steam as little as possible'
payload = '''local cwd = NFS.getWorkingDirectory()
NFS.setWorkingDirectory(love.filesystem.getSourceBaseDirectory())
'''

[[patches]]
[patches.pattern]
target = 'main.lua'
match_indent = true
position = 'before'
pattern = '--Set up the render window and the stage for the splash screen, then enter the gameloop with :update'
payload = '''NFS.setWorkingDirectory(cwd)
'''

[[patches]]
[patches.pattern]
target = "main.lua"
pattern = '''if os == 'OS X' or os == 'Windows' then'''
position = "at"
payload = '''if os == 'OS X' or os == 'Windows' or os == 'Linux' then'''
overwrite = true
match_indent = true

[[patches]]
[patches.pattern]
target = "main.lua"
pattern = '''if os == 'OS X' then'''
position = "at"
payload = '''if os == 'OS X' or os == 'Linux' then'''
overwrite = true
match_indent = true

[[patches]]
[patches.pattern]
target = "main.lua"
pattern = "st = require 'luasteam'"
position = "at"
payload = """local success, _st = pcall(require, 'luasteam')
if success then st = _st end"""
overwrite = true
match_indent = true
9 changes: 4 additions & 5 deletions lovely/keybind.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ match_indent = true
overwrite = false

[[patches]]
[patches.pattern]
[patches.regex]
target = 'engine/controller.lua'
pattern = 'if key == "r" and not G.SETTINGS.paused then'
pattern = 'if key == "r"'
position = 'at'
match_indent = true
line_prepend = '$indent'
payload = '''
if key == 'm' then
if self.held_key_times[key] > 1.1 then
Expand All @@ -44,5 +44,4 @@ if key == 'm' then
else
self.held_key_times[key] = self.held_key_times[key] + dt
end
elseif key == "r" and not G.SETTINGS.paused then
'''
elseif key == "r"'''
19 changes: 19 additions & 0 deletions lovely/language.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ position = 'at'
payload = "self.localization = assert(loadstring(love.filesystem.read('localization/'..G.SETTINGS.language..'.lua') or love.filesystem.read('localization/en-us.lua')))()"
match_indent = true

[[patches]]
[patches.pattern]
target = 'game.lua'
pattern = "self.LANG = self.LANGUAGES[self.SETTINGS.language] or self.LANGUAGES['en-us']"
position = 'at'
payload = "self.LANG = self.LANGUAGES[self.SETTINGS.real_language or self.SETTINGS.language] or self.LANGUAGES['en-us']"
match_indent = true

# G.FUNCS.change_lang

[[patches]]
[patches.pattern]
target = 'functions/button_callbacks.lua'
pattern = "G.SETTINGS.language = lang.key"
position = 'at'
payload = """G.SETTINGS.language = lang.loc_key or lang.key
G.SETTINGS.real_language = lang.key"""
match_indent = true

# G.FUNCS.warn_lang (wtf)
[[patches]]
[patches.pattern]
Expand Down
23 changes: 23 additions & 0 deletions lovely/playing_card.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,26 @@ end
for j = 1, #suit_map do
$mid
(0.42 - (num_suits <= 4 and 0 or num_suits >= 8 and 0.28 or 0.07 * (num_suits - 4))) * G.CARD_H,'''

[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = '--Fill all remaining info if this is the main desc'
position = 'before'
match_indent = true
payload = '''if card_type == 'Default' or card_type == 'Enhanced' and not _c.replace_base_card and card and card.base then
if not _c.no_suit then
local suit = SMODS.Suits[card.base.suit] or {}
if suit.loc_vars and type(suit.loc_vars) == 'function' then
suit:loc_vars(info_queue, card)
end
end
if not _c.no_rank then
local rank = SMODS.Ranks[card.base.value] or {}
if rank.loc_vars and type(rank.loc_vars) == 'function' then
rank:loc_vars(info_queue, card)
end
end
end
'''
2 changes: 1 addition & 1 deletion lovely/seal.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ line_prepend = '$indent'
payload = '''
local obj = G.P_SEALS[self.seal] or {}
if obj.get_p_dollars and type(obj.get_p_dollars) == 'function' then
ret = ret + obj.get_p_dollars(self)
ret = ret + obj:get_p_dollars(self)
elseif $cond'''

# generate_card_ui()
Expand Down
2 changes: 1 addition & 1 deletion lovely/sticker.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ payload = '''
for k, v in pairs(SMODS.Stickers) do
if self.ability[v.key] then
if v and v.draw and type(v.draw) == 'function' then
v:draw(self)
v:draw(self, layer)
else
G.shared_stickers[v.key].role.draw_major = self
G.shared_stickers[v.key]:draw_shader('dissolve', nil, nil, nil, self.children.center)
Expand Down
Loading

0 comments on commit 7f28169

Please sign in to comment.