Editor fatal error

Have trouble running Legend of Grimrock 2 or do you have questions about the purchasing options? Look for help here.
Dewalrus
Posts: 20
Joined: Thu Feb 19, 2015 11:35 pm

Editor fatal error

Post by Dewalrus »

I have been building a dungeon in the Editor for three months and nearing completion. All of a sudden I'm getting this error when I try to load the project:

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

The project loaded just fine this morning and I worked with it for about half an hour. All I did was adjust a few teleporters and floor triggers, then went to work on a new level that I just created yesterday. I had barely opened the new level when an error message popped up and the Editor crashed to the Desktop. I can't say for sure, but I believe this occurred when I went to "update" the Preview pane. I did not preserve or even read that error, so unfortunately I don't know what it said. I restarted the game, tried to load the project, and got the above "nil value" message. I cold rebooted and tried again, with the same result.

I would assume that something I did in the Editor this morning caused this, except for one very key point: when I tried to open a previous version of the project that I had saved under a different file name weeks ago, that file gave me the exact same error. And I haven't touched that version for more than a month.

Any ideas what's going on and how I could fix it? It will be devastating if it turns out that three months of work is down the drain. :cry:
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Editor fatal error

Post by minmay »

Your dungeon.lua is a plaintext file with lua code, so if you simply open it in your text editor and go to line 9775, you should be able to find and fix the problem.
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.
Dewalrus
Posts: 20
Joined: Thu Feb 19, 2015 11:35 pm

Re: Editor fatal error

Post by Dewalrus »

Thanks for confirming that. I had already looked at the dungeon.lua file in Notepad, but it doesn't number the lines and I don't have a dedicated Lua interpreter or anything. But it's good to know the problem can be solved that way. If you have any further ideas as to how I can isolate the problem code I would be grateful. I do at least know which two levels I was working on prior to the crash, would it be reasonable to assume the problem is somewhere in the data for those levels? Also -- I don't see any actual scripting code for the Lua objects in dungeon.lua. Is there a way to work with the individual scripts, the ones that are physically placed on the maps in the Editor, without being able to load the project?
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Editor fatal error

Post by minmay »

Embedded scripts are stored as strings in dungeon.lua but they are not the problem because they only run after dungeon.lua has been run. What you need to do is download a real text editor like Notepad++ so that you can go to line 9775. That's where the problem code is. Probably you placed an object on the map and later removed or renamed a component from its definition. For example if you place an object with a component named "goat", changed the component in any way (enabled/disabled, added an item, or the component is wall text etc), then changed the asset definition so that there is no longer a component named "goat", your dungeon.lua won't be able to run anymore because it will try to index the "goat" component which doesn't exist.
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.
Dewalrus
Posts: 20
Joined: Thu Feb 19, 2015 11:35 pm

Re: Editor fatal error

Post by Dewalrus »

Thank you mate, I will get into it as you suggest. Thanks a million for the help. I do have one question. Do you know why this same error would occur when I try to load the prior version of the project that I saved under a different name more than a month ago? Could something I did in the current version cause the backup also not to work?

Thanks for the education -- :)
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Editor fatal error

Post by Zo Kath Ra »

Dewalrus wrote:Thank you mate, I will get into it as you suggest. Thanks a million for the help. I do have one question. Do you know why this same error would occur when I try to load the prior version of the project that I saved under a different name more than a month ago? Could something I did in the current version cause the backup also not to work?

Thanks for the education -- :)
Are you using the Steam beta of LoG2?
Dewalrus
Posts: 20
Joined: Thu Feb 19, 2015 11:35 pm

Re: Editor fatal error

Post by Dewalrus »

I bought and run LoG2 through Steam, but I don't believe it's the beta version. I bought it shortly after the official release, probably in early November 2014.
Dewalrus
Posts: 20
Joined: Thu Feb 19, 2015 11:35 pm

Re: Editor fatal error - NEW INFORMATION

Post by Dewalrus »

Thanks to Minmay (you rock man!) I got Notepad++ and loaded the dungeon.lua with the code lines numbered -- and I think I see the problem. The original error that is preventing my project from loading into the Editor cited line 9755. Here is that line and the relevant ones around it:

spawn("spawner",7,2,3,0,"spawner_100")
spawner_100.spawner:setSpawnedEntity("lightning_bolt")
spawner_100.spawner:setMonsterLevel(1)
spawner_100.spawner:setCooldown(0)
spawner_100.spawner:setDisableSelf(true)
spawn("spawner",3,15,2,0,"") <------LINE 9755
.spawner:setSpawnedEntity("lightning_bolt")
.spawner:setMonsterLevel(1)
.spawner:setCooldown(0)
.spawner:setDisableSelf(true)
spawn("spawner",1,21,2,0,"spawner_102")
spawner_102.spawner:setSpawnedEntity("lightning_bolt")
spawner_102.spawner:setMonsterLevel(1)
spawner_102.spawner:setCooldown(0)
spawner_102.spawner:setDisableSelf(true)

So it looks to me like the Lua file somehow lost its references to spawner_101. Now the question is... am I safe to just alter the lines that seem to be missing "spawner_101" to read exactly like the spawner_100 and spawner_102 sections above and below that? Would that be expected to fix the problem completely?

Thanks again :) I wasn't looking forward to starting all over.
User avatar
Dr.Disaster
Posts: 2874
Joined: Wed Aug 15, 2012 11:48 am

Re: Editor fatal error

Post by Dr.Disaster »

You can see the version in use by looking in the lower left corner of the main menu. The current release version is 2.1.18 with the actual beta being 2.2.4. When you got anything older at least update to the current release.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Editor fatal error - NEW INFORMATION

Post by minmay »

Dewalrus wrote:Thanks to Minmay (you rock man!) I got Notepad++ and loaded the dungeon.lua with the code lines numbered -- and I think I see the problem. The original error that is preventing my project from loading into the Editor cited line 9755. Here is that line and the relevant ones around it:

spawn("spawner",7,2,3,0,"spawner_100")
spawner_100.spawner:setSpawnedEntity("lightning_bolt")
spawner_100.spawner:setMonsterLevel(1)
spawner_100.spawner:setCooldown(0)
spawner_100.spawner:setDisableSelf(true)
spawn("spawner",3,15,2,0,"") <------LINE 9755
.spawner:setSpawnedEntity("lightning_bolt")
.spawner:setMonsterLevel(1)
.spawner:setCooldown(0)
.spawner:setDisableSelf(true)
spawn("spawner",1,21,2,0,"spawner_102")
spawner_102.spawner:setSpawnedEntity("lightning_bolt")
spawner_102.spawner:setMonsterLevel(1)
spawner_102.spawner:setCooldown(0)
spawner_102.spawner:setDisableSelf(true)

So it looks to me like the Lua file somehow lost its references to spawner_101. Now the question is... am I safe to just alter the lines that seem to be missing "spawner_101" to read exactly like the spawner_100 and spawner_102 sections above and below that? Would that be expected to fix the problem completely?

Thanks again :) I wasn't looking forward to starting all over.
Yes, that would work. Looks like what happened is that you renamed spawner_101 to the empty string (nothing). When you erase an object's name in the editor, remember to replace it with a new name.
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.
Post Reply