LUA font colour

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

blackmilan
Posts: 124
Joined: Sat, 22. Jan 11, 21:13
xr

LUA font colour

Post by blackmilan »

Hi all,

I need a little help with colouring a font string in LUA. Maybe I am just missing the obvious solution right now.

I know how to assign a colour to a complete string, but what I would actually like to achieve in this case is something like:
Ice, Ore, Nividium

Is it possible to assign multiple colours to different parts of a font string?

If not, what would you recommend? Having a table cell for each part of the string or is there a better way?

Thanks a lot for your help.
User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg »

Having the colour info contained in the single string or the table that contains the formatted string would imply that there would need to be some form of delimiter in the raw string - just like you did with the BB code in your post.

It's early days on my own personal UI code voyage of discovery but I haven't come across anything like that in any of the code in the vanilla game so probably not.

Your idea of using individual cells sounds like the right idea. I guess with a bit of tweaking you could make the cells look like one single cell if you wanted the string to look like a single statement. A bit fiddly but then show me a bit of the UI that is not - lol!

Good luck! :)
Vim Razz
Posts: 1842
Joined: Tue, 2. Nov 10, 02:20
x4

Post by Vim Razz »

I've had no luck finding anything that might help, either. Color seems to be determined at the Font String level, and only one Font String seems to be allowed per cell.
blackmilan
Posts: 124
Joined: Sat, 22. Jan 11, 21:13
xr

Post by blackmilan »

Thanks a lot. You just saved me a lot of time. I think I will give the multiple table cells to split the string a try to see how it looks.

Thanks again
Vim Razz
Posts: 1842
Joined: Tue, 2. Nov 10, 02:20
x4

Post by Vim Razz »

There's a new development on this front: v3 beta uses multiple font colors within single cells (at least in the object menu -- menu_object.xpl).

I haven't picked the file apart to see how it's formatted yet, but it's worth checking out and I thought I'd mention it here in case one of you guys want to take a look before I get around to it.
blackmilan
Posts: 124
Joined: Sat, 22. Jan 11, 21:13
xr

Post by blackmilan »

That sounds great. Thank you for the feedback. That will give us some nice new possibilities in UI modding.

I guess I will have to sign up for the beta when I find some time and have a look into the new ui code.
User avatar
wysiwyg
Posts: 585
Joined: Thu, 26. Feb 04, 00:08
x4

Post by wysiwyg »

Nice find Vim! Let's hope you're on to something. Very busy in real life with work at the moment so not getting any time to play or mod but will keep looking for a sneaky half hour here and there to decompile the v3.0 Lua code and have a look.
Vim Razz
Posts: 1842
Joined: Tue, 2. Nov 10, 02:20
x4

Post by Vim Razz »

Welp... NightNord's decomplier can't handle as many of the new lua menus as the old ones, it seems , including the new object menu file. It'll take some more digging to find out how those multi-color strings are being formatted.

So make sure you've got a safe archive of 2.51's xpl files -- there's no way of knowing if or when anyone with Nord's level of comp-sci skill will be interested in advancing the decompiler project in the future, and as opening new files becomes more challenging then solid reference materials will be harder to come by.

Return to “X Rebirth - Scripts and Modding”