Trouble picking the same instance of a text object in a container on my inventory system.

1 favourites
  • 4 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • So I've spent the last couple of days putting together a little test project to see if I can get an inventory system working & I believe I am 99% of the way there.

    The issue I am having is that when the same item dropped on another of itself the excess value should be displayed on the item's text object when it's returned to it's previous position (it's in a container). I've tried various methods of picking the other but cannot seem to get it.

    I have it set up so you can change the value manually on the item (on item clicked) so I know it's value has been updated correctly, just not the text object itself.

    Here's the project file, I've bookmarked the issue & notated everything.

    https://drive.google.com/file/d/1n17FrkRUPDvmoA9qLQkrfrbIOrCOyLN7/view?usp=sharing

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It doesn't work on the actions because text_value is in a container with item and not items. You could try bringing out the set text action to either every tick although not really advised for too many text objects, or having a function you run every time you change the inventory that picks all text_value and sets them to items.value to kind of refresh them. You always want the text to be correct so imo better you refresh it often to have some control.

  • like lionz said, the easiest way is to use a function. (I really don't like updating text objects every tick).

    I simplified the logic in your example a bit and added a fuction to update the correct text_value instance.

    In event 6 you don't need to pick the top items instance because the event is triggered by drag-and-drop so only one instance is already selected.

    In event 8 you were checking if "items" value was >= stack_size, but that should be "item".

    I calculate surplus by adding the item.value + items.value - stack_size, if that results in a negative number then return zero. This can be done in one action using Max()... and use Min() to set the new value to item.value + items.value, or stack_size, and then use the function to update the text_value instances.

    https://www.rieperts.com/games/forum/InventoryTest2.c3p

  • Thanks a lot guys, I have learnt much today!

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