You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: projects/make-a-bg3-mod-with-lua/make-a-bg3-mod-with-lua.mdx
+29-13Lines changed: 29 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ tags:
19
19
cl="for-sidebar"
20
20
/>
21
21
22
-
##Make a Baldur's Gate 3 Mod With Lua
22
+
# Make a Baldur's Gate 3 Mod With Lua
23
23
24
24
<AuthorAvatar
25
25
author_name="Julien Kris"
@@ -37,9 +37,11 @@ tags:
37
37
**Prerequisites:** Lua basics, Baldur's Gate 3
38
38
**Read Time:** 45 minutes
39
39
40
-
# Introduction: Companion Creatures
40
+
##Introduction: Companion Creatures
41
41
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.
@@ -55,9 +57,10 @@ We're going to do just that by making our own mod!
55
57
56
58
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!
57
59
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!
59
61
60
62
By the end of this tutorial, you’ll know how to:
63
+
61
64
- Write a BG3 mod that lets you summon a custom companion with Lua
62
65
- Customize the companion’s stats
63
66
- Test your mod in-game
@@ -74,7 +77,9 @@ If you don't already have a code editor installed, download [Visual Studio Code]
74
77
75
78
**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).
76
79
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**.
78
83
79
84
We'll be keeping:
80
85
@@ -124,7 +129,9 @@ It contains the following components:
124
129
125
130
Without this file, the game doesn’t know your mod exists.
126
131
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`.
128
135
129
136
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:
130
137
@@ -140,7 +147,8 @@ In Baldur’s Gate 3, most of the game’s data, like characters, spells, and it
140
147
141
148
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.
142
149
143
-
Inside the **Data** folder, you should see three text files.
150
+
Inside the **Data** folder, you should see three text files:
151
+
144
152
-**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.
145
153
-**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).
146
154
-**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"
181
189
data "Weight" "1"
182
190
data "StepsType" "Clawed"
183
191
```
184
-
-`Vitality` is the base number of hit points.
192
+
-`Vitality` is the base number of hit points (hp).
@@ -214,15 +222,20 @@ The core logic: Summon our Frog friend when you cast the spell, and make sure on
214
222
215
223
As you saw in your file folder structure, you'll create two Lua scripts:
216
224
225
+
### BootstrapServer.lua
226
+
217
227
The first script is **BootstrapServer.lua**. Write the following code inside:
218
228
219
229
```lua
220
230
Ext.Require("Server/Frog.lua")
231
+
221
232
print("BootstrapServer.lua loaded")
222
233
```
223
234
224
235
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!).
225
236
237
+
### Frog.lua
238
+
226
239
The second script is **Frog.lua**.
227
240
228
241
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
248
261
249
262
`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.
`Ext.Osiris.RegisterListener("UsingSpell", 5, "before", ...)` registers a listener for the `UsingSpell` event in the game’s scripting system.
260
275
261
276
`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,
274
289
275
290
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.
276
291
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
+
278
294
- 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.
281
297
282
298
<ImageZoomsrc="https://i.imgur.com/wjDsrkV.png"style={{ width: "80%", height: "auto" }}alt="screenshot of multitool"/>
283
299
@@ -305,7 +321,7 @@ You’ll be able to find the teapot containing the frog in the Tutorial Chest at
305
321
306
322
## Bonus Challenges
307
323
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.
309
325
310
326
<ImageZoomsrc="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
0 commit comments