LUA scripts not loading correctly on mod

Howdy - I’m trying to debug why my scripts are not loading correctly into my mod, but unable to determine why. I think there might be something fundamentally wrong with my file structure, but only the scripts do not work, all dbr-based changes are working.

The goal is to give a xp potion to a new character as soon as they appear in town after being created.

Can someone please help me debug? What I’ve done so far:

  1. Downloaded Grim Internals to enable print outputs into the game console (nothing is printing)
  2. Set up asset manager
  3. Created the following file structure for scripts (main is the name of the mod in this case - know, poor name choice but please bear with me):
  • MAIN/source > scripts > game > main
  • in scripts, I have main.lua (unrelated to mod, entry point from grim dawn)
  • in scripts/game, grimdawn.lua
  • in scripts/game/MAIN, mainmod.lua

Contents:
main.lua:

– Libs
Script.Load(“scripts/libs/shared.lua”)

– Game
Script.Load(“scripts/game/grimdawn.lua”)

grimdawn.lua (the fact that the prints here are not triggering tells me it hasn’t loaded, but unsure if that’s just the print flat out not working)

print “aaa”
print(“aaanother format”)
gd = {}

// Mod - starter items
Script.Load("scripts/game/MAIN/mainmod.lua")

// Endless Dungeon
Script.Load("scripts/game/endlessdungeon.lua")

// Quests
Script.Load("scripts/game/quests.lua")
Script.Load("scripts/game/dungeonchestsgdx1.lua")
Script.Load("scripts/game/dungeonchestsgdx2.lua")
Script.Load("scripts/game/dungeonchests.lua")
Script.Load("scripts/game/events/waveevent.lua")

mainmod.lua

print “aaa inside mainmod”
print("aaanother format inside mainmod ")
gd.MAIN = {}

function gd.MAIN.StarterItems(id)
print(“inside func”)
local player = Game.GetLocalPlayer()

if(player:GetLevel() > 1 || Game.GetGameDifficulty() ~= Game.Difficulty.Normal) then
return
end

player:GiveItem(“records/items/crafting/consumables/gdl_xppotion_malmouth.dbr”, 2, false)
end

A follow-up question:
Where do I actually trigger the script to execute on start? I have the function but I’m not calling it yet, because I don’t know where to yet.

Look at the Grimmest mod for this, it does what you want when it gives players the item to spawn Zeke.

If all you want is an XP potion, then adding one to the body on the bridge might be easier though. Certainly only requires you to change its dbr, without having to fiddle with scripts

Well lets see.

  1. Did you auto create assets for those scripts in AM?
  2. I triiger mine on records\triggervolumes\devilscrossing_spawnarea.dbr since it is already giving you the salt necklace. You could probably do it the player file on add to world ( might trigger everytime death happens? )
  3. It would be very hard for you to give yourself that exp potion :rofl: . That is mod special for the GD League

Do 1-3 to call your function and do all nesseccery debug prints in there.

1 Like

LOL, of course leave it to the noob to screw even the dbr up :slight_smile: Amended to “records/items/crafting/consumables/xppotion_malmouth.dbr”.

After loading the trigger per your comment above and going into Grim Internals, it said my function wasn’t found. So I went back and deleted all the assets and recreated them respecting case (it seems I did it previously with a “scripts” directory and not a “Scripts” one), and it triggered!

Thank you so much!!

1 Like