Change Object Text Font with Lua

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



    Forum Fan

    246 Posts


  • #2, by sebastianSunday, 06. August 2017, 22:39 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]")

    Thread Captain

    2346 Posts

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

    Forum Fan

    246 Posts

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

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

    Thread Captain

    2346 Posts

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

    Thread Captain

    1580 Posts

  • #6, by afrlmeMonday, 07. August 2017, 01:41 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.

    Imperator

    7278 Posts

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

    both

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

    and
    game.ObjectFont = Fonts.my_font_name

    work nicely!

    Forum Fan

    246 Posts