1 line only for label

daime2861daime2861 Posts: 8Member
edited December 2020 in GUI

very easy, but i can't find answer

    enemy_kiled+=1
    var label = $killed_label_node/killed_label
    #label.text=String(enemy_kiled+"/10") runtime error
    #label.text=String("$enemy_kiled /10") compile error
    var s = "{num}/10"
    var s2 = s.format({"num":String(enemy_kiled)})
    label.text = s2 #works, but too long

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 4,277Admin

    Welcome to the forums @daime2861!

    I'm kinda confused on what you are asking. Are you trying to make all the code fit in one line? If so, you can try doing something like this, I think:

    label.text = str(enemy_killed) + "/10"
    

    That said, unless you have a reason to worry about line count, using multiple lines shouldn't cause any performance issues or anything like that, and sometimes its easier to read and maintain code if its spread across multiple lines.

    Also:


    This discussion was caught in the moderation queue since you have not confirmed your account yet.

    Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

    (Note: You do not need to repost, the discussion has been moved out and is visible now)

    If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

  • newmodelsnewmodels Posts: 345Member

    Your label might be configured for auto wrap. Set it to not auto wrap. It should spawn one line. Labels are able to handle the \n code, don't know if your code has it. Maybe you want it to not be on one line? Then set auto wrap true.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file