[Solved - Solution in the Wiki] So why was the Sub-Event needed here?

Hi guys, just something that occurred to me while I was trying to create an easier character selection/buy screen for my game.
This is probably a really Noob question.

The below objects belong in a group called Bloblos.

All of them have their own individuals description, cost etc in their variables.

Now when you click on one of them you have this description that changes to the description of the clicked Blob

image

This is the event sheet.

And the results

And It works fine!!!
.
.
.

Now… before I could make this work. I was doing this thing instead. (Basically the same action but without a sub-event)

Due to that the description was staying the same, and you had to click again in order for the description of the clicked Blob to appear.

I clicked but nothing

I click again and the proper description of the object shows up. (Of course the previous description is still there as I did not delete it)

Now I just want to know why this happens. Why was the Sub-Event needed here? Why this couldn’t work with my first try (Without the sub-event) ? As I see it, Gdevelop needed the description object, to already exist in the scene in order for the description to change?

Just when I thought that I learned somehow how sub-events work I come face to face with this thing.

In case you don’t understand my question I have the example here.

Just disable the correct action and enable the wrong one to see what I mean

I noticed a similar issue with external layouts. The objects that are added can’t seem to be referenced in the same event. It’s weird that it works in a subevent but it does.

For me, it was adding a tween right after the layout objects were added. Nothing happened when the actions were in the same event.

IDK if it’s a bug. When you add objects in the usual way, you can modify them immediately.

2 Likes

This is just my observation
And thx to what @Keith_1357 wrote i am more willing to believe this is the case

In same fashion as you can’t set something to let’s say width of object which not yet exist
Or position of it if its not there already since there is nowhere to get information from
Same way something 1st need to be created from external layout then you can reference it

I would assume that sub event is taking extra frame or some time delay for object from parent event to be created
And then you can reference it in any way you want
But for now its case like
Hey sell me your keyboard for 5$ i just don’t have money now i will pay you next week
Today i get keyboard you did not get money right now
So you did not sell me anything you gave me something and your wallet did not get any heavier from this action
So there is no information for how much you sold me your keyboard

And again that is just my assumption based on observation

1 Like

Thank you for the observations guys @Keith_1357 @ZeroX4

Glad to see that at least I’m not the only one with the problem :sweat_smile: I was trying to figure out what I was doing wrong and almost punched my screen.

I like the analogy with the keyboard, I just never thought that this could be the problem since I was with the Idea that Gdevelop does the actions from top to bottom in a “consecutive?” order. Like it won’t proceed to the changed text action until the Layout is created first, not ignore it completely. I wonder if the action will happen properly if I add a wait 0.5 or 1 seconds action in the same event before the edit of the text.

If this is indeed the problem and Gdevelop can’t reference objects from external layouts in the same event I wonder if there is a way to fix it. Maybe I should create a request cause I was honestly baffled when it happened. (I started using external layouts last week for pop up windows, menus etc and they make life so much easier)

This has also happened to me i.e. I can’t do things with objects that have been created from an external layout in the same event that they are created.

For my dialogue system I use ‘Create objects from external layout’ at the beginning of the scene in its own event that I do nothing else with. In the next event down (another ‘at the beginning of the scene’ event) I do things with those created objects, such as hiding them or changing their opacity.

I also went through a whole troubleshooting process over it and discovered the fix by accident. I did not know until your post that a sub-event can also work.

1 Like

Just to be clear AGAIN observation not actually knowledge

1 - Action for loading is triggered
Imagine you have huge ass crap to load from external layout
So let’s lag your game?
Or let it load in background?

2 - in that exact event you are referring to object that DOES NOT EXIST you are creating that object from external layout

If you would create object in that event and then reference it you should be able to do it i mean change text but here you don’t create object but bunch of them
You don’t really know how long and in which order it takes to create them

3 - Another issue here is that you set text to something for ONE SINGLE FRAME in which this object don’t exist yet
You could delay setting text or run it without trigger once which also should solve issue

4 - Imagine its not something with external layout but something with gdevelop
There is hide cursor action
So you can hide original mouse cursor if you create custom one for your game
And most logical way to use it is in event with at beginning of the scene condition
Sometimes it don’t hide it
I discovered if i run this action without any condition it works perfectly fine
Then i discovered if i run WAIT action like 0.02 or 0.8 sec with at beginning of the scene it hides it perfectly fine ALWAYS

So i use compare 2 numbers conditon
And i check if TImeFromStart()+1 is less than TimeFromStart()
Action hide cursor
So for 1 sec since scene starts i am constantly hiding mouse cursor
It never failed me

5 - In few cases i use WAIT 0.02
it’s like nothing but somehow it does kick in some action which don’t want to work
Some variables in extensions do not work
Yet they do if i add that wait action

In conclusion let’s face it
Our games make us slaves of time and only thing we can do is adapt to it

1 Like

This is a known GDevelop behaviour , and documented in the GDevelop Wiki:

5 Likes

Sometimes reading the wiki is all it takes :sweat_smile:

Actually Im pretty sure I read it months ago and forgot about it. Wish there was a way to fix this limitation (And the limitations of my brain)