Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Combining inventory items  (Read 3121 times)

0 Members and 1 Guest are viewing this topic.

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Combining inventory items
« 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?
Logged

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: Combining inventory items
« Reply #1 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().
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Combining inventory items
« Reply #2 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.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Combining inventory items
« Reply #3 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.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Re: Combining inventory items
« Reply #4 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
Logged
 

Page created in 0.031 seconds with 23 queries.