Per Object Event question

So… I don’t know if I’m about to say something stupid here,

but couldn’t local variables somehow work per instance?

For example, they could be used inside a Repeat for Each to get around the Trigger Once for Each issue, since you’d have a temporary variable that changes immediately without cluttering the object variables.

But that’s just one example.

I think they could be really useful in single events too… kind of like how the old undeclared variables worked.

I don’t know… am I saying something completely stupid here?

Has this already been discussed? (cos i haven t find any thread on this)

Is it just not feasible?

Because I cant believe this is something that hasn’t been talked about before.

Sometimes I’m a bit out of the loop on the forum, so it’s pretty easy for me to miss things.

Could someone update me on this?

edit: also how this would fit inside c.objects?

I don’t really understand what you meant, but why would it be better than regular object variables?

No, no, I’m not saying it would be better. I’d say they would do the same thing… I think?

The difference is that I wouldn’t need to declare it, or rather, I would declare it the same way I do the other scene/local variables.

For example, here I had to declare the obj.var ready because I needed it for every instance.

At end..i could do Local ready=1 instead…i guess..

It would only change the fact that I wouldn’t have to declare it permanently, since I only need it for that particular event…(btw this is a random example)…I mean i know they’re there..but they’re not in my variables lists..since it’s a 1 use vars

Again, I think it would basically be the same thing we were doing before the variable changes.

I don’t know what this would actually lead to or whether it would work, but in my project I could see a use for it…

I have not seen any way to do this without making it yourself

I guess you have a few misconceptions about how local variables work. You should read this doc:

Local variables are stored in memory for the duration of an event execution
Local variables - GDevelop documentation

Yes, that could be the case… I think so too, actually. But at this point I need some clarification: when I declare local variables, they go into the scene variable list, right? If I’m wrong, please correct me.

here in the wiki i’ve this .

The following event…

…can be replicated using variables:

This example demonstrates how the “trigger once” condition functions. However, this is primarily to help understand its limitations, as explained in the next section.

BUT these are scene variables.

that is idd what i did in my example in op but per object..

I’m asking if we could have something per object..so i don’t need to add another var in the obj var list to just execute a 1 time event across the whole project.

In your example, you need to keep the value of ready during the whole life of the object so I don’t see how a local variable would be useful for this.

Couldn’t this replace that… I ask.

This is the part I don’t understand.

If, for example, I want this event to work for the object, is the local variable scene-level, or does it work per object/instance? Because otherwise I’m asking for something that already exists.

i guess..it’s not possible

Sorry, but I can’t guess what “this” and “that” mean for you.
You can always experiment on your end and come back when you have a clearer idea of how local variables actually work.

I’d like to ask if this:

Could be replaced with this?

using something like local per obj ..without adding a 1 time usevar in the obj.vars list…but any other method would be.

EDIT: I definitely will… even though the wiki doesn’t really answer the question. The thing is, I tried using it per object, and that event stopped working, so I came here to ask. At this point, I’ll move it to “How do I?” until I figure out what’s actually going on.

What your example is doing is to exclude objects that have already been linked. You can’t do this if you forget everything as soon as you leave the loop (which is what local variables do).

That’s exactly what I needed to know. Thanks.

HAHA, I realized the next day that I had asked something silly… and I probably didn’t even choose a very good example to use. In the end, I think such a request wouldn’t really have any practical use, because the local variable would rightly be forgotten after the event.

Sorry for bringing such stupid matter to your attention.Sometimes my brain just short-circuits.