Expression concatenation + random

titostitos Member Posts: 41
edited November -1 in Working with GS (Mac)
I have attribute named game.RandomPick of type text that contain a random name of a attribute.
It contain text that is random: a1, a2 or a3

I want a display the content of those attribute a1, a2 or a3. So I try this expression in vain.

`game..(game.RandomPick)`

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi titos, presumably you mean in a Display Text Behaviour? Just put game.RandomPick. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • titostitos Member Posts: 41
    game.randomPick will give me ex: a1
    But A1 is attribute that contain text, and I want to show the content of the attribute A1.

    :)
  • JeffreyShimaneJeffreyShimane Member Posts: 372
    You could do something like this...

    Create a game attribute called RandomNumber (integer type).

    Change Attribute game.RandomNumber to random(1,3)

    If game.RandomNumber = 1,
    Display Text game.A1 (or you could just have the contents of A1 written here)

    If game.RandomNumber = 2,
    Display Text game.A2(or you could just have the contents of A2 written here)

    If game.RandomNumber = 3,
    Display Text game.A3 (or you could just have the contents of A3 written here)

    - Jeff
  • titostitos Member Posts: 41
    Thanks, I am sure there is another way.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    "game"..game.RandomPick

    Text needs to be in quotation marks. Expressions and attributes do not, but must be separated by '..' between each concatenated section.
  • titostitos Member Posts: 41
    I am trying to get a random number between 1-3.
    Then I have 3 attribute called a1,a2 and a3 that contain text:a1 => "allo" , a2=> "mon", a3 => "coco".
    So when I get my random 1 2 or 3 it represent the numbers in my attribute name. letter "a" return in every attribute name. That number is stored in the attribute game.randomPicked.

    So I want when the random number is 1 to concatenate a with 1 to make a1. "a"..game.randomPicked

    Then I want to ask how to get the content of game.a1 without a if.
Sign In or Register to comment.