Random grid of squares

For questions about using Classic.

Post » Sun May 24, 2009 3:41 am

I'm trying to make a 5x5 grid of text files to fit into a grid of squares. This should be simple enough but every step of the way I'm blocked by a lack of features.

I first put all possible texts into a listbox object. Then I created the text files with 2 loops and gave them unique values. This worked and displayed the text from the listbox properly but was not random.

I tried to find a way for the listbox to move its lines around but I can't find a way to move existing lines at all. Then, I tried to create a duplicate listbox object and insert lines from it into random indexes (Not that that would produce very much randomness). It didn't work, as if the index number exceeded the existing line number it ignored the action.

I then tried to skip the inserting, make 25 dummy lines, and then randomly rewrite those lines from the original listbox object. The only problem is there's no way to rewrite lines that I can find. "Set line data" doesn't seem to do anything.

There has got to be an easier way of doing this, but man I hate the listbox object...
B
4
G
6
Posts: 32
Reputation: 1,514

Post » Sun May 24, 2009 4:36 am

Hmm, I have no clue what you are talking about mr.

[quote="dustingunn":3nk9qe5h]I'm blocked by a lack of features.[/quote:3nk9qe5h]
No. Go wash your hands.

But seriously, post a cap or a picture or something! :mrgreen:
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Sun May 24, 2009 5:47 am

[quote="dustingunn":11jm5aen]Then, I tried to create a duplicate listbox object and insert lines from it into random indexes ... It didn't work, as if the index number exceeded the existing line number it ignored the action.[/quote:11jm5aen]

Not sure what you're trying to do here, but if the insert line action only takes an index from 1 to number of lines, then random(number_of_lines) + 1 should insert to a random, valid place and will be totally randomly shuffled.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Sun May 24, 2009 11:06 am

The ignoring of inserting lines if it's beyond bounds is standard Windows behavior. What is possibly necessary is a virtual list object which can be sorted and shuffled, then iterated. Until then there are many different ways to do what you want.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sun May 24, 2009 12:54 pm

[quote="Davioware":1n5yc8rd]Hmm, I have no clue what you are talking about mr.

[quote="dustingunn":1n5yc8rd]I'm blocked by a lack of features.[/quote:1n5yc8rd]
No. Go wash your hands.[/quote:1n5yc8rd]

What do you mean "no." I was talking specifically about the listbox object here, so unless you know something I don't, it doesn't have the ability to rewrite existing lines or to rearrange them.

Anyways, it turns out inserting lines from one listbox to another with random(number of lines) as the index does properly shuffle them, so thanks, Ashley.
B
4
G
6
Posts: 32
Reputation: 1,514

Post » Mon May 25, 2009 1:57 am

Sorry, didn't know that you were referring specifically to the listbox object :mrgreen:. But.. As you see, there was a workaround.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests