DocGnuss

Need help with night vision in caves

Recommended Posts

DocGnuss    0

Hi, I have a problem with adding night vision in caves

My character, in theory, should see well in caves (that is, cave night vision) 

But at the moment there is something wrong with my code and instead of night vision it BLOCK THE CAVES! 

I mean the character literally can't be in the caves anymore... 

Please help fix this

1627029793385_wuffy.lua

Share this post


Link to post
Share on other sites
Monti18    400

The caves crash, that's why you're not able to go in them. You need to have a look at the server log of the caves to see why it crashed.

There you would find this error: 120: variable 'NIGHTVISION_PHASEFN' is not declared

If you have a look at your prefab, you can see that you added NIGHTVISION_PHASEFN, but you don't declare it anywhere.

  • Like 1

Share this post


Link to post
Share on other sites
Maxsar    1

maybe try that
 

local NIGHTVISION_COLOURCUBES =
{
    day = "images/colour_cubes/day05_cc.tex",
    dusk = "images/colour_cubes/dusk03_cc.tex",
    night = "images/colour_cubes/ruins_light_cc.tex",
    full_moon = "images/colour_cubes/purple_moon_cc.tex",
}

local function NightVision(inst, enable)
	if TheWorld.state.isnight or TheWorld:HasTag("cave") then
		inst.components.playervision:ForceNightVision(true)
        inst.components.playervision:SetCustomCCTable(NIGHTVISION_COLOURCUBES)
	else
		inst.components.playervision:ForceNightVision(false)
		inst.components.playervision:SetCustomCCTable(nil)
	end
	
	if TUNING.NIGHT_VISION == false then
		inst.components.playervision:ForceNightVision(false)
		inst.components.playervision:SetCustomCCTable(nil)
	end

end

it works for me

Share this post


Link to post
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