'Invalid Expression' - this should be simple ;)

gizmokrisgizmokris Member, PRO Posts: 35

Hi all, HNY!

Please can you help? Ive searched the forums and tried lots of different ways to do this, but Im probably just missing something.

Im trying to change an image using a Change Attribute.
There are 10 different images per level, and 20 levels. My images are named as follows:
ImageNumber_LevelNumber.png. (1_1, 2_1...... 1_2, 2_2... etc, etc)

I have set up a 'Level' attribute that works perfectly elsewhere in my game. (this is the number of the current level)

I also have a local attribute in the actor, called 'RandomImageNumber' - I have a Change Attribute set up that changes the attribute to a random number between 1-10)

What is the expression I use on a Change Attribute for 'Self.Image'... eg:
Change Attribute: 'self.Image' To: self.RandomImageNumber_Game.Level

What happens with the multiple ways Ive tried, is, the actor displays as white, and with the text 'invalid expression' (I set a display text to troubleshoot)

Please help! ;)

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    self.RandomImageNumber.."_"..game.Level

    Two dots (..) are used to concatenate or join text strings and attributes. Text strings ("_") must be surrounded by double quotes.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • gizmokrisgizmokris Member, PRO Posts: 35

    @tatiang THANK YOU!!!!! I knew I should have posted sooner and saved myself an hour or so ;)

    I did try quoting the _ , and also used the double dots after the first part of the expression, but because I didnt really understand what they were, I obviously didnt do it completely right.

    Thanks again, Ive just tested it and it works perfectly!
    Youre a star.

  • JSprojectJSproject Member Posts: 730

    Me picturing you picturing him as a star ;)

  • gizmokrisgizmokris Member, PRO Posts: 35

    Love that!! :# (*)

  • JSprojectJSproject Member Posts: 730

    :)

Sign In or Register to comment.