Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
minmay
Posts: 2715
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Tue Sep 21, 2021 11:28 pm

Sounds like you have a ScriptComponent somewhere that's trying to load mod_assets/scripts/monsters.lua as a source file. Search your dungeon.lua for "mod_assets/scripts/monsters.lua" and you should find it.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
Mal85
Posts: 103
Joined: Fri Nov 16, 2012 10:56 am

Re: Ask a simple question, get a simple answer

Post by Mal85 » Wed Sep 22, 2021 12:36 am

Yes I found it easily enough in my Dungeon.lua, but what do I do with it? Do I delete the entry? When I tried to outright remove the problematic script entity in my mod it threw even worse error and crashed editor.

Edit: Oh I figured it out... I must have switched the referenced script from the custom one to the monsters.lua by mistake. Geeze. Thanks Minmay at any rate, that fried my brain for literal months. :shock:

User avatar
Mal85
Posts: 103
Joined: Fri Nov 16, 2012 10:56 am

Re: Ask a simple question, get a simple answer

Post by Mal85 » Wed Sep 22, 2021 1:03 am

Ok, so I got it to load the floor finally by switching it to the correct script. But then it said something about not enough memory and CTD. Now when I attempt to load the mod it says-

mod_assets/scripts/dungeon.lua:13856: attempt to index a nil value.

that line of code reads as follows in dungeon.lua-

script_entity_8.script:loadFile("mod_assets/scripts/yunintemple.lua")

switching it back to monsters.lua has same error and same line.

As I feared, I broke it even worse now...

:?

Edit: I switched the little pulldown menu inside the editor from monster.lua to yunintemple.lua. Any way I can undo that little mistake? So close to be done with this mod, just need to get this last bit figured out and some coding hitches are killing me.

minmay
Posts: 2715
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Wed Sep 22, 2021 4:10 am

It means that either script_entity_8 or its component named "script" don't exist yet. Did you accidentally delete the spawn() call that creates script_entity_8?
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
Mal85
Posts: 103
Joined: Fri Nov 16, 2012 10:56 am

Re: Ask a simple question, get a simple answer

Post by Mal85 » Wed Sep 22, 2021 4:32 am

No I didn't delete anything. Basically the party grabs a sword off an altar which starts a boss battle. One of the connectors is to a script entity that is supposed to reference yunintemple.lua but was incorrectly referencing monsters.lua. Thinking I had solved the issue I switched the little pull down tab in the editor for that external script and changed it from monsters.lua to yunintemple.lua.

The floor loaded perfectly! Hurray! I fought the boss, the music and HP bar worked and everything, so I save the mod, finally it's fixed! Then try to load all the floors at once and get a CTD.

I tried to change the line in Dungeon.lua that you pointed me too and changed it to also reference yunintemple.lua as was intended. Yoink, now the mod fails to load at all with the above posted error and Im not sure what I can do. I tried changing it between Monsters.lua and yunintemple.lua but it seems that changing the little menu in game really broke it and I have no way to get back into it to revert that change...

Thanks Minmay!

EDIT: I did not delete the spawn call, it is still present there.

EDIT:Here is the script that references that.
https://hosting.photobucket.com/images/ ... &crop=fill

minmay
Posts: 2715
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Wed Sep 22, 2021 5:56 am

The dropdown menu just changes the line that gets generated in the dungeon.lua. It doesn't do anything else. So if you want to "undo" it, you can just remove the

Code: Select all

script_entity_8.script:loadFile("mod_assets/scripts/yunintemple.lua")
line (or change it back to monsters.lua if you really want to get your old error back).

Of course, this doesn't really help with the error you describe. It's extremely strange that the code in the screenshot would result in that error. Neither of the possibilities seem very likely:
1. script_entity_8 is nil. It's just been spawned on a map, one line ago, so the only way this could happen is if you're loading the dungeon.lua from your init.lua, in which case I'd expect an error much sooner (for one, spawn would probably be nil!)
2. script_entity_8.script is nil. This could only happen if you have changed the definition of script_entity to remove or rename its ScriptComponent.

(The error can't can't be coming from within loadFile, because this is the complete source code of loadFile:

Code: Select all

function ScriptComponent:loadFile(filename)
	self.source = filename
	self.scriptType = "external"
end
The only indexes performed are to self, i.e. script_entity_8.script in this case, and if that were nil, you wouldn't get far enough to call loadFile)
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
Mal85
Posts: 103
Joined: Fri Nov 16, 2012 10:56 am

Re: Ask a simple question, get a simple answer

Post by Mal85 » Wed Sep 22, 2021 7:34 am

Deleting the lines worked and I even got the original script sorted thanks too you Minmay! Ever the legend, so glad your still around here! Cheers mate!

Edit: Pretty sure I changed something in my monster.lua after I also messed up the dungeon.lua and that was causing the nil. Thankfully I made a backup of that file and simply restored it. Whew, work can resume finally! Thanks again.

Post Reply