Scripting Problem: Grimrock Alchemist
Posted: Wed Sep 19, 2012 1:06 am
Hey,
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.
The pressure plates connect to the checkName function and the alcoves to the checkItem function set on any. It works pretty well. The only problem is, beside the visual aspect, when you put more items into an alcove the script doesn't work anymore. You can just take all items and be on your way. So to prevent this, my idea was to store the last item (the second) into a variable and put it back to the mouse pointer.
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.
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.