I wanted to (kinda, sorta) create a room, where you can get an item by offering an item of equal value. So I created three alcoves with three hidden pressure plates in front of them and a lua script.
Code: Select all
function checkName()
for s_item_1 in alcove_1:containedItems() do
item_1 = s_item_1
end
for s_item_2 in alcove_2:containedItems() do
item_2 = s_item_2
end
for s_item_3 in alcove_3:containedItems() do
item_3 = s_item_3
end
end
function checkItem()
print(item_1)
local alcoveCount = alcove_1:getItemCount()+alcove_2:getItemCount()+alcove_3:getItemCount()
if alcoveCount <= 1 then
if item_1 == getMouseItem() then
alcove_1:addItem(item_1)
elseif item_2 == getMouseItem() then
alcove_2:addItem(item_2)
elseif item_3 == getMouseItem() then
alcove_3:addItem(item_3)
end
setMouseItem()
hudPrint("Something of equal value must be offered.")
end
checkName()
end
How can I read out the last item and how can I remove it from an alcove using a script?
If this works, it should even be possible to turn this into a Zelda-esque shop.