0-indexed vs 1-indexed

New releases and general discussions.

Post » Mon Feb 23, 2009 8:13 am

Perhaps there should be a separate call for for a random pick of either true of false, 1 or 0.
Something like Rndbool?
Any way there are time's like when you want a random angle where zero might be ok, and there are times when zero will not do like in getting x, or y, but currently setting that up right is a bit confusing.
How about Rndbool for 0 or 1
Rndnoone for starting with zero
and just Random for starting with 1?

ehh then again Randnoone(1) would get the same as Rndbool.

Dam you guys are confusing as hell... :lol:
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Thu Feb 26, 2009 1:59 pm

How about letting it accept characters as well, IE:

random('C', 'G') gives CDEFG

if char get ASCII code, random(ascii1, ascii2) etc.
Image Image
Scirra Founder
B
125
S
37
G
25
Posts: 3,945
Reputation: 44,922

Post » Thu Feb 26, 2009 5:11 pm

Hi, I'm new to Construct but proficient with many programming languages.
Here's my point of view: I agree with changing all loops to 1-indexed when possible.
As for random() I don't see a reason to change it, either leave it like that or force the use of two parameters
B
3
S
1
G
3
Posts: 45
Reputation: 1,140

Post » Sat Feb 28, 2009 5:56 am

Would just like to point out that 99% of my caps use the Array Object. I have 267 caps in total. 99% of 267 rounds out to 264 caps.

Assuming it takes an average of about a minute per cap, I am looking at 4 hours, 24 minutes of time wasted fixing my files.

Can we at least have this as an option within the object itself rather than a permanent change? Or at the bare minimum still supply a 0 indexed array object as well as a new 1 indexed version?

Thanks.


EDIT: The above post was made due to frustration with a change that seemed unnecessary and has subsequently broken the majority of my cap files. I'll deal with it, even if no changes are made. But I'm letting it be known that I don't exactly approve.

To understand the scope of my annoyance, I use the array object for things as simple as private variables within a function, and for things as complex as the rotation matrix, vertex information, and Z buffer in my 3D engine. This is not something I can fix in a few scant minutes.
B
2
S
2
G
5
Posts: 108
Reputation: 1,866

Post » Sat Feb 28, 2009 8:08 am

If you compile your projects with older versions, they will still work. But if you want to open your projects and update them with newer version of construct, then yeah, you have to fix everything...
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sat Feb 28, 2009 11:23 am

You could copy/paste the old array.csx from a previous install into your plugins dir; you don't have to use the new one.

It's a much needed change though, being the only object which was 0 based, there's no doubt it could cause confusion or lack of clarity. Most changes we make are bound to break something now, unfortunately, but they're nearly always for the better.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sat Feb 28, 2009 3:30 pm

[quote="Rich":mw5ke90w]You could copy/paste the old array.csx from a previous install into your plugins dir; you don't have to use the new one.[/quote:mw5ke90w]
Yeah, I actually thought of that after posting. :)

As I said though, I'll deal with it either way. I've always been a big advocate of consistency in programs/programming so I believe it is a welcome change overall.
B
2
S
2
G
5
Posts: 108
Reputation: 1,866

Post » Sun Mar 01, 2009 5:34 pm

It's the sort of thing that's way better to bite the bullet now rather than further down the line.
Image Image
Scirra Founder
B
125
S
37
G
25
Posts: 3,945
Reputation: 44,922

Post » Sun Mar 01, 2009 8:47 pm

So things now start from 1?
Everything else starts from 0...
B
3
S
2
G
5
Posts: 301
Reputation: 2,302

Post » Sun Mar 01, 2009 9:06 pm

It shouldn't do, everything should start from 1, with the exception of random(). If you find anything else 0-indexed, report it as a bug.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

PreviousNext

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 4 guests