Skip to content

Commit 31f0f5e

Browse files
authored
Update make-a-bg3-mod-with-lua.mdx
1 parent 04d27a4 commit 31f0f5e

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

projects/make-a-bg3-mod-with-lua/make-a-bg3-mod-with-lua.mdx

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tags:
1919
cl="for-sidebar"
2020
/>
2121

22-
## Make a Baldur's Gate 3 Mod With Lua
22+
# Make a Baldur's Gate 3 Mod With Lua
2323

2424
<AuthorAvatar
2525
author_name="Julien Kris"
@@ -37,9 +37,11 @@ tags:
3737
**Prerequisites:** Lua basics, Baldur's Gate 3
3838
**Read Time:** 45 minutes
3939

40-
# Introduction: Companion Creatures
40+
## Introduction: Companion Creatures
4141

42-
[Baldur’s Gate 3](https://en.wikipedia.org/wiki/Baldur%27s_Gate_3) (BG3) is a 2023 RPG by Larian Studios, adapted from Dungeons & Dragons. It's earned over 10 million players due to its expansive worldbuilding, fleshed out characters, and stunning visuals. Anyone who's played knows it features some truly epic battles, with animal allies who fight alongside you, like our best boy, Scratch.
42+
[Baldur’s Gate 3](https://en.wikipedia.org/wiki/Baldur%27s_Gate_3) (BG3) is a 2023 RPG by Larian Studios, adapted from Dungeons & Dragons. It's earned over 10 million players due to its expansive worldbuilding, fleshed out characters, and stunning visuals.
43+
44+
Anyone who's played knows it features some truly epic battles, with animal allies who fight alongside you, like our best boy, Scratch.
4345

4446
<ImageZoom src="https://i.imgur.com/rxAJDtM.png" style={{ width: "80%", height: "auto" }} alt="Scratch"/>
4547

@@ -55,9 +57,10 @@ We're going to do just that by making our own mod!
5557

5658
We’ll create a mod that lets your character cast a spell to spawn their frog friend anywhere. That frog friend is a playable character who can help out during battles!
5759

58-
Since BG3 Lua modding is only supported on Windows, this tutorial is aimed at Windows users. If you're a Mac user, scroll down to our Resources section for some links!
60+
Since BG3 Lua modding is only supported on Windows, this tutorial is aimed at Windows users. If you're a Mac user, scroll down to our Resources section for some links!
5961

6062
By the end of this tutorial, you’ll know how to:
63+
6164
- Write a BG3 mod that lets you summon a custom companion with Lua
6265
- Customize the companion’s stats
6366
- Test your mod in-game
@@ -74,7 +77,9 @@ If you don't already have a code editor installed, download [Visual Studio Code]
7477

7578
**BG3 Script Extender (BG3SE)** is a program created by a developer named @Norbyte that adds Lua scripting and console support to Baldur's Gate 3. Download it from [GitHub](https://github.com/Norbyte/bg3se).
7679

77-
Right click on the downloaded **.zip** file, select [Extract All], and extract the files to a new folder in your **Documents** directory, and name it something like **ModdingTools**. Next to your **ModdingTools** folder, create a new folder called **Mods**.
80+
Right click on the downloaded **.zip** file, select [Extract All], and extract the files to a new folder in your **Documents** directory, and name it something like **ModdingTools**.
81+
82+
Next to your **ModdingTools** folder, create a new folder called **Mods**.
7883

7984
We'll be keeping:
8085

@@ -124,7 +129,9 @@ It contains the following components:
124129

125130
Without this file, the game doesn’t know your mod exists.
126131

127-
A **UUID (Universally Unique Identifier)** is a 128-bit value used to uniquely identify information across systems or databases without significant risk of duplication. It looks something like: `30b78323-c06f-4a66-9767-6241f5ee4656`.
132+
A **UUID (Universally Unique Identifier)** is a 128-bit value used to uniquely identify information across systems or databases without significant risk of duplication.
133+
134+
It looks something like: `30b78323-c06f-4a66-9767-6241f5ee4656`.
128135

129136
It'll make sure your mod is unique and doesn't interfere with another mod installed on the same system. We’ve left it blank, so generate your own by using this [online UUID generator](https://www.uuidgenerator.net/version4), and paste it in here:
130137

@@ -140,7 +147,8 @@ In Baldur’s Gate 3, most of the game’s data, like characters, spells, and it
140147

141148
To make modding easier, the BG3 modding community uses tools to export, convert, and edit these files in a readable **.txt** format before putting them back into the game.
142149

143-
Inside the **Data** folder, you should see three text files.
150+
Inside the **Data** folder, you should see three text files:
151+
144152
- **Character.txt** is empty right now but it will define the stats for your frog, including Strength, Dexterity, Constitution, and other abilities. It will also include special boosts, resistances, and spells that the frog can use.
145153
- **Object.txt** contains information about the object that interacts with the frog, like a teapot or magical item that summons it. This includes the item’s name, rarity, and any effects it grants (for example, unlocking the summon spell when equipped or used).
146154
- **Spell_Target.txt** defines the spells themselves. It includes the summon spell you can cast to bring the frog into the game, as well as the frog’s own spells or attacks it can use in battle to help you out!
@@ -181,7 +189,7 @@ data "Vitality" "2"
181189
data "Weight" "1"
182190
data "StepsType" "Clawed"
183191
```
184-
- `Vitality` is the base number of hit points.
192+
- `Vitality` is the base number of hit points (hp).
185193
- `Weight` affects physics and interactions.
186194
- `StepsType` determines footstep sound/animation (Clawed, Hoofed, etc.).
187195

@@ -214,15 +222,20 @@ The core logic: Summon our Frog friend when you cast the spell, and make sure on
214222

215223
As you saw in your file folder structure, you'll create two Lua scripts:
216224

225+
### BootstrapServer.lua
226+
217227
The first script is **BootstrapServer.lua**. Write the following code inside:
218228

219229
```lua
220230
Ext.Require("Server/Frog.lua")
231+
221232
print("BootstrapServer.lua loaded")
222233
```
223234

224235
Here, we are telling Script Extender to load our **frog.lua** file which contains the game logic, and once it's finished loading, we tell the game to run the code inside (in this case, a print message that says the mod has loaded!).
225236

237+
### Frog.lua
238+
226239
The second script is **Frog.lua**.
227240

228241
By default, the `Target_Summon_Frog` spell just spawns a new frog every time it’s cast. If you cast it twice, you’d have two frogs. If you cast it ten times, you’d have a swarm of frogs!
@@ -248,14 +261,16 @@ end
248261

249262
`Die(summon[1])` kills that frog immediately. Don’t fret though! We aren’t literally killing the frog, we’re just making sure we don’t spawn a million frogs and accidentally crash the game.
250263

251-
Below that, write
264+
Below that, write:
265+
252266
```lua
253267
Ext.Osiris.RegisterListener("UsingSpell", 5, "before", function(caster, spell, targettingType, school, StoryActionID)
254268
if spell == "Target_Summon_Frog" then
255269
KillFrog()
256270
end
257271
end)
258272
```
273+
259274
`Ext.Osiris.RegisterListener("UsingSpell", 5, "before", ...)` registers a listener for the `UsingSpell` event in the game’s scripting system.
260275

261276
`UsingSpell` fires whenever someone casts a spell, and it contains `5` parameters. `before` means the function runs before the spell’s normal effects are applied.
@@ -274,10 +289,11 @@ A **.pak** file is a type of “package” file, primarily used in video games,
274289

275290
Download [BG3 Modder’s Multitool](https://github.com/ShinyHobo/BG3-Modders-Multitool), which is a beginner-friendly open source tool that lets you unpack BG3’s files, browse models, and export your own mod into **.pak** format.
276291

277-
Extract the contents of the .zip folder into the `ModdingTools` folder so you can run the tool separately from your mod files.
292+
Extract the contents of the .zip folder into the **ModdingTools** folder so you can run the tool separately from your mod files.
293+
278294
- Open BG3 Modder’s Multitool (installed outside the game).
279-
- Select your project folder (`Mods`).
280-
- Click Build Mod, which generates a .pak file.
295+
- Select your project folder (**Mods**).
296+
- Click Build Mod, which generates a **.pak** file.
281297

282298
<ImageZoom src="https://i.imgur.com/wjDsrkV.png" style={{ width: "80%", height: "auto" }} alt="screenshot of multitool"/>
283299

@@ -305,7 +321,7 @@ You’ll be able to find the teapot containing the frog in the Tutorial Chest at
305321

306322
## Bonus Challenges
307323

308-
Try changing the frog’s stats! For example, you can scale the frog into a **giant** frog by altering the number inside `ScaleMultiplier()` in the Character.txt file.
324+
Try changing the frog’s stats! For example, you can scale the frog into a GIANT frog by altering the number inside `ScaleMultiplier()` in the **Character.txt** file.
309325

310326
<ImageZoom src="https://i.imgur.com/yYwLo1m.png" style={{ width: "80%", height: "auto" }} alt="BIG FROG"/>Fun fact: that's Jackie’s BG3 character on the right
311327

0 commit comments

Comments
 (0)