1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Showing message string and variables

Discussion in 'Programming' started by Nathan Matthews, Nov 19, 2017.

  1. Nathan Matthews

    Nathan Matthews Member

    Joined:
    Nov 10, 2016
    Posts:
    30
    I thought this code would have worked but it didn't, can someone please help me with the right way to do it.
    Code:
    show_message("Level Status: "+room_caption+"#Coins Remaining: " +instance_number(Coin)+"#Fuel" + health);
     
  2. Jakylgamer

    Jakylgamer Member

    Joined:
    Jun 27, 2016
    Posts:
    511
    when you string together non strings you need to do
    Code:
    "Level Status: " + string(variable) + "more text" + string(variable2)
    
     
  3. DukeSoft

    DukeSoft Member

    Joined:
    Jun 20, 2016
    Posts:
    783
    What the parser thinks you're doing here is adding a number to another variable. But since the first variable there is a string, it can't add that number to the string, so you will have to cast your variable to being a string using that function.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice