I have 5 figures and they have to be placed in the alcove in order. If the wrong item is placed, then you get an incorrect sound from everything you place afterwards until you take everything out and start over.
Connect the alcove to the script as On insert items, not remove item or you get extra error sounds.
Code: Select all
unlock1 = 0
unlock2 = 0
unlock3 = 0
unlock4 = 0
function figurepuzzle()
local count = mine_alcove_1.surface:count()
if count == 1 then
if surfaceContains(mine_alcove_1.surface, "figure_crowern") then
unlock1 = 1
unlock2 = 0
unlock3 = 0
unlock4 = 0
playSound("lock_chest")
else
resetlocks()
end
elseif count == 2 then
if surfaceContains(mine_alcove_1.surface, "figure_crowern") and
surfaceContains(mine_alcove_1.surface, "figure_snail") and
unlock1 == 1 then
unlock2 = 1
playSound("lock_chest")
else
resetlocks()
end
elseif count == 3 then
if surfaceContains(mine_alcove_1.surface, "figure_crowern") and
surfaceContains(mine_alcove_1.surface, "figure_snail") and
surfaceContains(mine_alcove_1.surface, "figure_ice_guardian") and
unlock2 == 1 then
unlock3 = 1
playSound("lock_chest")
else
resetlocks()
end
elseif count == 4 then
if surfaceContains(mine_alcove_1.surface, "figure_crowern") and
surfaceContains(mine_alcove_1.surface, "figure_snail") and
surfaceContains(mine_alcove_1.surface, "figure_ice_guardian") and
surfaceContains(mine_alcove_1.surface, "figure_ogre") and
unlock3 == 1 then
unlock4 = 1
playSound("lock_chest")
else
resetlocks()
end
elseif count == 5 then
if surfaceContains(mine_alcove_1.surface, "figure_crowern") and
surfaceContains(mine_alcove_1.surface, "figure_snail") and
surfaceContains(mine_alcove_1.surface, "figure_ice_guardian") and
surfaceContains(mine_alcove_1.surface, "figure_ogre") and
surfaceContains(mine_alcove_1.surface, "figure_skeleton") and
unlock4 == 1 then
playSound("lock_chest")
mine_door_camo_2.door:open()
else
resetlocks()
end
else
resetlocks()
end
end
function resetlocks()
playSound("lock_incorrect")
unlock1 = 0
unlock2 = 0
unlock3 = 0
unlock4 = 0
end
function surfaceContains(surface, item)
for _,i in surface:contents() do
if i.go.name == item then
return true
end
end
end