Will the top level design be removed in C3?

Discussion and feedback on Construct 2

Post » Wed Sep 30, 2015 12:50 pm

Wonder if the top level design/problem will be removed from C3 as its really not good in my opinion. Especially because its kind of encourage, especially new users, to solve problems using wait = 0, which is a bad way to handle problems in general, even though in some cases its really difficult to avoid it. But every time you do or are forced to do it, you are almost 100% certain that you are going to have problems later on. So wondering if that design is going to be removed from C3? So the Wait functionality can be removed as well, for good? :D
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Wed Sep 30, 2015 12:55 pm

i don't see why anyone would use wait(0) since it calls the wait function not to wait. but i've had a couple of good wait usages and i find it pretty usefull.

also i don't see what is your "top level design" problem? if you are thinkin' on gui/UI i don't see how removing that would solve your problems
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
42
S
14
G
12
Posts: 624
Reputation: 9,421

Post » Wed Sep 30, 2015 1:19 pm

saiyadjin wrote:i don't see why anyone would use wait(0) since it calls the wait function not to wait. but i've had a couple of good wait usages and i find it pretty usefull.

also i don't see what is your "top level design" problem? if you are thinkin' on gui/UI i don't see how removing that would solve your problems

What im referring to is the problem with objects not existing before next top level when created, which you can "solve" by throwing in a wait = 0. Which is part of the top-level design problem or what to call it, there are other issues which can be solved with just throwing in waits.
But a functionality in the form of a wait is a poor design decision in my opinion in general. Especially when its used to solve varies issues like working with newly created objects, but more, why on earth would you ever make a design that would force the program to wait? Unless you actually want the user to wait, but then there are timers way better suited for that, as they have built in triggers. I don't disagree with you that waits can be useful, but this is not because they are needed, its because C2 is designed the way it is. But if that was redesigned you wouldn't have to use Waits at all. It have nothing to do with the UI/GUI.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Wed Sep 30, 2015 1:26 pm

Wait( 0 ) is good to use as an Event Sheet LateUpdate. An update that occurs after everything else in EventSheet and Plugins, yet also triggers before the next tick. It's actually very helpful in a few instances as it's one of the few techniques that allows some measure of finite control. However it is a problem due to how it works. Personally the only time to use wait are for automated sequences. if at any point there is a possibility of interuption or reset, then wait will hurt. It's best to use Timer.

I'm not sure about the top level reference either. Are we talking about UI or are we talking about how all programming is in C2 is Functional and not say Object Orientated, which would be I suppose downward up.
-------------------------
Replied before I sents.

Wait doesn't hold the program. Wait encapsulates the current set of information and starts a JS Timer to execute after the given period of time. However once doing so obliviously moves that piece of code out of our control.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Wed Sep 30, 2015 1:36 pm

Actually wait has it's uses, you just haven't encountered them yet.

Like pressing a sprite button. You switch the buttons animation, wait one second, and switch it back.
Having to also set up a trigger to switch it back is as silly as wait(0).

or like not allowing a key to work for 3 seconds after it's pushed:
Image

