[SLOLVED NO POSSIBLE] Reference instance variable of object in action?

When you want to tint something you need to provide 3 values
RGB in format of 0-255;0-255;0-255

I am using 3 sliders with different names to do that
In form of

ToString(NewSlider.Value())+";"+ToString(NewSlider2.Value())+";"+ToString(NewSlider3.Value())

But what if i had one object called Slider
With 3 instances of it on scene and maybe ID vars from 1 to 3
I can’t imagine how to do that maybe there are some means to achieve it?

My only idea was to go with If one of these conditions is true
And go Slider var ID = 1 or 2 or 3

But that would not reference which is which but only if any of them have such var

You should be able to pick an object using an object variable as long as you use the object variable condition and not the compare 2 numbers or compare 2 strings. Those conditions do not pick objects.

Also, make sure there isn’t another condition already reducing the pick list. If so, you would have to use pick all first.

In your case, I think using different objects would be the easiest method. Why use 3 events when 1 would do the job?

1 Like

Keith either i don’t understand your answer or you my question

Color string needs to be built from 3 values
For that you need 3 sliders
I went with having 3 slider objects where each is separate object and not instance copy of itself

And so i in color string only need reference them by their object name
NewSlider.Value() NewSlider2.Value() NewSlider3.Value()

Now i asking is to would it be somehow possible to reference in that string
3 different copies of one slider like for example via instance variable

And then i would still be using one event but also one object (just 3 copies of it) instead of 3 separate objects
I think it is technically not possible in gdevelop but i just ask to be sure

This is how I would do it using the same object.

Using different objects, you could do the same with 1 action. It’s 100% up to you. I’ll support you either way.

You could do it with Javascript. You could create an extension. You could create a custom object with 3 sliders. It’s up to you.

I agree that you can’t reference different instances without changing the pick list unless you created your own expression/extension.

I’ve often thought that instances should be addressable like arrays like NewSprite[0].Angle like when using Javascript.

2 Likes

I just thought of a way to do this with a structure. Although, I still prefer separate objects.

This works because the condition picks just the slider being dragged. It then uses the object name Color ( with the values Red, Green and Blue) to modify a structure. It then uses the structure to build the color.

It’s chaos but it works.

1 Like

Hahah ok now i see i did not explain it enough
What was obvious to me is not obvious at all
So all my fault

I meant more like i have only this action
ToString(NewSlider.Value())+";"+ToString(NewSlider2.Value())+";"+ToString(NewSlider3.Value())

I ask is there a way to reference different instances of same object
IN ACTION or to be precise in expression itself

I did not understand what you meant by 3 events and that part did not make sense to me
Because you was talking about referencing it in condition
Sou you needed 3 separate events for it
Which was exactly something i wanted to avoid

Again my question was about a way to reference instances in action not condition

Well now i see how NOT clear my question was to begin with

I did fall under impression like
Since we can do CursorX(“LayerName”,)

Maybe we can make something similar to referencing object instances in action

I’m not aware of a way to access the values of different instances with the built-in actions or expressions without changing the pick list or using Javascript. You could make a custom action or expression but that just seems like overkill unless you use it for other purposes or you want to move code from the main event sheet to a function to make it easier to read.

1 Like

I sit here for so long
I was sure it was not possible
But i seen a lot not possible things actually being possible

Where in this case it would also make no sense for it to be possible

BUT just in case i did care to ask if am wrong
SO it was not like i was asking for a way but more of like i was just making sure it is not possible

Thx Keith

1 Like