Color changing on persons via lua

  • #1, by marvelWednesday, 24. October 2018, 17:45 5 years ago
    Hey Guys,
    any idea how to change the colors (palette) of a person via lua? 

    My character has kind of neutral colors at the moment. Now I want him to enter a very blue, dark cave. So my intention is to change the palette. Could this work with lua?


    Key Killer

    598 Posts

  • #2, by afrlmeWednesday, 24. October 2018, 19:09 5 years ago
    game.CurrentCharacter.Tint = 0xff0000

    That would tint the character blue. For some reason the RGB is inversed so it's BGR instead, so take that in mind when you write out the hex color values.


    Color the character will be drawn with. If the most significant byte is not 0 then this color will be ignored (default) and the lightmap (if present) and scene brightness will be used for the tint of the character. Otherwise the three lower bytes are used for the tint the character will be drawn with. The least significant byte specifies red, then green and the third byte specifies blue. E.g. with 0xFF0000 the character would be drawn with a blue light.

    Out of curiosity, why are you not using light maps?


    7272 Posts

  • #3, by sebastianThursday, 25. October 2018, 03:43 5 years ago
    real palette swapping for sprites would be cool. That would be ideal for sprites with a limited indexed palette with e. g. 256 colors... 

    example of possibilities :

    Currently i see the only way to do it via the shader system with a fragment shader to run through each pixel and change the color. But thats a bit costly and not "the real thing" . 

    Just tinting the sprite can be done via the methods AFRLme mentioned.


    Thread Captain

    2346 Posts