-
Notifications
You must be signed in to change notification settings - Fork 2
Patching the Game
We will use lovely-injector to inject our code into the game. Why should you patch the game over just modifying its code? Because:
- It makes using multiple mods at once easier.
- It makes adding, removing and distributing mods easier.
- You won't have to remake your mod every update (patch mods might still break, but it's easier to fix them).
We will start by creating a folder called lovely inside our mod folder. This folder will contain our patches. After that we will create a .toml file for our patch, the name can be anything.
At the top of the .toml file you need to put a manifest. You can copy the format below:
[manifest]
version = "1.0.0"
dump_lua = true
priority = 0version does nothing, you can ignore it.
dump_lua decides whether the changed files should be saved inside %Appdata%/beatblock/Mods/lovely. This is useful for debugging so leave it as true.
priority decides the order of the patch to load, higher priority patches are loaded first. Change this only if your patches are loading in the wrong order.
lovely-injector has a lot of types of patches, but to keep the guide short I will only explain pattern and copy patching. These 2 will be the most useful ones.
A pattern match looks for a pattern in the code and injects code before, at or after it.
You can see an example below:
[[patches]]
[patches.pattern]
target = "preload/states.lua"
pattern = '''bs.new('Keybinds')'''
position = "after"
payload = '''
bs.new('Mods', "Mods/beatblock-plus/mod-loader/")
'''
match_indent = trueHere, it searches through the Beatblock's preload/states.lua file to find bs.new('Keybinds'). Once it's found it adds bs.new('Mods', "Mods/beatblock-plus/mod-loader/") after it. Pretty simple.
A copy patch prepends or appends a whole .lua file to a file in the game. You can see an example below:
[[patches]]
[patches.copy]
target = "states/Mods.lua"
position = "prepend"
sources = ["mod-loader/Mods.lua"]Here, it copies the contents of mod-loader/Mods.lua and prepends it to the contents of the states/Mods.lua file of Beatblock. If no such file exists, it creates a new one.
If you would like to learn more about lovely-injector. Check out their GitHub repo: https://github.com/ethangreen-dev/lovely-injector
Click to join the Beatblock Modding Discord Server
For users:
For Mod Developers: