Destroying and then respawning a key puzzle item
Posted: Sat Oct 06, 2012 5:44 am
Hi folks,
I am trying to write some code to make sure a puzzle doesn't become impossible to complete.
I have a bunch of pits with alcoves all around that require gems. Problem is, if you place a gem in an alcove then fall into a pit after having the access to the alcove removed, when you walk back around to the puzzle you are cut off from the gem (i.e., puzzle cant be completed)
So I figured that a pressure plate leading up to the puzzle could trigger a check on certain alcoves to see whether a certain gem is present.
If it is, it is destroyed and respawned at the beginning of the puzzle - so no matter if you fall down a pit (or teleported away) - you are never cut off from the puzzle's key item.
Here is the code I tried:
However, nothing happens
The pressure plate (hidden) is connected to the script
Ultimately, I will need about 4 checks to take place once the party walks over the pressure plate...
Helpful nudges or directions would be greatly appreciated!!
Thankyou
I am trying to write some code to make sure a puzzle doesn't become impossible to complete.
I have a bunch of pits with alcoves all around that require gems. Problem is, if you place a gem in an alcove then fall into a pit after having the access to the alcove removed, when you walk back around to the puzzle you are cut off from the gem (i.e., puzzle cant be completed)
So I figured that a pressure plate leading up to the puzzle could trigger a check on certain alcoves to see whether a certain gem is present.
If it is, it is destroyed and respawned at the beginning of the puzzle - so no matter if you fall down a pit (or teleported away) - you are never cut off from the puzzle's key item.
Here is the code I tried:
SpoilerShow
function gemCheckRed()
local itemFound = false
for i in alcoveGemSecret1:containedItems() do
if i .name == "red_gem" then
itemFound = true
end
end
if itemFound then
red_gem:destroy()
spawn(("red_gem"),6,21,8,0)
end
end
local itemFound = false
for i in alcoveGemSecret1:containedItems() do
if i .name == "red_gem" then
itemFound = true
end
end
if itemFound then
red_gem:destroy()
spawn(("red_gem"),6,21,8,0)
end
end
The pressure plate (hidden) is connected to the script
Ultimately, I will need about 4 checks to take place once the party walks over the pressure plate...
Helpful nudges or directions would be greatly appreciated!!
Thankyou