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
+30-21Lines changed: 30 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Make a Baldur's Gate 3 Mod With Lua
2
+
title: Make a Baldur's Gate 3 Mod with Lua
3
3
author: Julien Kris
4
4
uid: Jps14SaCwqgdbbnYvoMpvMKv92P2
5
5
datePublished: 2025-09-03
@@ -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"
@@ -39,9 +39,7 @@ tags:
39
39
40
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 the fifth edition of 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.
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.
**Mods** (short for modifications) are a way of writing code to alter features, graphics, or gameplay of an existing game, even for huge titles like Baldur's Gate 3. Special thanks to [Jon Hinkerton](https://next.nexusmods.com/profile/jonhinkerton?gameId=3474) for creating the original mod that inspired this tutorial.
54
+
**Mods** (short for modifications) are a way of writing code to alter features, graphics, or gameplay of an existing game, even for huge titles like Baldur's Gate 3.
57
55
58
56
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!
59
57
@@ -64,6 +62,8 @@ By the end of this tutorial, you’ll know how to:
64
62
- Customize the companion’s stats
65
63
- Test your mod in-game
66
64
65
+
**Note:** Special thanks to [Jon Hinkerton](https://next.nexusmods.com/profile/jonhinkerton?gameId=3474) for creating the original mod that inspired this tutorial.
66
+
67
67
## Getting Started
68
68
69
69
Make sure you have Baldur's Gate 3 installed on your machine! If not, start [installing](https://store.steampowered.com/app/1086940/Baldurs_Gate_3) it in the background while you create your mod.
@@ -72,21 +72,27 @@ If you don't already have a code editor installed, download [Visual Studio Code]
72
72
73
73
### BG3 Script Extender
74
74
75
-
**BG3 Script Extender (BG3SE)** is a program that adds Lua scripting and console support to Baldur's Gate 3. Download it from [GitHub](https://github.com/Norbyte/bg3se).
75
+
**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
+
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**.
76
78
77
-
Right click on the downloaded .zip file, select [Extract All], and extract the files to a new folder called in your Documents directory, and name it something like `ModdingTools`. Next to your `ModdingTools` folder, create a new folder called `Mods`. We'll be keeping our modding apps in the `ModdingTools` folder, and our working files in the `Mods` folder.
79
+
We'll be keeping:
78
80
79
-
Here's the structure you'll be working with inside the Mods folder (you'll learn how to create the meta.lsx files and both .lua files in a bit!)
81
+
- Our modding apps in the **ModdingTools** folder.
82
+
- Our working files in the **Mods** folder.
83
+
84
+
Here's the structure you'll be working with inside the **Mods** folder (you'll learn how to create the **meta.lsx** files and both **.lua** files in a bit!)
80
85
81
86
### Starter files
82
-
[Here’s](LINK) a zip folder containing the starter files for this project! It contains the basic file structure you’ll be working with.
87
+
88
+
[Here’s a zip folder](LINK) containing the starter files for this project! It contains the basic file structure you’ll be working with.
83
89
```
84
90
Mods/Frog/Mods/Frog
85
91
├── meta.lsx
86
92
└── ScriptExtender/
87
93
└── Lua/
88
-
├── BoostrapServer.lua
89
-
└── Server/
94
+
├── BoostrapServer.lua
95
+
└── Server/
90
96
└── Frog.lua
91
97
```
92
98
@@ -118,9 +124,9 @@ Without this file, the game doesn’t know your mod exists.
118
124
119
125
## Setting up .txt files
120
126
121
-
In Baldur’s Gate 3, most of the game’s data, like characters, spells, and items, is stored inside .pak files. These are packed files that the game reads directly, so you can’t edit them in a normal text editor.
127
+
In Baldur’s Gate 3, most of the game’s data, like characters, spells, and items, is stored inside **.pak** files. These are packed files that the game reads directly, so you can’t edit them in a normal text editor.
122
128
123
-
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.
129
+
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.
124
130
125
131
Inside the **Data** folder, you should see three text files.
126
132
-**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.
@@ -199,9 +205,9 @@ The first script is **BootstrapServer.lua**. Write the following code inside:
199
205
```lua
200
206
Ext.Require("Server/Frog.lua")
201
207
print("BootstrapServer.lua loaded")
202
-
203
208
```
204
-
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!).
209
+
210
+
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!).
205
211
206
212
The second script is **Frog.lua**.
207
213
@@ -210,6 +216,7 @@ By default, the `Target_Summon_Frog` spell just spawns a new frog every time it
210
216
This script fixes that by ensuring that any existing frog is removed before a new one is created. That way, you’ll always have exactly one frog active.
211
217
212
218
Write the following code:
219
+
213
220
```lua
214
221
localfunctionKillFrog()
215
222
localsummons=Osi.DB_PlayerSummons:Get(nil)
@@ -220,6 +227,7 @@ local function KillFrog()
220
227
end
221
228
end
222
229
```
230
+
223
231
`Osi.DB_PlayerSummons:Get(nil)` queries the game for all currently active summons belonging to the player. The script checks them one by one.
224
232
225
233
`string.match(summon[1], "Frog")` says that if the summon’s identifier (its internal name) contains "Frog", we’ve found a frog.
@@ -279,7 +287,7 @@ You’ll be able to find the teapot containing the frog in the Tutorial Chest at
279
287
280
288
<ImageZoomsrc="insert image before publishing"style={{ width: "80%", height: "auto" }}alt="Discovering the teapot containing Frog"/>
281
289
282
-
# Bonus Challenges
290
+
##Bonus Challenges
283
291
284
292
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.
285
293
@@ -289,7 +297,7 @@ You can also try summoning other creatures! The best way to understand Mod files
289
297
290
298
Download one of these mods that use similar logic and let you summon a [Ghost Cat](https://www.nexusmods.com/baldursgate3/mods/5720), a [Tressym](https://www.nexusmods.com/baldursgate3/mods/5742), or even a [Pet Rock](https://www.nexusmods.com/baldursgate3/mods/7217).
291
299
292
-
# Conclusion
300
+
##Conclusion
293
301
294
302
Congrats! You just made your first Baldur’s Gate 3 mod! 🎉
295
303
@@ -299,7 +307,7 @@ We created a frog companion that can fight by your side in battle!
299
307
300
308
May you win every battle, and have fun breaking Faerûn!
301
309
302
-
# Additional Resources
310
+
###Additional Resources
303
311
304
312
Here are some more resources to explore:
305
313
@@ -309,7 +317,8 @@ Here are some more resources to explore:
309
317
-[Manual Modding in BG3 for MacOS Users](https://www.youtube.com/watch?v=8BNi0uNOvrE)
310
318
-[Jon Hinkerton’s other mods](https://next.nexusmods.com/profile/jonhinkerton/mods?gameId=3474&page=1)
311
319
312
-
Scratch told us he wants you to share your projects with the team [@codedex_io](https://www.twitter.com/codedex_io)! Let us know what you come up with!
320
+
Scratch told us he wants you to share your projects with the team [@codedex_io](https://www.twitter.com/codedex_io) and [@baldursgate3](https://x.com/baldursgate3)! Let us know what you come up with!
0 commit comments