Change Object Text Font with Lua

  • #1, z dionousSunday, 06. August 2017, 22:12 hodinky 7 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.



    Fanoušek fóra

    246 Posts


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

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

    Kapitán

    2346 Posts

  • #3, z dionousSunday, 06. August 2017, 23:01 hodinky 7 years ago
    great thanks!

    Fanoušek fóra

    246 Posts

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

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

    Kapitán

    2346 Posts

  • #5, z SimonSMonday, 07. August 2017, 00:52 hodinky 7 years ago
    game.ObjectFont = Fonts.my_font_name
    would be even shorter.

    Kapitán

    1582 Posts

  • #6, z afrlmeMonday, 07. August 2017, 01:41 hodinky 7 years ago
    game.ObjectFont = Fonts.my_font_name
    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.

    Imperátor

    7285 Posts

  • #7, z dionousMonday, 07. August 2017, 09:33 hodinky 7 years ago
    Thanks all,

    both

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

    and
    game.ObjectFont = Fonts.my_font_name

    work nicely!

    Fanoušek fóra

    246 Posts