Two variables in a expression: one to complete the object name and other to return that obj value

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • How to do that? I have many object_x and want to have the value of a variable of this objects. So I use:

    "object_"&indentifier.value

    ("object_"&identifier)all this is my object and (.value) the value I want to know of this object. Composing my object reference a variable that complete the name.

    The problem is that I dont know how to write this parameter a way that run.

    Just to make clear:

    indentifier: is a variable like "selected player"

    value: is a variable that I want to obtain the value with this expression

    So I have to know the "value" of the "object"_"x".

  • You use several conditions. First the selected variable player identifier = n then you pick further with value = n. Not in the same expression but with conditions, so it could be a block like 'object where object.identifier=2 and value=10'.

  • If your object_1, object_2, object_3 etc. are different objects, then what you are asking is impossible. You can't refer to object by its name in expressions.

    One workaround is to put all objects into a family, define an instance variable "type" on this family, set different type for each object. Then in your events you can pick family member by type and access its value.

    You can create a function "GetObjectValue" that takes type parameter, picks that object from the family and returns object value. Then you will be able to use this function in expressions.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • dop2000I greatly appreciate the help.

    Just to clarify, yes it is an object belonging to a family: a set of different characters to be played (indentifier would be the number of each in its name: player_1). And the value would be the price of the character chosen to be unlocked.

    So as I understand it is not possible to do this the way I was trying.

    In this case I will resort to other methods and appreciate the suggestions.

    In my case maybe just calling the family is enough for the system to hit the variable instance "price" of the character in question (because only the selected character is "created" in the layout).

    I don't know if I understand exactly what you said, so if I let something go let me know.

  • If they are part of a family, you don't have to use this "object_"&identifier. You can just check for "FamilyName.value".

    It may not work in some specific situations, but, without a code or file is hard to know the exact context of your question.

    Cheers!

  • brunopalermoYes!That's what I thought. And for my specific case I believe it will work.

    I greatly appreciate the help

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)