Removing an item from alcove

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
xbdj
Posts: 32
Joined: Sun Dec 30, 2012 7:43 pm

Removing an item from alcove

Post by xbdj » Sun Dec 30, 2012 7:44 pm

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

User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Removing an item from alcove

Post by crisman » Sun Dec 30, 2012 8:21 pm

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

User avatar
Brodie301
Posts: 286
Joined: Sun Apr 08, 2012 6:00 pm
Location: Mississippi, USA

Re: Removing an item from alcove

Post by Brodie301 » Sun Dec 30, 2012 8:36 pm

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.
The FORCE is with me!!!

xbdj
Posts: 32
Joined: Sun Dec 30, 2012 7:43 pm

Re: Removing an item from alcove

Post by xbdj » Sun Dec 30, 2012 9:02 pm

Great - thanks both of you
"i:destroy" was what I needed! :-)

xbdj
Posts: 32
Joined: Sun Dec 30, 2012 7:43 pm

Removing the alcove...

Post by xbdj » Sun Dec 30, 2012 9:34 pm

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?

Hariolor
Posts: 42
Joined: Sun Apr 15, 2012 5:59 am

Re: Removing the alcove...

Post by Hariolor » Sun Dec 30, 2012 10:09 pm

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

xbdj
Posts: 32
Joined: Sun Dec 30, 2012 7:43 pm

Re: Removing an item from alcove

Post by xbdj » Sun Dec 30, 2012 10:39 pm

Thought about that too - but havent looked into how (if possible) it is done...

Hariolor
Posts: 42
Joined: Sun Apr 15, 2012 5:59 am

Re: Removing an item from alcove

Post by Hariolor » Sun Dec 30, 2012 11:11 pm

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.

xbdj
Posts: 32
Joined: Sun Dec 30, 2012 7:43 pm

Re: Removing an item from alcove

Post by xbdj » Sun Dec 30, 2012 11:23 pm

Nice thinking...you cant place a wall (?) so you place a secret door instead ;-)
Works nicely though!

Hariolor
Posts: 42
Joined: Sun Apr 15, 2012 5:59 am

Re: Removing an item from alcove

Post by Hariolor » Sun Dec 30, 2012 11:42 pm

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! ;)

Post Reply