Don't DO This:

Discussion and feedback on Construct 2

Post » Wed Sep 10, 2014 8:58 am

Fimbul wrote:@Aphrodite and @newt: I don't think you guys get the issue:

He is accessing properties of an object that exists, but has no instances at the time of the referencing.

think of it like this:
  • <There are zero balls>
  • Make all balls be blue
  • Create a ball
  • Ball unexpectedly comes out white

I don't consider this a "bug" per se, but @Ashley might want to do something about this. Either make it so that you can write defaults, or make construct give an error if the object you're writing to has no instances (I think this last approach would be very hard to implement).



For a situation like this it would be nice if the debugger could provide you with a list of warnings when a situation like this arose. For example "Warning: this operation has no object instance". However as @fimbul said, I'm not sure how you'd do it.

As Ashley said, the behaviour is not surprising, but it is hard to debug when it accidently arises.

PS: didn't know about the physics object behaviour.


I don't think changing the defaults is a good idea
B
7
S
3
G
1
Posts: 184
Reputation: 1,352

Post » Wed Sep 10, 2014 11:35 am

rho wrote:For a situation like this it would be nice if the debugger could provide you with a list of warnings when a situation like this arose. For example "Warning: this operation has no object instance".

I think the Construct Classic debugger did something like this, but it wasn't especially useful. In a long event sheet the "zero instances action" can happen several times per tick for innocuous reasons, and that ends up spamming the log with huge amounts of irrelevant data, making it hard to pick out the cases where it really is a problem.
Scirra Founder
B
397
S
236
G
88
Posts: 24,412
Reputation: 194,526

Post » Wed Sep 10, 2014 5:00 pm

@Fimbul @Aphrodite - Yes, that is indeed true. You have to reference objects that don't necessarily exist. And I don't think that changing default values at runtime would be wise... but I was original only thinking of changing global states (such as physics or pltformer gravity direction; something you really don't need an object to do, but do.

@Aphrodite - On create is a lovely event trigger, but there are some problems with it that I can't get around. For example: I can't send on create any parameters so I don't know what object spawned the object if I am dealing with compound objects. Thus, if I just run on create logic, I lose the the ability to have the creator in my list of objects.

I am not saying it should be different, I 'm just giving a shout out to help others not make the mistake I did. I literally had a problem for several months, and instead of realizing I made a call in the wrong place, I spent hours trying to figure out why physics wasn't working as expected. I found problems that weren't the problem and changed things that didn't need changed.

@Ashley - Thanks, that makes sense. High five for all your hard work. Construct 2 is the bomb.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: AnimH01 and 13 guests