Check-boxes and arrays.

Get help using Construct 2

Post » Fri Jun 15, 2012 4:49 am

EDIT: I think I got it working on my own. But rather than leaving this to rot and remove any kind of usefullness, I shall explain how I got this working.

Each checkbox has three variables. Type, Use, and Checked. Type is the group it is in, use is numbered 1-last counting up by ones, and checked is a Boolean to test if it has been checked or not.

We have two arrays. One is full of the items we want to display or generate, called ITEMS, the second is a copy of the first one in terms of size, but holds Boolean values, called CANUSE.

When we check the boxes we want and click "Generate", it will loop through the whole array of CANUSE, but check it's CurX and CurY values to the Type and Use of the checkboxes. If the Checkboxes Type and Use are equal to the array position it is at, then it sets its value to the boxes 'Checked' variable.

Once the array is finished (checked by having a variable count up in the 'For Each Element' condition, then if the counter is equal to Width*Height of the array) it will run a While loop. This whole time, it randomizes a variable to how many checkboxes of that type there are. It uses this to randomly pick a value from the CANUSE array. When it finds a value that is equal to one, it will pull the equivalent from ITEMS and append it to the text, and stop the loop.

Here is the event sheet:

Also, the ==TYPE== and ==MATTER== thing is commented because they are for different groups.

Whooo! Glad I got that sorted finally. I hope this can help someone having a similar issue!Phobos0022012-06-15 15:35:29
Posts: 202
Reputation: 5,235

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Mayfly, staleevolution and 18 guests