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