Lovely 是一个 lua 注入器,它在运行时将代码嵌入到 LÖVE 2d 游戏中。与可执行修补程序不同,模组可以反复安装、更新和删除,而不需要部分或全部游戏重新安装。这是通过进程内 lua API 绕行和易于使用(和分发)的补丁系统来完成的。
lovely-x86_64-pc-windows-msvc.zip
。version.dll
复制到游戏目录中。您可以通过右键单击 Steam 中的游戏,将鼠标悬停在“管理”上,然后选择“浏览本地文件”来导航到游戏的目录。%AppData%/Balatro/Mods
(如果您正在修改 Balatro)。WINEDLLOVERRIDES="version=n,b" %command%
。lovely-aarch64-apple-darwin.tar.gz
。如果你有一个 Intel CPU 那么它会lovely-x86_64-apple-darwin.tar.gz
liblovely.dylib
和run_lovely.sh
复制到游戏目录中。您可以通过右键单击 Steam 中的游戏,将鼠标悬停在“管理”上,然后选择“浏览本地文件”来导航到游戏的目录。/Users/$USER/Library/Application Support/Balatro/Mods
,其中$USER
是您的用户名(如果您正在修改 Balatro)。Shift-Command-.
(句号)在 Finder 中显示隐藏文件。run_lovely.sh
拖放到应用程序 > 实用程序中的Terminal.app
上然后按 Enter 键来运行游戏,或者在游戏目录中的终端中执行sh run_lovely.sh
。注意:由于 Steam 客户端中的错误,您无法在 Mac 上通过 Steam 运行游戏。您必须使用run_lovely.sh
脚本运行它。
重要提示:带有Lovely补丁文件( lovely.toml
或lovely/*.toml
)的Mod必须安装到mod目录中自己的文件夹中。无一例外!
请注意,补丁格式不稳定并且容易发生变化,直到Lovely 结束早期开发为止。
补丁文件定义了游戏进程中代码注入的位置和方式。可以在此处的 Steamodded 存储库中找到一个很好的(复杂的)示例。
[ manifest ]
version = " 1.0.0 "
priority = 0
# Define a var substitution rule. This searches for lines that contain {{lovely:var_name}}
# (var_name from this example, it can really be anything) and replaces each match with the
# provided value.
# This example would transform print('{{lovely:var_name}}') to print('Hello world!').
#
# USEFUL: For when you want to reduce the complexity of repetitive injections, eg. embedding
# release version numbers in multiple locations.
[ vars ]
var_name = " Hello world! "
# Inject one or more lines of code before, after, or at (replacing) a line which matches
# the provided pattern.
#
# USEFUL: For when you need to add / modify a small amount of code to setup initialization
# routines, etc.
[[ patches ]]
[ patches . pattern ]
target = " game.lua "
pattern = " self.SPEEDFACTOR = 1 "
position = " after "
payload = '''
initSteamodded()
print('{{lovely:var_name}}')
'''
match_indent = true
times = 1
# Inject one or more lines of code before, after, at, or interwoven into one or more
# Regex capture groups.
# - I recommend you to use a Regex playground like https://regexr.com to build
# your patterns.
# - Regex is NOT EFFICIENT. Please use the pattern patch unless absolutely necessary.
# - This patch has capture group support.
# - This patch does NOT trim whitespace from each line. Take that into account when
# designing your pattern.
#
# USEFUL: For when the pattern patch is not expressive enough to describe how the
# payload should be injected.
[ patches . regex ]
target = " tag.lua "
pattern = " (?[ t ]*)if (?_context.type == 'eval' then) "
position = ' at '
line_prepend = ' $indent '
payload = '''
local obj = SMODS.Tags[self.key]
local res
if obj and obj.apply and type(obj.apply) == 'function' then
res = obj.apply(self, _context)
end
if res then
return res
elseif $cond
'''
times = 1
# Append or prepend the contents of one or more files onto the target.
#
# USEFUL: For when you *only* care about getting your code into the game, nothing else.
# This does NOT inject it as a new module.
[[ patches ]]
[ patches . copy ]
target = " main.lua "
position = " append "
sources = [
" core/core.lua " ,
" core/deck.lua " ,
" core/joker.lua " ,
" core/sprite.lua " ,
" debug/debug.lua " ,
" loader/loader.lua " ,
]
# Inject a new module into the game *before* a target file it loaded.
# USEFUL: For when you want to silo your code into a separate require-able module OR inject a "global" dependency before game / mod code begins execution.
[[ patches ]]
[ patches . module ]
source = " nativefs.lua "
before = " main.lua "
name = " nativefs "
pattern
补丁将代码外科手术式地嵌入到目标内的特定位置。支持*
(匹配任何字符出现 0 次或多次)和?
(精确匹配任何字符的一次出现)通配符。regex
补丁。这基本上是模式补丁,但带有支持正则表达式查询引擎、捕获组等。copy
补丁。module
补丁将 lua 模块注入游戏的运行时。请注意,目前仅支持单个文件模块,但这应该很快就会改变。补丁文件从 mod 文件夹 ( MOD_DIR
) 内的 mod 目录加载。 Lovely 将加载MOD_DIR/ModName/lovely/
中存在的任何补丁文件,或从MOD_DIR/ModName/lovely.toml
加载单个补丁。如果加载了多个补丁,它们将按照找到的顺序注入到游戏中。
补丁中定义的路径以 mod 的目录为根。例如, core/deck.lua
解析为MOD_DIR/ModName/core/deck.lua
。
每个补丁定义都有一个补丁目标。这些目标是使用 7zip 等工具从游戏中转储时源文件的相对路径。例如,可以定位顶级文件(如main.lua
)或子目录中的文件(如engine/event.lua
。
Lovely 将修补后的 lua 源文件转储到MOD_DIR/lovely/dump
。日志同样写入MOD_DIR/lovely/log
。
manifest.version