Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Mikael on September 13, 2007, 08:37:56 AM

Title: Combining inventory items
Post by: Mikael on September 13, 2007, 08:37:56 AM
In my game, when two inventory items are combined to create a third item, I’ve been using this code:

Game.TakeItem("new_item");
Game.DeleteItem("first_item");
Game.DeleteItem("second_item");

My inventory slides down for a second when an item is added to it, and the problem with this method is that you can see all three abovementioned items for a split second in the inventory, which isn’t very nice.

I’ve tried to do it the other way around (that is, first deleting the two items that are combined, and then adding the new item), but when I do that, the new item is never added.

I’m probably just missing something blinding obvious here?
Title: Re: Combining inventory items
Post by: fireside on September 13, 2007, 02:48:27 PM
I use Game.DropItem("name") and I can't see any delay or anything.  I didn't even notice DeleteItem().
Title: Re: Combining inventory items
Post by: metamorphium on September 13, 2007, 02:59:09 PM
forums didn't work for me today so here goes again for the claritz.

the problem is as follows.

You have your item script attached to the item which you delete. That means that the script won't finish its execution.
There are several workarounds, one of them is using something like this:

1. you have to find out what item has the script attached and call drop instead of deleting to it. So for example if you
combine book and a knife to get a key and the script is attached to the book item, you'd do the following.

Game.Interactive = false;
Game.DropItem("book");
Game.DeleteItem("knife");
Game.TakeItem("key");
Game.DeleteItem("book");
Game.Interactive = true;

Can't check it right now, but this should work.
Title: Re: Combining inventory items
Post by: Mnemonic on September 13, 2007, 05:34:54 PM
Can't check it right now, but this should work.
Without the Game.Interactive bits, though. They are unnecessary in this case, and since the DeleteItem call will terminate the script, the game would stay non-interactive forever.
Title: Re: Combining inventory items
Post by: Mikael on September 13, 2007, 06:26:49 PM
You're all right. "DropItem" does the trick. There's really no need to involve "DeleteItem" at all (for me at least).

Thanks!

Mikael