Halstrom Posted July 4, 2014 Author Posted July 4, 2014 GetHairColor 0 is supposed to return the full RGB code as an integer. SetHairColor takes an RGB color and an optional NPC, but there might an error. Try the code. let cc := ((255 * 255) + 240) * 255 + 15 ;;; (if I am good cc will be 16773135) SetHairColor cc let rr := GetHairColor 1 let gg := GetHairColor 2 let bb := GetHairColor 3 rr should be 15 gg should be 240 bb should be 255 if that's not the case then it would seem there a bug Cool, I'll try use this to add random hair color to offspring
ArgusSCCT Posted July 4, 2014 Posted July 4, 2014 Well, I probably should have stuck the word "other" in there as if you read up a few posts you would have read that he didn't want to use NX I was under the impression UDF's were part of NX but seems they are NVSE, not sure if he wanted to use that either. If this is about me, I am using NVSE, in fact I'm using wherever I can. I think it is pretty impossible to do this without it and in fact I don't think I'm ever going to make a mod that doesn't make use of NVSE. The real reason that I'm not using NX is that people won't want to come here to download it, I'm sure a bunch of shortsighted fools will whine about it. People already whine about having to download NVSE, even if they don't know why they're complaining about that. Globals are definitely off the table, in fact I'm deleting them all. I can see how they would become more trouble than they're worth.
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 GetHairColor 0 is supposed to return the full RGB code as an integer. SetHairColor takes an RGB color and an optional NPC, but there might an error. Try the code. let cc := ((255 * 255) + 240) * 255 + 15 ;;; (if I am good cc will be 16773135) SetHairColor cc let rr := GetHairColor 1 let gg := GetHairColor 2 let bb := GetHairColor 3 rr should be 15 gg should be 240 bb should be 255 if that's not the case then it would seem there a bug Maybe there is. I have R:40 G:34 B;23 (standart brown color) The color is 12989 (gethaircolor 0 returns the same thing) But when I set hair color I get orange color Halstrom, Youll have to add a code in gamemode block which sets hair on NPC's load(If getgame loaded || getgamerestarted)
Halstrom Posted July 4, 2014 Author Posted July 4, 2014 Halstrom, Youll have to add a code in gamemode block which sets hair on NPC's load(If getgame loaded || getgamerestarted)Damn, I was hoping to set them on their initial adding to the world to give a bit of variety in OffSpring
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 Halstrom, Youll have to add a code in gamemode block which sets hair on NPC's load(If getgame loaded || getgamerestarted)Damn, I was hoping to set them on their initial adding to the world to give a bit of variety in OffSpring Do they use their own form? If so, I don't see the problem. But that would be really cool if the change was permanent
nyaalich Posted July 4, 2014 Posted July 4, 2014 let cc := ((255 * 255) + 240) * 255 + 15 ;;; (if I am good cc will be 16773135) SetHairColor cc let rr := GetHairColor 1 let gg := GetHairColor 2 let bb := GetHairColor 3 rr should be 15 gg should be 240 bb should be 255 I'm confused with your initial conversion from hex to dec.
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 I'm confused with your initial conversion from hex to dec. just read it from DOWN to UP.
nyaalich Posted July 4, 2014 Posted July 4, 2014 He's either shortcutting the conversion or something else where I'm just not getting it. I don't understand why which parts of it are being multiplied by 255 if it's RGB.
prideslayer Posted July 4, 2014 Posted July 4, 2014 I don't get it either. If the goal is rr should be 15 gg should be 240 bb should be 255 Then let cc := (15 << 16) | (240 << 8) | 255 ; or let cc := (15 * 256 * 256) | (240 * 256) | 255 Both of these come out to 1044735 (0x0FF0FF) which is correct for 15(0xF) 240(0xF0) 255(0xFF). The 16mil # in the example is 0xFFF00F -- 255(0xFF) 240(0xF0) 15(0x0F) -- which would be BGR, not RGB.
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 I don't get it either. If the goal is rr should be 15 gg should be 240 bb should be 255 Then let cc := (15 << 16) | (240 << 8) | 255 ; or let cc := (15 * 256 * 256) | (240 * 256) | 255 Both of these come out to 1044735 (0x0FF0FF) which is correct for 15(0xF) 240(0xF0) 255(0xFF). The 16mil # in the example is 0xFFF00F -- 255(0xFF) 240(0xF0) 15(0x0F) -- which would be BGR, not RGB. Hair color is 21965. Still orange.
jaam Posted July 4, 2014 Posted July 4, 2014 Like I would have looked up the formula before tiping it Next, tomm434, get the values for rr, gg and bb after the SetColor. I'm worried there could be some truncation when setting the color.
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 Like I would have looked up the formula before tiping it Next, tomm434, get the values for rr, gg and bb after the SetColor. I'm worried there could be some truncation when setting the color. I started doing it for you and "gethaircolor 0" returned me a new value "1516072". And when I set hair color, he was brown like she should. but earlier it returned "12989" and I swear both times I used 1 savegame! So, we can assume that it was my mistake but I still don't know why. About your test.. Considering I transformed RGB (40;34;23) into 21965 right, here is what file says gethaircolor 0 GetHairColor: (000055CD) Code=0 Color=55cd [21965.000000] gethaircolor 1 GetHairColor: (000055CD) Code=1 Color=cd [205.000000] gethaircolor 2 GetHairColor: (000055CD) Code=2 Color=55 [85.000000] gethaircolor 3 GetHairColor: (000055CD) Code=3 Color=00 [0.000000]
jaam Posted July 4, 2014 Posted July 4, 2014 this does not look right. if you specify 3 non null colors, only the first two hexadecimal characters should be null.
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 I'll go calculate color again. Like I said, maybe that's my mistake. 23879 but still it's green.
jaam Posted July 4, 2014 Posted July 4, 2014 40 is 28 in hexa, 34 is 22, 23 is 17. So the RGB value should be 00172228 or 1516072 in decimal.
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 40 is 28 in hexa, 34 is 22, 23 is 17. So the RGB value should be 00172228 or 1516072 in decimal. should I use your version or Prideslayer's? I mean method.
jaam Posted July 4, 2014 Posted July 4, 2014 They are the same, mine makes reading the resulting hexa code easier. Though if using prideslayer version in GECKscript, use the + operator rather than the | operator that does not exists .
prideslayer Posted July 4, 2014 Posted July 4, 2014 0x000055CD is (should be) 0x00 (0) (alpha, probably unused?) 0x00 (0) (red) 0x55 (85) (green) 0xCD (205) (blue) The first thing you need to do is make sure these functions are working the way you expect. Set the colors to black (0), red (0x00ff0000), green (0x0000ff00), blue (0x000000ff) and white (0x00ffffff). Make sure you get the correct color, and also read it back out with getcolor and make sure it matches. If it does then you should be good to go for matching. When it comes to combining, I (of course) suggest you do it my way. If the format is really RGB then setting the full value is as simple as: color = (red_val << 16) | (green_val << 8) | (blue_val) You must make sure that each individual value is 255 or less, OR AND them against a 0xff bitmask before shifting, though doing this will hide problems from you.
prideslayer Posted July 4, 2014 Posted July 4, 2014 They are the same, mine makes reading the resulting hexa code easier. Though if using prideslayer version in GECKscript, use the + operator rather than the | operator that does not exists . | doesn't exist? It's in the OBSE expressions document.. :/ You can use + instead of course.
nyaalich Posted July 4, 2014 Posted July 4, 2014 So the RGB value should be 00172228 Why are there 8 numbers? And why would it have leading zeroes? And, couldn't that possibly be a problem? IIRC, kid had a number issue in a C++ script that we couldn't figure out until I remembered that a leading zero made it think it was in octal. Why are there 6 pedals if there are only 4 directions?
jaam Posted July 4, 2014 Posted July 4, 2014 hum did I forgot something ? I may be posting way too fast for my own good
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 Update. eh, I'm going to read Pridelsayer's post. OK. How do you get that value that you get? Prideslayer's method. let cc := (15 * 256 * 256) | (240 * 256) | 255 R ==40 G==34 B==23 (R * B+1 * B+1) + G * B+1 + B (23040) + (816) + 23 == 23879 how do you get 00172228 ?
jaam Posted July 4, 2014 Posted July 4, 2014 In hexadecimal, every byte takes 2 characters. And yes I should not write number without specifying the base. Problem is, there isn't a single convention for writing base. C++ uses a 0x0 prefix (and effectively 0 for octal), Pascal uses a $ prefix and assembly uses a h postfix. But, as long as my number was only a string in a post , the leading 0 helps readability.
prideslayer Posted July 4, 2014 Posted July 4, 2014 Update. eh, I'm going to read Pridelsayer's post. OK. How do you get that value that you get? Prideslayer's method. let cc := (15 * 256 * 256) | (240 * 256) | 255 R ==40G==34 B==23 (R * B+1 * B+1) + G * B+1 + B (23040) + (816) + 23 == 23879 how do you get 00172228 ? That is not my method, that is jaams. 0x172228 is: red = 0x17 (23) green = 0x22 (34) blue = 0x28 (40) I have no idea what multiplying red * blue+1 and all that is about in jaams method. He says it's easier to understand.. maybe for someone who learned math on some other planet.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now