game crash when saving

Have trouble running Grimrock 1 or you're wondering if your graphics card is supported? Look for help here.
Post Reply
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

game crash when saving

Post by Drakkan »

Hi, I have quite interesting problem. I am playing my custom dungeon - when I try to save the game (no matter if F5, crystal autosave or named save), the game crash with following error:

script_entity_277: cannot serialize table 'x' 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 "GameMode.lua"]: in function 'quickSave'
[string "GameMode.lua"]: in function 'keyPressed'
etc...


any ideas what is going wrong ?
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: game crash when saving

Post by Komag »

It appears that you have some value of some non-local variable that is not allowed for save games
Finished Dungeons - complete mods to play
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: game crash when saving

Post by Drakkan »

Komag wrote:It appears that you have some value of some non-local variable that is not allowed for save games
which in english means what ? :d
saving was working without problem, but it began to crash at the end of dungeon. Could it have something to do with steam ?
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Sol_HSA
Posts: 681
Joined: Fri Mar 02, 2012 3:10 pm
Location: Nowhere whenever
Contact:

Re: game crash when saving

Post by Sol_HSA »

In English, the custom dungeon is buggy.
Reminder: moderators (green names) don't work for almost human. | http://iki.fi/sol/ - My schtuphh..
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: game crash when saving

Post by antti »

Drakkan wrote:
Komag wrote:It appears that you have some value of some non-local variable that is not allowed for save games
which in english means what ? :d
saving was working without problem, but it began to crash at the end of dungeon. Could it have something to do with steam ?
Here's more details on what Komag was referring to: http://www.grimrock.net/modding/save-ga ... variables/

In short, the probable cause is that you use variables in functions that are not local. Since the crash started happening towards the end of the dungeon, you probably can start looking for the issue in scripts that are triggered in those parts of the dungeon. But yeah, check out the documentation I linked to and if you need more help, ask again in this thread. 8-)
Steven Seagal of gaming industry
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: game crash when saving

Post by Komag »

You could test again by trying to save all the time, and the first moment it crashes, just remember what you just recently did, and it must be involved with those scripts. Try to only use safe values for non-local variables, or try to change the script setup to just use a local (temporary) variable.
Finished Dungeons - complete mods to play
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: game crash when saving

Post by Drakkan »

good, I have found the "invalid" script, however do not know what problem is, as the script itself is working right. Any tips ?

Code: Select all

function itemCheck(item)
   -- checks for the item in champions hands
   for champ = 1,4 do
   for slot = 7,8 do
      x = party:getChampion(champ):getItem(slot)
      if x ~= nil then
      if x.name == item then
         -- if found it is removed and the returnItem function is triggered
            party:getChampion(champ):removeItem(slot)
         print("item removed")
         returnItem(item,champ)
      end
        end   
   end    
   end   
end

function returnItem(item,champ)
   -- checks backpacks for empty slot
   for slot = 11,32 do
         if slot < 32 then
            if party:getChampion(champ):getItem(slot) == nil then
               -- once found, the item is placed in a slot and the player is told where
               print("item returned")
               party:getChampion(champ):insertItem(slot,x)
               hudPrint("Something strange in the air makes torches unusable in this area. Torch is put into "..party:getChampion(champ):getName().."'s bag." )
               playSound("generic_spell")
               break
            end
         else
            -- if no slots are empty, the item is dropped
            spawn(item,party.level,party.x,party.y,party.facing)
            hudPrint("Your bags are full. The torch is dropped to the floor.")
            break
         end
   end
end

function checkTorch()
   itemCheck("torch")
end
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: game crash when saving

Post by Komag »

your non-local variable x is storing the actual item from the player's hands, not just it's name or something else. either make x local or make it only store something like a string or a number
Finished Dungeons - complete mods to play
Post Reply