Hi everyone,
This tutorial is for those who are new to scripting/modding, and is intended to explain the basic scripting architecture in Grim Dawn, so that you understand how scripts are connected together. You’ll need to understand this in order to create new quests and other type of events in Grim Dawn.
We’ll use the “Modding Tutorial” Mod, and you need to have setup your modding tools suite already (check https://forums.crateentertainment.com/t/script-basics-modding-beginners-guide-i/37525 if you haven’t done so already). In order to open/edit scripts, you can use many softwares but I’d recommend Notepad++, it’s simple/light and free.
Now that you’re set, let’s look at how Grim Dawn organizes scripts.
Open your asset manager, choose the modding tutorial mod.
Go the Sources tab, click Scripts, and you’ll see a main.lua script in the right window : the main script is the entry point of the architecture of scripts, this is where all begins and it is needed for any of your scripts to work.
Open the script, and you’ll notice that it has two lines that loads other scripts :
So now we see that our main script is loading the grimdawn.lua script. So let’s look at what it is.
Go to scripts\game\ and open grimdawn.lua
Here we see that the grimdawn.lua is loading a script too : quests.lua which is another script in the same folder. Open it.
Now we see that script is loading all the quests and quest related scripts. This is where the quest script’s adresses are, and every quest script that is here will be loaded to be used when needed.
Here we see that the mod will be loading the quests "killBossQuest"and “flavorEvent.lua”.
Questevents.lua and _MPQuestControl.lua are not quests per say, but they are needed as well for your quests to work properly (what these specifically do will be covered in a quest creation tutorial).
Now you can see that in scripts/game/, there is a folder named quests, which is where those two quest scripts are.
Click that folder in your Asset Manager and open killBossQuest.lua
Here you see the script that will be executed by this quest only.
So now, from the first main.lua script down to killBossQuest.lua, you can see how scripts are spread and connected together. That explains why If you create a quest and it’s script, you will then also need to update the quests.lua so that the quest script is loaded.
If you wish to learn how to create a quest from beginning to end, there is a tutorial here : https://forums.crateentertainment.com/t/tutorial-basic-scripting-how-to-create-a-quest/103239/3