(I didn't already have an image of the first example.) ;-)

Wait could be made clearer to the user, when you make a wait action, it immediately forms a little subevent, so that it's clear the only thing waiting is the code in that subevent. (however making that kind of subevent look right might be a challenge.

Knowing how things work on the back end makes it obvious why you "wait" until the next tick, but I suppose it could be built into the problem events. (they all include a hidden wait(0) the user doesn't know about.)
B
230
S
62
G
33
Posts: 902
Reputation: 40,323

Post » Wed Sep 30, 2015 4:27 pm

jayderyu wrote:It's actually very helpful in a few instances as it's one of the few techniques that allows some measure of finite control. However it is a problem due to how it works. Personally the only time to use wait are for automated sequences. if at any point there is a possibility of interuption or reset, then wait will hurt. It's best to use Timer.

I'm not sure about the top level reference either. Are we talking about UI or are we talking about how all programming is in C2 is Functional and not say Object Orientated, which would be I suppose downward up.
-------------------------
Replied before I sents.

Wait doesn't hold the program. Wait encapsulates the current set of information and starts a JS Timer to execute after the given period of time. However once doing so obliviously moves that piece of code out of our control.

As I said its not because Wait() can't be useful, my point is that its shouldn't be needed at all, at least not when it comes to solving problems, or what to say.

I don't mean like if you throw in a wait of 10, then nothing will happen in the program for 10 seconds. What I mean is that you create a "fake" break in your program that shouldn't be needed.

Paradox wrote:Actually wait has it's uses, you just haven't encountered them yet.

Like pressing a sprite button. You switch the buttons animation, wait one second, and switch it back.
Having to also set up a trigger to switch it back is as silly as wait(0).

or like not allowing a key to work for 3 seconds after it's pushed:

Using wait for something like a button and the audio in your examples can be ok. But you might as well hook up a timer. That when its up, triggers and you act on that. So my point in general is not that Wait() is broken and can't be used at all. But again it shouldn't be necessary to use to solve problems. You using it for a button or for the audio is fine. But you are just showing how it can be useful and that is not what im talking about.

So to show you the problem and this is of course a simple example, but if you have a huge game and you solve problem using Wait() its could/will cause problems.

Imagine we have a game where we spawn a Unit (Red square) based on this unit we want to spawn something else (Green square), but depending on some settings we might spawn different things. In this example I have only added one which are the Green square, just to keep it simple. But imagine it could be a Blue, Yellow, Black or a Pink square, all depending on some value when the Red square is spawned.

So the Red square have two variables A and B and we assume that based on whatever, we ended up spawning the Green Square and we store the UID of the Red Square in the Green one. So when you hit the button to create the squares, we want Red Sq. A to be 1 and B to be 2 and write the UID stored in the Green Sqr. as well.

In the top part of the image when I click the button it fails so all it writes is 0.

Adding a Wait(0) in the Green square create event and then trying again, will solve the problem and now the values are correctly read and written to the text objects.

Image

So Wait(0) can be (mis)used to solve problems like this to fake It going to top level, instead of just having the Red and Green squares exist straight away, so the wait is not needed. So the code would do the same thing but the Wait(0) could be removed.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Wed Sep 30, 2015 4:41 pm

O star of layout- set text to "hi"
-wait 5 sec
-set text to "This is an example of a timeline"
-wait 5 sec
-set text to "wait can do other things besides text"
-wait 5 sec
-set text to "like make a trigger out of a variable"
-wait 1 sec
-set variable "dostuff" to 1
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Wed Sep 30, 2015 5:08 pm

newt wrote:O star of layout- set text to "hi"
-wait 5 sec
-set text to "This is an example of a timeline"
-wait 5 sec
-set text to "wait can do other things besides text"
-wait 5 sec
-set text to "like make a trigger out of a variable"
-wait 1 sec
-set variable "dostuff" to 1

And again :D Wait in itself is not a problem and yes there are lots of examples of how it can be used And your example is also a fine way to use it, but again it could be done with a Timer just as well. But its fair enough to leave Wait and not remove it, its not really that huge of a problem.
But If you as in my example have to create several objects which depends on each other in one go, then its not all that simple as it allow Wait() to be misused, not because there is something wrong with wait itself, but because C2 when creating objects doesn't make them available before the next top level.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Wed Sep 30, 2015 5:57 pm

i see what you're tryin' to do.

you want to use the object you created at the same moment as it was created (in the same tick).

so basically what you do is use wait ( 0 ) to go to next tick and continue where the it left off (at that function).

by default that is the expected behaviour - suggesting that your desing is bad. and probably top level won't be removed any time soon, but if you design your game good it's not even needed. also if you're aiming for the instant spawning of more elements that need to be "stuck together" and you want to do that in one tick - use containers. that's what they're used for. also "on created" is used for defining start state of an created object. but only after one tick is done your object gets UID, therefore you never had any output without wait(0).
also, if you aim 60+ fps, have in mind that 1 tick is 0.016s (1/60)s which is really fast, and if you pick your objects in next ticks that won't look / work wierd. i know it takes some time to design the game correctly, but it works good.


also what newt told you - do an action and if you want to set up some basic object items do it on created, otherwise use wait for some behaviours/events in your game that need to happen after some time /at some defined moment. instantly picking item that you created won't do much since that tick you're in has to PASS for object to really appear there.
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
42
S
14
G
12
Posts: 624
Reputation: 9,421

Post » Wed Sep 30, 2015 6:14 pm

saiyadjin wrote:i see what you're tryin' to do.

you want to use the object you created at the same moment as it was created (in the same tick).

so basically what you do is use wait ( 0 ) to go to next tick and continue where the it left off (at that function).

by default that is the expected behaviour - suggesting that your desing is bad. and probably top level won't be removed any time soon, but if you design your game good it's not even needed. also if you're aiming for the instant spawning of more elements that need to be "stuck together" and you want to do that in one tick - use containers. that's what they're used for. also "on created" is used for defining start state of an created object. but only after one tick is done your object gets UID, therefore you never had any output without wait(0).
also, if you aim 60+ fps, have in mind that 1 tick is 0.016s (1/60)s which is really fast, and if you pick your objects in next ticks that won't look / work wierd. i know it takes some time to design the game correctly, but it works good.


also what newt told you - do an action and if you want to set up some basic object items do it on created, otherwise use wait for some behaviours/events in your game that need to happen after some time /at some defined moment. instantly picking item that you created won't do much since that tick you're in has to PASS for object to really appear there.

Think you are missing the point. Using containers for something like this is not very good I think. In my example I said imagine that you have several options and you have to choose one at random, lets say you have 10 options. Then when you spawn your object you spawn 10 other objects as well that is part of the container, to only use one of them, how is that a good design?

And you are correct that the problem you run into is that it will be a bad design.

"if you aim 60+ fps, have in mind that 1 tick is 0.016s (1/60)s which is really fast, and if you pick your objects in next ticks that won't look / work wierd. i know it takes some time to design the game correctly, but it works good."
I don't think this is a valid reason. Computers doesn't work as we do, where you can say that if we don't see it, then the computer wont either. It notice every tick, and if something in your code does something in that 1 tick it gives you problem whether you see it or not.

Newt just gave an example of how wait works, but I can come up with lots of example of how to use it where it works fine. But im not interested in that. :)

So try this and you can use my example if you want, but when you make it and spawn the Red square, make it so, depending on a random roll of 3, which we assume is some important setting for the Red square, you make it spawn another object depending on the roll all in one go and print out the values from both of them. Its not unrealistic that your game when creating a unit might spawn something else that rely on some setting from the first unit.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 1 guest