How exactly would I got about checking which item(s) is/are in an alcove?
The documentation mentions Alcove:containedItems() but I can't for the life of me figure out how to use it.
Code: Select all
function checkAlcoveForItems()
-- change these variables to match your alcove's ID and the item you want to test for
local itemName = "dagger"
local alcoveID = dungeon_alcove_1
-- iterate through all the contained items on alcove, checking for a matching name
for i in alcoveID:containedItems() do
if i.name == itemName then
itemFound()
else
itemNotFound()
end
end
end
-- run this script _once for each item_ with a matching name
function itemFound()
playSound("level_up")
end
-- run this script _once for each item_ without a matching name
function itemNotFound()
spawn("poison_cloud", party.level, party.x, party.y, 0)
end
Code: Select all
-- a helper function which returns true if alcove contains the given item
function containsItem(alcove, item)
for it in alcove:containedItems() do
if it.name == item then
return true
end
end
return false
end
-- example usage
if containsItem("alcove1", "dagger") then
print("alcove contains a dagger")
else
print("alcove does not contain a dagger")
end
Code: Select all
function gemCheckblue(alcoveblue, blue_gem)
for i in alcoveblue:containedItems() do
if i.name == "blue_gem" then
return true
end
end
return false
end
if gemCheckblue("alcoveblue", "blue_gem") then
doorblue:open()
else
doorblue:close()
end
Code: Select all
function gemCheckblue()
for i in alcoveblue:containedItems() do
if i.name == "blue_gem" then
doorblue:open()
else
doorblue:close()
end
end
end
Code: Select all
function gemCheckblue()
for i in alcoveblue:containedItems() do
if i.name == "blue_gem" then
doorblue:open()
else
doorblue:close()
end
end
end
Code: Select all
else
dosomething