Page 1 of 1
Yet another alcove puzzle problem (scripting)
Posted: Wed Nov 28, 2012 9:39 pm
by SpiderFighter
I have the puzzle set up, and it's working properly. 4 items placed each in their proper alcove nets the end result I want. However, I want something bad to happen if the player has the 4 items in the wrong alcoves (pits open up beneath the player). The problem, as I'm sure you can see where this is going, is that as soon as a player sets an item in an alcove, right or wrong, the pits open because the other alcoves are empty and, therefore, the qualifications of the puzzle are not met.
So, my question: is there a way to hold off the check until all four items have been placed (regardless of order)?
[EDIT: I thought about using a counter to call the check script, but then the items couldn't be checked because they're already placed. Hmmm.]
Re: Yet another alcove puzzle problem (scripting)
Posted: Wed Nov 28, 2012 9:47 pm
by JohnWordsworth
I might be mis-understanding the question, but can you not just do (assuming you have a method
containsItem(container, itemId))...
Code: Select all
if (alcove1:getItemCount() > 0) and (alcove2:getItemCount() > 0) and (alcove3:getItemCount() > 0) and (alcove4:getItemCount() > 0) ) then
if containsItem(alcove1, "item1_id") and containsItem(alcove2, "item2_id") and containsItem(alcove3, "item3_id") and containsItem(alcove4, "item4_id") then
-- Open Door
else
-- Open Pit
end
end
Re: Yet another alcove puzzle problem (scripting)
Posted: Wed Nov 28, 2012 9:53 pm
by SpiderFighter
JohnWordsworth wrote:I might be mis-understanding the question, but can you not just do (assuming you have a method
containsItem(container, itemId))...
Code: Select all
if (alcove1:getItemCount() > 0) and (alcove2:getItemCount() > 0) and (alcove3:getItemCount() > 0) and (alcove4:getItemCount() > 0) ) then
if containsItem(alcove1, "item1_id") and containsItem(alcove2, "item2_id") and containsItem(alcove3, "item3_id") and containsItem(alcove4, "item4_id") then
-- Open Door
else
-- Open Pit
end
end
Here's what I have:
Code: Select all
function sfjndalcoveContents(entity, item)
for i in entity:containedItems() do
if i.name == item then
return true
end
end
return false
end
function sfjndalcoveCheck()
if sfjndalcoveContents(sfjndalcove_1, "spoiler_item_1") and
sfjndalcoveContents(sfjndalcove_2, "spoiler_item_2") and
sfjndalcoveContents(sfjndalcove_3, "spoiler_item_3") and
sfjndalcoveContents(sfjndalcove_4, "spoiler_item_4")
then
playSound("discover_spell")
spawn("pressure_plate_hidden", 1, 13, 21, 0, "sfjndplate01")
sfjndplate01:addConnector("activate","sfjnd_spawner_16","activate")
sfjndplate01:addConnector("activate","sfjnd_spawner_17","activate")
sfjndplate01:addConnector("activate","sfjnd_timer_26","activate")
else
sfjnd_port_1:close()
sfjnd_temple_pit_14:open()
sfjnd_temple_pit_15:open()
sfjnd_temple_pit_16:open()
sfjnd_temple_pit_17:open()
end
end
Oh, so I'm missing the getItemCount. I see. Thanks, John! I'm going to go check it out.
EDIT: That did it, thanks! For anyone who finds this later, remove the extra parenthesis above, or you'll get an error.
Thanks so much, John! Scared the crap out of me when I dropped that 4th item in the wrong spot and the pits opened up! lol