Pit immunity crashes the game

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Conchron
Posts: 137
Joined: Mon Dec 31, 2012 1:20 am
Location: Sweden

Pit immunity crashes the game

Post by Conchron »

I'm using a pit immunity script and it crashes the (exported) game when I save it. I started out by using the pit immunity script from the useful scripts repository but it didn't work for me so I changed it a bit. The timer was the problem and I added a pressure plate to stop the script instead.

Top floor script:
SpoilerShow

Code: Select all

function tempImmunity()
     for i = 1,4 do
   pitImmunity = party:getChampion(i)
   pitImmunity:setEnabled(false)
     end
end

The script that connects to the pressure plate the floor above the landing point:
SpoilerShow

Code: Select all

function immunityRevoke()
  for i = 1,4 do
    pitImmunity = party:getChampion(i)
    pitImmunity:setEnabled(true)
  end
end
The error message:
SpoilerShow
script_entity_2: cannot serialize table 'pitImmunity' with metatable
stack traceback:
[C]: in function 'error'
[string "ScriptEntity.lua"]: in function 'saveValue'
[string "ScriptEntity.lua"]: in function 'saveState'
[string "GameMode.lua"]: in function 'saveGame'
[string "SaveGameMenu.lua"]: in function 'update'
[string "GameMode.lua"]: in function 'update'
[string "Grimrock.lua"]: in function 'display'
[string "Grimrock.lua"]: in main chunk
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Pit immunity crashes the game

Post by msyblade »

I am not sure about this, as I havent run across the script before. However, the pitImmunity command you are using is not built into LoG, which leads me to surmise that it is part of a "Framework" you will need to install to get the extra commands. Go back where you found the script and see if it is part of a larger framework, then read on how to install it.
edit: See Komag below, it usually saves a lot of trouble.
Last edited by msyblade on Fri Apr 26, 2013 3:38 pm, edited 1 time in total.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Pit immunity crashes the game

Post by Komag »

There doesn't seem to be any reference to any framework that I can see, just a variable that needs to be local:

Code: Select all

function tempImmunity()
     for i = 1,4 do
   local pitImmunity = party:getChampion(i)
   pitImmunity:setEnabled(false)
     end
end

function immunityRevoke()
  for i = 1,4 do
    local pitImmunity = party:getChampion(i)
    pitImmunity:setEnabled(true)
  end
end
But if I were you I would simply leave off the pointless variable altogether:

Code: Select all

function tempImmunity()
  for i = 1,4 do
    party:getChampion(i):setEnabled(false)
  end
end

function immunityRevoke()
  for i = 1,4 do
    party:getChampion(i):setEnabled(true)
  end
end
(I haven't tested it, and it's been a while, so maybe I'm mistaken about something)
Finished Dungeons - complete mods to play
User avatar
Conchron
Posts: 137
Joined: Mon Dec 31, 2012 1:20 am
Location: Sweden

Re: Pit immunity crashes the game

Post by Conchron »

Thank you Komag. That script works. In a brand new dungeon. However, when I put it into my work in progress the editor crashes to the point where I have to reboot my pc. :? In other words, I've got gremlins in my dungeon and they are messing up the script somehow. ... back to the drawing board ...
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Pit immunity crashes the game

Post by Komag »

they are quite simple straightforward functions - I can't imagine what could cause a bad hard crash like that. Have you tried renaming the functions? What about adding a very fast timer at the bottom to have a tiny delay between the plate and the function?
Finished Dungeons - complete mods to play
User avatar
Conchron
Posts: 137
Joined: Mon Dec 31, 2012 1:20 am
Location: Sweden

Re: Pit immunity crashes the game

Post by Conchron »

I realized that I've poked something else. The script is fine, it's what happens afterwards that causes the crash. :mrgreen:
Post Reply