Other way of dropping items in this inventory capx

0 favourites
  • 5 posts
From the Asset Store
Now you can drop everything in your game with sound :)
  • Hello, about a year ago, EncryptedCow linked me a very nice text inventory example capx. I have modified it so that when function "add_item" is called, it adds the current value of this global variable "itemID_to_add" to an inventory slot.

    Right now as it is, to take away an item, the text object displaying said item must be right clicked. However, i'd like to change it so that when a "subtract_item" function is called, then the value of the global variable "itemID_to_subtract" is taken away from an inventory slot that contains said item.

    Could someone help me find out how to do what I need? At it's current state, I can only take away items when I right click the text. But I need it so that I can subtract it at any time, like when purchasing something it takes away some coins or a door takes away a key, you know?

    Here is the capx https://dl.dropboxusercontent.com/u/30826419/modified%20text%20inventory.capx

    I've made it so that when you press A, "add_item" is called. When you click on a color, the value of its "itemID" instance variable is copied to the value of "add_item", and there is text on the bottom right that will tell you what items are to be added and subtracted, in case you're not in debug mode. Thanks!

  • From what I understand, you want to tell the game what item ID id is to be dropped then the system finds which slot has the item and drops it? If thats the case you can drop an item the same way its picked up. Just go through the array by X axis (or whichever contains the IDs of the slot, I havent had this thing open since it was posted.) Just check which ID the slot contains and subtract the amount to remove. If the slot contains less, then keep going through the array until you find more. If the slot becomes empty after you remove the items, set the ID of that slot to an empty value.

  • I've been trying as you said, but when I do it I'm only able to subtract things from the first slot and nothing else.

  • You need to keep track of how many youve taken away, and how many you still need to take away. Do your subtracting inside of the array loop so that you can keep going if you still need to remove more.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Can you show me what you mean in the capx?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)