Change Object Text Font with Lua

  • #1, by atrusSunday, 06. August 2017, 22:12 3 years ago
    Hi all,

    What would be the best way to change the object text font with LUA? Checking the data structure i can see :

    GameObjectFont -> The font used when displaying an object text.

    and

    GameFontLinks -> All fonts of the game.



    Forum Fan

    237 Posts


  • #2, by sebastianSunday, 06. August 2017, 22:39 3 years ago
    before displaying an object text (and after displaying the text setting it back to default):

    game:setValue(VGameObjectFont,"Fonts[my_font_name]")
    1

    Thread Captain

    2336 Posts

  • #3, by atrusSunday, 06. August 2017, 23:01 3 years ago
    great thanks!

    Forum Fan

    237 Posts

  • #4, by sebastianMonday, 07. August 2017, 00:23 3 years ago
    im not sure, but
    game.GameObjectFont = Fonts["my_font_name"]
    1

    will may work, too. Looks a bit cleaner...

    Thread Captain

    2336 Posts

  • #5, by SimonSMonday, 07. August 2017, 00:52 3 years ago
    game.ObjectFont = Fonts.my_font_name
    1
    would be even shorter.

    Thread Captain

    1352 Posts

  • #6, by afrlmeMonday, 07. August 2017, 01:41 3 years ago
    game.ObjectFont = Fonts.my_font_name
    1
    would be even shorter.
    I'm not so keen on that method because it's not as clear. I like to separate the tables with . & access the visObj with ["this"] because it's much easier to spot what's what when you are scripting & something is incorrect or you need to change the name of the visOBJ you are accessing.

    Imperator

    6816 Posts

  • #7, by atrusMonday, 07. August 2017, 09:33 3 years ago
    Thanks all,

    both

    game:setValue(VGameObjectFont,"Fonts[my_font_name]")
    1

    and
    game.ObjectFont = Fonts.my_font_name
    1

    work nicely!

    Forum Fan

    237 Posts

Write post