What is the best way to do this? (item system)

0 favourites
  • 7 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • I'm prototyping this kind of visual novel. I wanted that in some part of the game, there were option of picking up itens in text format like "take sword [1]","take salt [10]", "take piece of bread [3]. And when the text objct was clicked, it would subtract the quantity of the "item", and when it was 0, the text object would disappear.

    I'm ok with adding the item to the inventory which is an array

    but I don't know how I would quantify the itens around the game. Let me explain

    For performance reasons, I've only created 4 text objetcts that could be clicked as a item. And I would like that this text object would "carry the Id" and quantity of every item in every part of the game (without me coming back to the place, and the item was back there)

    I tought about using array to carry the itens quantity of each scene. But I would have to set a xy value for each item in every scene. So I was wondering if any of you guys have a better way to do this.

    I'm not the best at using construct, so I'm just searching for a superficial explanation of how I would have to do this if is too complex. Don't mind me if I don't understand your answer. I know an inventory system and item system can be very complex, but I'm trying to make one as simple as possible for learning purposes.

    Tagged:

  • Hi. I tried to understand your question, I'm not sure I did.

    You can do this.

    When spawning an item on the level create a text object and it writes 2 local variables, the first is the type of item for example bread and the second is the quantity for example 10.

    And when the player picks it up and clicks on it you put in the inventory data from these two local variables text object and delete the object itself.

    Maybe that's not what you need or maybe I didn't explain it clearly.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you can't do it, send me your example with inventory and I'll add it.

  • I think you understood. I did not know about local variables. I'm using it now just to track the quantity of each text object. But there is a problem. The local variables value don't get subtracted when I click the text object. It works with global variables and I don't know why.

  • Just figured it out. It was that I was not putting the local variables as "static"

  • Just figured it out. It was that I was not putting the local variables as "static"

    You misunderstood me, I meant the local variables that the text object has.

  • Hahaha I think It's a better idea ! haha, I'll try, thank you very much!

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