Page 1 of 1

Pit immunity crashes the game

Posted: Fri Apr 26, 2013 1:52 pm
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

Re: Pit immunity crashes the game

Posted: Fri Apr 26, 2013 2:43 pm
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.

Re: Pit immunity crashes the game

Posted: Fri Apr 26, 2013 3:01 pm
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)

Re: Pit immunity crashes the game

Posted: Fri Apr 26, 2013 5:04 pm
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 ...

Re: Pit immunity crashes the game

Posted: Fri Apr 26, 2013 5:14 pm
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?

Re: Pit immunity crashes the game

Posted: Fri Apr 26, 2013 5:34 pm
by Conchron
I realized that I've poked something else. The script is fine, it's what happens afterwards that causes the crash. :mrgreen: