Jump to content

Player specific Ambientlighting


Recommended Posts

I know that  the ambientlighting component handles the worlds lighting and that I can change values in it so the world is dark during all day phases on the surface, but is it somehow possible to make it so that a specific character is continuously in the dark while everyone else experiences the day normally?

EDIT: Somehow missed that it also handles some nightvision stuff. So that might make this a bit easier.

Edited by DingoLingo
  • Like 1
Link to comment
Share on other sites

Ok so, I CAN make it so only players with a certain tag are constantly in darkness by directly adding a new table and chnging the OnNightVision function.

Spoiler

local NOT_NORMAL_COLOURS =
{
    PHASE_COLOURS =
    {
        default =
        {
            day = { colour = Point(0 / 255, 0 / 255, 0 / 255), time = 8 },
            dusk = { colour = Point(0 / 255, 0 / 255, 0 / 255), time = 8 },
            night = { colour = Point(0 / 255, 0 / 255, 0 / 255), time = 8 },
        },
        spring =
        {
            day = { colour = Point(255 / 255, 244 / 255, 213 / 255), time = 4 },
            dusk = { colour = Point(0 / 255, 0 / 255, 0 / 255), time = 6 },
            night = { colour = Point(0 / 255, 0 / 255, 0 / 255), time = 8 },
        },
    },

    FULL_MOON_COLOUR = { colour = Point(84 / 255, 122 / 255, 156 / 255), time = 8 },
    CAVE_COLOUR = { colour = Point(0 / 255, 0 / 255, 0 / 255), time = 2 },
}

--------

local function OnNightVision(player, enabled)

    _nightvision = enabled
    if player:HasTag("alwaysdark") then
        _overridecolour.currentcolourset = enabled and NIGHTVISION_COLOURS or NOT_NORMAL_COLOURS
         ComputeTargetColour(_overridecolour, 0.25)
        PushCurrentColour()
    else
        _overridecolour.currentcolourset = enabled and NIGHTVISION_COLOURS or NORMAL_COLOURS
         ComputeTargetColour(_overridecolour, 0.25)
        PushCurrentColour()
    end
end

But overwriting the old component file seems like a bad idea and I'm not entirely sure how to edit it through modmain...

  • Like 1
Link to comment
Share on other sites

Did some research and figured out how to edit components through modmain.

Spoiler

AddComponentPostInit("ambientlighting",function(self, inst)
    local _OldOnNightVision = self.OnNightVision

    function self:OnNightVision(player, enabled)
        if player:HasTag("alwaysdark") then
            _nightvision = enabled
            _overridecolour.currentcolourset = enabled and NIGHTVISION_COLOURS or NORMAL_COLOURS
            ComputeTargetColour(_overridecolour, 0.25)
            PushCurrentColour()
            print("Test")
        else
            return _OldOnNightVision(player, enabled)
        end
    end
end)

But the above doesn't do anything. I've done a few test changes on some other components functions and everything else worked, so i'm not sure why this isn't doing anything.

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
 Share

×
  • Create New...