Jump to content

Night Vision Details


Recommended Posts

I've been trying to make a character with night vision when it is night or when inside a cave, with search I found this solution:

 

But the night vision still keeps the sames colors as on the day, I wanted to it to look like it is full moon. Is there a way to make that?

Also, if possible I wanted to define the radius of vision, just like when you light a torch or a lantern, they grant you different sizes. Is it possible to make my vision radius be the same as when I have a lantern or a torch?

My code so far, the way it is now, it seems that the night vision is always enabled, not sure about that though:

local function UpdateNightVision(inst, phase)
	local enable = phase == "night"
	inst:DoTaskInTime(enable and 0 or 1, function(inst)
		inst.components.playervision:ForceNightVision(enable)
		inst.components.playervision:SetCustomCCTable(enable and {} or nil)
	end)
end

local function OnInitNightVision(inst)
	if TheWorld.ismastersim or inst.HUD then
		inst:WatchWorldState("phase", UpdateNightVision)
		UpdateNightVision(inst, TheWorld.state.phase)
	end
end

local common_postinit = function(inst) 
	-- Minimap icon
	print("common post init called")
	inst.MiniMapEntity:SetIcon( "shinobu.tex" )
	inst:DoTaskInTime(0, OnInitNightVision)
end

 

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...