Page 1 of 1
game crash when saving
Posted: Thu May 16, 2013 11:50 am
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 ?
Re: game crash when saving
Posted: Thu May 16, 2013 11:58 am
by Komag
It appears that you have some value of some non-local variable that is not allowed for save games
Re: game crash when saving
Posted: Thu May 16, 2013 12:52 pm
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 ?
Re: game crash when saving
Posted: Thu May 16, 2013 12:54 pm
by Sol_HSA
In English, the custom dungeon is buggy.
Re: game crash when saving
Posted: Thu May 16, 2013 1:08 pm
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.

Re: game crash when saving
Posted: Thu May 16, 2013 2:05 pm
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.
Re: game crash when saving
Posted: Thu May 16, 2013 2:10 pm
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
Re: game crash when saving
Posted: Thu May 16, 2013 2:38 pm
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