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.]
Yet another alcove puzzle problem (scripting)
- SpiderFighter
- Posts: 789
- Joined: Thu Apr 12, 2012 4:15 pm
Yet another alcove puzzle problem (scripting)
Last edited by SpiderFighter on Thu Nov 29, 2012 3:51 pm, edited 2 times in total.
- JohnWordsworth
- Posts: 1397
- Joined: Fri Sep 14, 2012 4:19 pm
- Location: Devon, United Kingdom
- Contact:
Re: Yet another alcove puzzle problem (scripting)
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
endMy Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
- SpiderFighter
- Posts: 789
- Joined: Thu Apr 12, 2012 4:15 pm
Re: Yet another alcove puzzle problem (scripting)
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
endEDIT: 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