Jump to content

How are clothing colours defined? (help with my profession outfit mod)


Banjo

Recommended Posts

I couldn't find any info on this here, so apologies if this has ben asked/solved before (please link me!).

 

How are the new "unlimited" clothing colours defined in scripts? I am modding the profession outfits and saw that they are represented as follows:

topColor = ColorInfo.new(0.1725,0.2745,0.5411,1);

That's a blue top. But what do the numeric values correspond to? I was thinking RGB, but those are three-digit. Hex colours are a single six-digit code. So... what are they? For example, what would a pink top coded as above look like? I'm sure there's a simple answer here that I'm missing! :)

 

Right now, I can mod the clothes and their colours just fine, but since I don't understand the actual colour codes being used, I can only reliably use the colours already specified in "CharacterCreationProfession.lua".

 

On the same topic, how would I give/spawn a clothing item of a specific colour rather than a random one with the new system?

player:getInventory():AddItem("Base.Shirt_White");

... would give a white sweater or a randomly coloured one? Now that the clothing colours are no longer individual items, how would it be done now (instead of changing the above codee to "Shirt_Blue", I mean)?

Link to comment
Share on other sites

Wouldn't a bit of experimentation solve this pretty quick? My guess is the format is (red, green, blue, alpha (transparency)), on scale of 0-1, so by multiplying with 255 you'd get more familiar values of about 44, 70, 138, which results in a blue color something like this. Pink would then be 1, 0.5, 0.5.

Link to comment
Share on other sites

Wouldn't a bit of experimentation solve this pretty quick? My guess is the format is (red, green, blue, alpha (transparency)), on scale of 0-1, so by multiplying with 255 you'd get more familiar values of about 44, 70, 138, which results in a blue color something like this. Pink would then be 1, 0.5, 0.5.

Well done! That seems to be the trick! :)

 

It's the "multiply by 255 to get a recognisable value" concept that had me confused and not seeing the "pattern" to this. Why is it expressed as 0.1618 rather than 43, though?

Link to comment
Share on other sites

Well done! That seems to be the trick! :)

 

It's the "multiply by 255 to get a recognisable value" concept that had me confused and not seeing the "pattern" to this. Why is it expressed as 0.1618 rather than 43, though?

 

 

Maybe programming habit? A lot of values in PZ are handled with doubles from 0 to 1.

 

"Moreover, most modern CPUs do floating-point arithmetic as fast as (or even faster than) integer arithmetic." (source) ^- This might also be a reason.

Link to comment
Share on other sites

Lua doesn't have an integer type.

Exactly ;)

EDIT: I think you have misunderstood my reply. Lua doesn't have integers, but Java does and ColorInfo.new(...) is a Java function. As I said it is just a guess, but it probalby is more a thing of personal preference by the devs!?

Link to comment
Share on other sites

 

Lua doesn't have an integer type.

Exactly ;)

EDIT: I think you have misunderstood my reply. Lua doesn't have integers, but Java does and ColorInfo.new(...) is a Java function. As I said it is just a guess, but it probalby is more a thing of personal preference by the devs!?

 

Ah, fair point. My line of reasoning, which I kinda failed to express, was that since there's a lot of Lua (well, Kahlua) interaction going on, it makes life simpler to just have a single convention of using floats instead of integers where possible.

Link to comment
Share on other sites

Heya,

 

I just added the setters and getters for the Color in inventoryItem :

  • setColor(Color)
  • getColor()

 

So, you can do stuff like that :

local topColor = ColorInfo.new(0.1725,0.2745,0.5411,1);local vest = getPlayer():getInventory():AddItem("Base.Vest");vest:setColor(topColor:toColor());

For the color, it's from 0 to 1, just like 0 to 255, so if I want to do 120 in R, I just need to do 120/255 = 0.47, and if you want to know the color we used, just multiply the numbers by 255 :)

 

Hope it's clear !

Link to comment
Share on other sites

Heya,

 

I just added the setters and getters for the Color in inventoryItem :

  • setColor(Color)
  • getColor()

 

So, you can do stuff like that :

local topColor = ColorInfo.new(0.1725,0.2745,0.5411,1);local vest = getPlayer():getInventory():AddItem("Base.Vest");vest:setColor(topColor:toColor());

For the color, it's from 0 to 1, just like 0 to 255, so if I want to do 120 in R, I just need to do 120/255 = 0.47, and if you want to know the color we used, just multiply the numbers by 255 :)

 

Hope it's clear !

 

This only work on .17 and up?

Link to comment
Share on other sites

It works naow on the "Kinda release" Steam build :D

 

Go crazy, make a pimp my clothes mod ! Everything pink yay !  :D

You do know you're a bloody legend, mate, right? :)

 

I'm happy my confused question posting led to this!

 

Oh, and huge thanks for such a clear answer on how this works... much appreciated!

 

EDIT: When I enter colours, they look quite "faded" (e.g. yellow as 1,1,0,1 = a very washed out dirty yellow). Is there a way to get brighter colours (e.g. "banana" yellow)?

 

Also... I'd still like to find where the game (vanilla) picks colours from when spawning a clothing item, if only to know the exact colour codes used each time in the vanilla game for shirts that are purple, red, green, etc.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...