Page 1 of 2
Removing an item from alcove
Posted: Sun Dec 30, 2012 7:44 pm
by xbdj
Is there a way to remove an item from an alcove with scripting?
I can only find the "addItem"...I would like the alcove to "eat" an item, when a button is pushed
Re: Removing an item from alcove
Posted: Sun Dec 30, 2012 8:21 pm
by crisman
Yes, you can, I'll give you an example:
Let's say you want to destroy a dagger in an alcove, then the script will be:
Code: Select all
funcion destroyDagger()
for i in alcove:containedItems() do
if i.name == "dagger" then
i:destroy()
end
end
end
Re: Removing an item from alcove
Posted: Sun Dec 30, 2012 8:36 pm
by Brodie301
But if you don't want the dagger to be permanently destroyed do it like:
eatalcove:addItem(spawn("dagger", nil, nil, nil, nil, "eatdagger"))
That will give unique name to the dagger, change alcove name to what you want as well, use crismans script and change name to "eatdagger" then tie button press to the script.
I believe that will work, not tested.
Re: Removing an item from alcove
Posted: Sun Dec 30, 2012 9:02 pm
by xbdj
Great - thanks both of you
"i:destroy" was what I needed!

Removing the alcove...
Posted: Sun Dec 30, 2012 9:34 pm
by xbdj
I would like to also remove the alcove all together - but when I destroy it with alcove:destroy(), the whole wall gets removed and only a black hole remains...
Is there a way to only remove the alcove, and not the entire wall?
Re: Removing the alcove...
Posted: Sun Dec 30, 2012 10:09 pm
by Hariolor
xbdj wrote:I would like to also remove the alcove all together - but when I destroy it with alcove:destroy(), the whole wall gets removed and only a black hole remains...
Is there a way to only remove the alcove, and not the entire wall?
best bet is probably to spawn a secret wall from the same wallset in the same place the alcove was
Re: Removing an item from alcove
Posted: Sun Dec 30, 2012 10:39 pm
by xbdj
Thought about that too - but havent looked into how (if possible) it is done...
Re: Removing an item from alcove
Posted: Sun Dec 30, 2012 11:11 pm
by Hariolor
xbdj wrote:Thought about that too - but havent looked into how (if possible) it is done...
This seems to work fine:
Code: Select all
function alcoveswap()
dungeon_alcove_1:destroy()
spawn("dungeon_secret_door",1,13,16,1)
end
edit: I had to place the secret door manually the first time to get the coordinates and orientation right...that was the only tricky part.
Re: Removing an item from alcove
Posted: Sun Dec 30, 2012 11:23 pm
by xbdj
Nice thinking...you cant place a wall (?) so you place a secret door instead

Works nicely though!
Re: Removing an item from alcove
Posted: Sun Dec 30, 2012 11:42 pm
by Hariolor
Yep...just be really careful when you destroy the alcove...if the same script gets called again somehow (e.g., by a pressure plate), or if another script somewhere else tries to do something with the alcove, it will crash the game because that alcove ID was already destroyed once!
