How do I create a count box for how many lines are in my array?

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello folks!

    I am trying to make something perhaps kind of odd for Construct - an inventory system, but not for a game, as in real life barcode scanning inventory haha.

    I have written a nice code for this in Excel and it works well, but I want to see if I can do something similar in Construct so I can have a better look than Excel (more visual customization).

    So far I have a text box tied to an array that then automatically exports to a CSV.

    What I am looking to do is have another text box next to the barcode textbox and have it keep count of how many lines have been scanned in (to give a total item count).

    I have ideas using variables and comparing the array height, but cannot seem to wrap my head around it.

    Any thoughts?

    Thank you!


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The Array in Construct can use Push. You can start with a 0 size array and every time you scan you can Push a new instance into the array. To delete an instance you just use delete. These will both edit your Array Width (size).

    To capture the current size simply create a text object. And every (whatever timing you decide) setText to Array.Width.

    Potential issues:

    Changing your array size means whatever you had in index 15 at one time may be else where at a later time. So you would need to add additional width/depth to the array to add an ID.

  • You are awesome!

    I had no idea about pushing, works perfect. I ended up just pushing every time the "enter" key is pressed, because barcode scanners automatically hit enter after each scan.

    Thank you so much! :D

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