Items to Sack to Alcove

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
DeDy
Posts: 132
Joined: Sun Oct 07, 2012 3:41 pm
Location: Brno, Czech Republic

Items to Sack to Alcove

Post by DeDy »

Hi, again need help. Easy script in editor F5 function ok. Dungeon Export, Custom Dungeon start all ok. Save game Grimrock shot down.

Code: Select all

function sack01()
	sack01 = spawn("sack")
	alcove_sack01:addItem(sack01)

	flask01 = spawn("flask")
	sack01:addItem(flask01)

	tar01 = spawn("tar_bead")
	sack01:addItem(tar01)

	energy01 = spawn("potion_energy")
	sack01:addItem(energy01)
end
error.log
SpoilerShow
script_entity_16: cannot serialize table 'tar01' 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'
[string "Grimrock.lua"]: in function 'pollEvents'
[string "Grimrock.lua"]: in function 'display'
[string "Grimrock.lua"]: in main chunk
Thanks
Nightfall: First Contact – http://dedy.euweb.cz/nightfall.html
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Items to Sack to Alcove

Post by crisman »

I think it's not working because you have used the name 'sack01' for both the function and for a variable.
User avatar
DeDy
Posts: 132
Joined: Sun Oct 07, 2012 3:41 pm
Location: Brno, Czech Republic

Re: Items to Sack to Alcove

Post by DeDy »

crisman wrote:I think it's not working because you have used the name 'sack01' for both the function and for a variable.
no :(
SpoilerShow

Code: Select all

function SackToAlcove1()
	sack_01x = spawn("sack")
	alcove_sack01:addItem(sack_01x)

	flask_01x = spawn("flask")
	sack_01x:addItem(flask_01x)

	tar_01x = spawn("tar_bead")
	sack_01x:addItem(tar_01x)

	energy_01x = spawn("potion_energy")
	sack_01x:addItem(energy_01x)
end
Nightfall: First Contact – http://dedy.euweb.cz/nightfall.html
Lilltiger
Posts: 95
Joined: Sun Sep 16, 2012 1:12 am

Re: Items to Sack to Alcove

Post by Lilltiger »

Try using "local" in front of the variables, as the game cant handle global vars that contains objects.
User avatar
Filipsan
Posts: 84
Joined: Fri Mar 16, 2012 10:18 am

Re: Items to Sack to Alcove

Post by Filipsan »

try local variables

Code: Select all

    
function SackToAlcove1()
       local sack_01x = spawn("sack")
       alcove_sack01:addItem(sack_01x)

       local  flask_01x = spawn("flask")
       sack_01x:addItem(flask_01x)

       local  tar_01x = spawn("tar_bead")
       sack_01x:addItem(tar_01x)

       local  energy_01x = spawn("potion_energy")
       sack_01x:addItem(energy_01x)
    end
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Items to Sack to Alcove

Post by crisman »

weird. I've tried your code and it's working fine for me.
Have you tested it with only an item per time?
User avatar
DeDy
Posts: 132
Joined: Sun Oct 07, 2012 3:41 pm
Location: Brno, Czech Republic

Re: Items to Sack to Alcove

Post by DeDy »

LOCAL test is OK. Thanks

function SackToAlcove1()
local sack_01x = spawn("sack")
alcove_sack01:addItem(sack_01x)

local flask_01x = spawn("flask")
sack_01x:addItem(flask_01x)

local tar_01x = spawn("tar_bead")
sack_01x:addItem(tar_01x)

local energy_01x = spawn("potion_energy")
sack_01x:addItem(energy_01x)
end
Nightfall: First Contact – http://dedy.euweb.cz/nightfall.html
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Items to Sack to Alcove

Post by Komag »

If you just want this to exist at the start of the map, you can do it more straightforward. Just have your script say:

Code: Select all

local sack_01x = spawn("sack")
alcove_sack01:addItem(sack_01x)
sack_01x:addItem(spawn("flask"))
sack_01x:addItem(spawn("tar_bead"))
sack_01x:addItem(spawn("potion_energy"))
if you really want to trigger it at some later point, just add a "function name()" at the top and an "end" line at the bottom
Finished Dungeons - complete mods to play
User avatar
DeDy
Posts: 132
Joined: Sun Oct 07, 2012 3:41 pm
Location: Brno, Czech Republic

Re: Items to Sack to Alcove

Post by DeDy »

WOW, script OK, thanks.
Nightfall: First Contact – http://dedy.euweb.cz/nightfall.html
Post Reply