An Illustrated Guide to the Display Text Behaviour

2

Comments

  • ArmellineArmelline Member, PRO Posts: 5,327

    @ElectroFox said:
    Great post, very detail. I would like to know if its possible to put a Text along with an Attribute.

    For example I have an integer attribute called Rank, and so I want to write "Your Rank:" infront of the Rank attribute. I tried:

    Your Rank: (game.Rank)
    "Your Rank:" game.Rank
    "Your Rank:" + game.Rank
    ...and several more trials but nothing works.

    I think it should be possible, right?

    Absolutely - check the section on concatenation near the end. You combine strings etc. with two dots - ..

  • ElectroFoxElectroFox Member, PRO Posts: 22

    Oh I missed that, my bad. Appreciate it and keep up the great tutorials.

  • DocJDocJ Member Posts: 66

    Is there a way to get the Display Text to stay on the screen?
    I'm using a When Touch is Pressed rule, along with a Display Text with a tableCellValue(Table, Random(1,6),1) rule.

  • ArmellineArmelline Member, PRO Posts: 5,327

    @DocJ said:
    Is there a way to get the Display Text to stay on the screen?
    I'm using a When Touch is Pressed rule, along with a Display Text with a tableCellValue(Table, Random(1,6),1) rule.

    Why is it currently not staying on the screen? If you use "position relative to scene", it should be visible at all times unless one of two things happens:

    1. The actor displaying it is destroyed
    2. Another actor is on a higher layer, blocking it from view
  • ApprowApprow Member Posts: 703

    @Armelline I missed this post, looks really good and very detailed:)!

  • DocJDocJ Member Posts: 66
    edited March 2015

    I'm using a PC and don't have the positioning options as in the Display Text on a Mac. I am trying to create a 6-sided dice that shows words instead of numbers. I'm using the Touch is Pressed rule along with Display Text. When I Touch the Actor on scene, it will show one of the rows from the 6 row table that I'm using, but as soon as let go of the Touch, the word goes away too.
    I'm new to this, but I was thinking I might need a Boolean to somehow tell GS to consider the Actor still being Pressed until the final dice is pressed.

  • ArmellineArmelline Member, PRO Posts: 5,327

    Yes, that's exactly right. Have a boolean that's turned to "true" when touch is pressed. Then put the display text in a rule that checks for when the boolean is "true".

  • motorcycle boymotorcycle boy Member Posts: 429

    If you want to use a game level attribute followed by a space and then a word, how would you do that? When I try typing a space it won't let me. I have the attribute with the word right next to it so I'm just missing the space in between.

  • ArmellineArmelline Member, PRO Posts: 5,327

    @dreichelt said:
    If you want to use a game level attribute followed by a space and then a word, how would you do that? When I try typing a space it won't let me. I have the attribute with the word right next to it so I'm just missing the space in between.

    game.Attribute.." word"

    You need to alt-Space for the space though, as noted in the guide.

  • motorcycle boymotorcycle boy Member Posts: 429

    @Armelline said:
    You need to alt-Space for the space though, as noted in the guide.

    Thank you!

  • RowdyPantsRowdyPants Member Posts: 465

    @Armelline Great Tutorial! Thank you for making this! So helpful :)

  • NimbleBugNimbleBug Member Posts: 483

    @Armelline Awesome post..thank for sharing..do you have pdf of this, to refer when we are in offline

    Thanks

  • ArmellineArmelline Member, PRO Posts: 5,327

    @NimbleBug said:
    Armelline Awesome post..thank for sharing..do you have pdf of this, to refer when we are in offline

    No immediate plans to do so but if you are on a Mac you can print any web page as a PDF.

  • motorcycle boymotorcycle boy Member Posts: 429

    @Armelline I am trying to combine the sum of two game level attributes for display. When I click the actor on my screen you get a point for the manual click but you can also get points over time. So basically like cookie clicker. However when I used the two dots to combine two attributes it didn't add the sum of the two integers it just put them side by side.

    So for example, my current point per click is 1 and my current points automatically per second is 0. But when I put those into the text display it shows 10 instead of 1 since 1+0 = 1. I was wondering if you could tell me how to fix this?

  • ArmellineArmelline Member, PRO Posts: 5,327

    Use + not .. to add numbers. The double period concatenates the two items, whereas + will add them.

  • motorcycle boymotorcycle boy Member Posts: 429

    @Armelline said:
    Use + not .. to add numbers. The double period concatenates the two items, whereas + will add them.

    Ah of course! Thank you for that!

  • mhedgesmhedges Raised on VCS Member Posts: 634

    @Armelline,

    Thanks for the helpful post. I'd like to revive the thread to add the following (which
    just occurred to me):

    If you need to use a combination of text, a line break, and a variable, type the following in the expression editor:

    You can see the text and line break go inside the quotes. Then you concatenate it with the double period, then you add the variable.

  • UncloudedStudioUncloudedStudio NetherlandsMember Posts: 285

    @Armelline When I display my score/highscore attribute it only shows one "0" but I want to start countting like so "00000" instead of "0". Is this possible?

  • SocksSocks London, UK.Member Posts: 12,822
    edited September 2016

    @UncloudedStudio said:
    @Armelline When I display my score/highscore attribute it only shows one "0" but I want to start countting like so "00000" instead of "0". Is this possible?

    Display it as: padInt(score attribute,5)

    This will pad out the score with a minimum of 5 digits, so for example padInt(56,5) will give you 00056 . . . . or padInt(220,7) will give you 0000220 . . . etc.

  • UncloudedStudioUncloudedStudio NetherlandsMember Posts: 285

    @Socks Great, thank you!

  • SocksSocks London, UK.Member Posts: 12,822
    edited September 2016

    @UncloudedStudio said:
    @Socks Great, thank you!

    Note: lower case 'p' and capital 'I' on 'padInt'.

  • UncloudedStudioUncloudedStudio NetherlandsMember Posts: 285

    @Socks said:

    @UncloudedStudio said:
    @Socks Great, thank you!

    Note: lower case 'p' and capital 'I' on 'padInt'.

    Works Perfect!

    Also having a problem I just can't seem to find/fix. I have an actor that displays the highscore. It's in a menu and when I interpolate it offscreen for a few times (clicking back an forth in the menus) the highscore disappears. Seems to happen totally at random.

  • SocksSocks London, UK.Member Posts: 12,822
    edited September 2016

    @UncloudedStudio said:

    @Socks said:

    @UncloudedStudio said:
    @Socks Great, thank you!

    Note: lower case 'p' and capital 'I' on 'padInt'.

    Works Perfect!

    Also having a problem I just can't seem to find/fix. I have an actor that displays the highscore. It's in a menu and when I interpolate it offscreen for a few times (clicking back an forth in the menus) the highscore disappears. Seems to happen totally at random.

    There is probably an error in your code/logic. Maybe start another thread, don't want drag @Armelline's thread too off course.

  • UncloudedStudioUncloudedStudio NetherlandsMember Posts: 285

    @socks Yes, that's maybe better.

  • ArmellineArmelline Member, PRO Posts: 5,327

    @UncloudedStudio How far do you move it off screen? Is the actor getting destroyed? It's normally the actor getting destroyed when it comes to that kind of thing. If not, then @Socks is probably right and it's probably an error in your logic somewhere.

  • bkhoward2001bkhoward2001 Member, PRO Posts: 86

    If you assign the display text to the square actor, how do you make the square invisible... I turned invisibility off but then the text disappears too!?

  • ArmellineArmelline Member, PRO Posts: 5,327

    @bkhoward2001 said:
    If you assign the display text to the square actor, how do you make the square invisible... I turned invisibility off but then the text disappears too!?

    Set the actor's Color>Alpha to 0.

  • bkhoward2001bkhoward2001 Member, PRO Posts: 86

    @Armelline I can't seem to get the line break to work on the display text... I have tried alt+Enter but that does not seem to work on windows.... Any idea without me having to add the \n in the editor itself?

  • RedRoboRedRobo Member, PRO Posts: 680

    Is it possible to display 2 different attributes separately within 1 display text behaviour?

  • bob loblawbob loblaw Member, PRO Posts: 793

    @strag said:
    Is it possible to display 2 different attributes separately within 1 display text behaviour?

    yes. need to make sure you separate them and any text with ..

    eg

    “score: “..attribute1..” time: “..attribute2

Sign In or Register to comment.