Really bogus reading from array issue [SOLVED!]

For questions about using Classic.

Post » Tue Jan 18, 2011 11:36 pm

Alright, I'm almost just about to give up on construct. There are a lot of neat features, but there are some basic logical aspects that are just plain broken. I'm probably going to have to come back when it gets its crap together. Anyways, I wonder if anyone can shed some light on this issue and perhaps save the day.

I've got an array filled with values. I can load the file and load in the variables, and it's just fine, the correct numbers always come up, and it's spot on. I have an event that says "when a value is equal to zero" and "when a value is less than a value on an array" then it does stuff.

It doesn't. I tried changing the "when a value is less than a value on an array" to "when a value is less than a value (which is the exact same number that comes up with the array)" and it works. I tried loading the value on the array to a separate value, and that still doesn't work. The event will not run.

This engine took me 15 minutes to write, test and perfect in MMF2, I've been working on this same simple concept in Construct for an entire week. It literally consists of 8 lines of code. The only reason I would keep at Construct is the fact that I can make a product that is visually superior with "less effort", but really there are some neat features in Construct that require little effort, but there defiantly are still a few things that really need work, and I'd say they are pretty important. So I'll give it one more chance.
B
2
S
1
G
1
Posts: 38
Reputation: 676

Post » Wed Jan 19, 2011 12:05 am

Post a cap, or a screen. Its kinda hard to tell from your description.
I will say if your using "for each" on the array it may give you issues if your using a z.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Jan 19, 2011 12:23 am



It's not an interfering piece of code, simply because there is not other code. All I want to do is grab a value from an array. It grabs the value, I can clearly see in the debug and if I input it to a string that it is the correct number, and that the other number is lower than it. But it just seems that anything grabbed from an array is rendered useless.
B
2
S
1
G
1
Posts: 38
Reputation: 676

Post » Wed Jan 19, 2011 1:12 am

Still kind of hard to figure out what you want to happen.
I can tell you I was able to grab data from my array "Array(3, Sprite.Value('an#'))", after I set it.
Just wondering, you do know that two conditionals in the same line are treated like "and"?
So if one is not true the event is skipped.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Jan 19, 2011 1:20 am

Yes, I do know that.
Basically, when that first value reaches zero, and that second value hasn't passed a certain value, then it resets the first value and adds one to the second value. Basically, it adds to a counter with a variable speed.
I was able to grab data from it too, but the data is useless. For instance, I place the number 284 into the array, load it into construct and it clearly says "yeah, I got 284" but it doesn't register that it is 284. If I simply just plug in 284 or place another variable that doesn't draw it's value from an array, then it functions perfectly fine, the first value counts down and when it reaches 0 it adds one to the second value and repeats until that second value equals 284.
B
2
S
1
G
1
Posts: 38
Reputation: 676

Post » Wed Jan 19, 2011 1:37 am

Perhaps its an int() issue
How often does your variable actually equal 0?
Not 0.1, or less than zero, or perhaps even str()
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Jan 19, 2011 2:10 am

it never has anything to do with floats, it's always an integer. The other thing I just thought of is that the array contains both strings and numbers. I know in MMF2 you have to choose either of the two (I usually choose text and just convert any values). Does a construct array have any of those restrictions? It still would be very odd that it would still return the correct value. Other than that, I'm stumped.
B
2
S
1
G
1
Posts: 38
Reputation: 676

Post » Wed Jan 19, 2011 2:32 am

From what I see here it's hard to tell what the issue is. For example, all the pv, are they text or number pv? Do they get mixed up? If you accidentally store a number as text, you will see the number in the debugger, but you can't compare it to a number as it is a text then, etc.

Also:
[quote="Horrendous Games":1szpwvzt]it never has anything to do with floats, it's always an integer.[/quote:1szpwvzt]
This isn't true. The fact that you use whole numbers doesn't make them integers. All numbers in Construct are always floats, and floats can get imprecise even when just calculating with whole numbers. That's due to the structure of floats.

But that's vague. Can't tell more without actually seeing a cap. Couldn't you setup a demonstration cap? Would help solving this.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Wed Jan 19, 2011 2:35 am

[quote:vccy17n5]Does a construct array have any of those restrictions?[/quote:vccy17n5]

That I don't know, but you can always use int(), or str() applied to what you retrieve from your array to be sure.
Other than that, I don't know what to tell you... frame rate issue? :P
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Jan 19, 2011 2:48 am

[quote="newt":11c71dkz][quote:11c71dkz]Does a construct array have any of those restrictions?[/quote:11c71dkz]

That I don't know, but you can always use int(), or str() applied to what you retrieve from your array to be sure.
Other than that, I don't know what to tell you... frame rate issue? :P[/quote:11c71dkz]
You may store text and numbers mixed in an array. Every array "cell" keeps the information if the data is a number or a text ([Array: Set index 1 to 20] stores the number 20, [Array: Set index 2 to "20"] stores the text "20")

EDIT: When running without debugger the result of 2 * Array(2) is 2 instead of 40, because multiplying the text is an error and therefore the text is treated as nothing.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests