[SOL]Pressing 'K' in editor / killing a monster causes crash

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

[SOL]Pressing 'K' in editor / killing a monster causes crash

Post by SpiderFighter »

I'm having an issue all of a sudden, pressing the instakill key within the editor, and killing monsters. I have added two snails and one herder, and killing (or pressing 'K' when in the editor) one of them always causes a crash, both in the editor and the exported game. The monster death that causes the crash can be different every time. I have no idea what's going on here.

Here's the error.log when pressing 'K' in the editor:
SpoilerShow
[string "Map.lua"]:0: entity already added to map
stack traceback:
[C]: in function 'assert'
[string "Map.lua"]: in function 'addEntity'
[string "Monster.lua"]: in function 'die'
[string "GameMode.lua"]: in function 'keyPressed'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk

OS Version 6.1

OEM ID: 0
Number of processors: 2
Page size: 4096
Processor type: 586

Total memory: 6050 MB
Free memory: 1842 MB

Display device 0:
Device name: \\.\DISPLAY1
Device string: Intel(R) HD Graphics Family
State flags: 00000005

Display device 1:
Device name: \\.\DISPLAY2
Device string: Intel(R) HD Graphics Family
State flags: 08000000

Display device 2:
Device name: \\.\DISPLAYV1
Device string: RDPDD Chained DD
State flags: 00000008

Display device 3:
Device name: \\.\DISPLAYV2
Device string: RDP Encoder Mirror Driver
State flags: 00200008

Display device 4:
Device name: \\.\DISPLAYV3
Device string: RDP Reflector Display Driver
State flags: 00200008
And the killed monster crash in the exported version:
SpoilerShow
[string "Map.lua"]:0: entity already added to map
stack traceback:
[C]: in function 'assert'
[string "Map.lua"]: in function 'addEntity'
[string "Monster.lua"]: in function 'die'
[string "Monster.lua"]: in function 'damage'
[string "Combat.lua"]: in function 'damageTile'
[string "ProjectileSpell.lua"]: in function 'onProjectileHit'
[string "Projectile.lua"]: in function 'update'
[string "ProjectileSpell.lua"]: in function 'update'
[string "Map.lua"]: in function 'updateEntities'
[string "Dungeon.lua"]: in function 'updateLevels'
[string "GameMode.lua"]: in function 'update'
[string "Grimrock.lua"]: in function 'display'
[string "Grimrock.lua"]: in main chunk

OS Version 6.1

OEM ID: 0
Number of processors: 2
Page size: 4096
Processor type: 586

Total memory: 6050 MB
Free memory: 1848 MB

Display device 0:
Device name: \\.\DISPLAY1
Device string: Intel(R) HD Graphics Family
State flags: 00000005

Display device 1:
Device name: \\.\DISPLAY2
Device string: Intel(R) HD Graphics Family
State flags: 08000000

Display device 2:
Device name: \\.\DISPLAYV1
Device string: RDPDD Chained DD
State flags: 00000008

Display device 3:
Device name: \\.\DISPLAYV2
Device string: RDP Encoder Mirror Driver
State flags: 00200008

Display device 4:
Device name: \\.\DISPLAYV3
Device string: RDP Reflector Display Driver
State flags: 00200008
Does anyone have any ideas, or (or has anyone seen this before)?

[EDIT:} Ok, I'm not quite ready to mark this as solved yet, but I had a script like this:
SpoilerShow
local message = spawn("scroll")
message:setScrollText("VISITOR'S PASS")
visitora:addItem(message)
visitorb:addItem(message)
I had named one snail visitora, and a herder visitorb. I've deleted the "visitorb:addItem(message)" line and it seems to be working, although I cringe everytime I press 'K." I'll test it a few more times, because at one point I did kill both of them successfully (and had both scrolls in my inventory).

[EDIT: Calling this solved. Don't spawn one scroll and put it in two places. ;) It might work, but, mostly...no.]
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [SOL]Pressing 'K' in editor / killing a monster causes c

Post by Komag »

Yeah that's it, the error only "matured" when they died because that's when the game has to fork over the scroll, and suddenly it throws a conniption fit!
Finished Dungeons - complete mods to play
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

Re: [SOL]Pressing 'K' in editor / killing a monster causes c

Post by SpiderFighter »

Komag wrote:Yeah that's it, the error only "matured" when they died because that's when the game has to fork over the scroll, and suddenly it throws a conniption fit!
Yeah, seems pretty boneheaded, but the weird thing is that it actually did work at least once! :lol:
Alcator
Posts: 37
Joined: Fri Apr 13, 2012 9:59 am

Re: [SOL]Pressing 'K' in editor / killing a monster causes c

Post by Alcator »

Code: Select all

local message = spawn("scroll")
message:setScrollText("VISITOR'S PASS")
visitora:addItem(message)
visitorb:addItem(message)
You cannot add the same object (= an object with a unique ID) to 2 different places. the first time you call "addItem" or "spawn" with exact placement coordinates, is the moment when the object "materializes" and cannot be "moved" by another addItem call.

What you should have done is call the spawn/setScrollText/addIem triplet two times. Like this:

Code: Select all

local alphabet = {"a","b"}
for i = 1,2 do
  local message = spawn("scroll") 
  message:setScrollText("VISITOR'S PASS")
  local recipientId = "visitor"..alphabet[i]  -- this generates either "visitora" or "visitorb" ID.
  findEntity(recipientId):addItem(message)  -- this finds an entity with that ID and gives it this "copy" of the scroll.
end -- at this point all the local variables minus the alphabet one disappear.
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

Re: [SOL]Pressing 'K' in editor / killing a monster causes c

Post by SpiderFighter »

Alcator wrote:
What you should have done is call the spawn/setScrollText/addIem triplet two times. Like this:

Code: Select all

local alphabet = {"a","b"}
for i = 1,2 do
  local message = spawn("scroll") 
  message:setScrollText("VISITOR'S PASS")
  local recipientId = "visitor"..alphabet[i]  -- this generates either "visitora" or "visitorb" ID.
  findEntity(recipientId):addItem(message)  -- this finds an entity with that ID and gives it this "copy" of the scroll.
end -- at this point all the local variables minus the alphabet one disappear.
I've learned that I can't script worth a...well, I can't script. But this is a remendous help to us .lua newbies! Thanks for posting it.
Post Reply