Jump to content

Nightvision


Recommended Posts

I have a character that I couldn't really get to have night vision, so I decided to give him a light that covers the entire screen.
I feel that this way is also better because the night vision is quite annoying to the eyes.

local function SeeDark(inst)
    if TheWorld.state.phase == "day" then
		inst.Light:Enable(false)
	elseif TheWorld.state.phase == "night" then
		inst.Light:Enable(true)
		inst.Light:SetRadius(19)
		inst.Light:SetFalloff(0.75)
		inst.Light:SetIntensity(.7)
		inst.Light:SetColour(70/255,230/255,12/170)
		end
end

local refreshTime = 1/5
	inst:DoPeriodicTask(refreshTime, function() SeeDark(inst, refreshTime) end)

I suppose you can try the same thing to put night vision on it, although I couldn't do it, but I work in DST

I'll see if one of these days I decide to put on night vision but I feel satisfied with the light.

Link to comment
Share on other sites

On 7/26/2023 at 6:17 AM, Terry_Rosario said:

I have a character that I couldn't really get to have night vision, so I decided to give him a light that covers the entire screen.
I feel that this way is also better because the night vision is quite annoying to the eyes.

local function SeeDark(inst)
    if TheWorld.state.phase == "day" then
		inst.Light:Enable(false)
	elseif TheWorld.state.phase == "night" then
		inst.Light:Enable(true)
		inst.Light:SetRadius(19)
		inst.Light:SetFalloff(0.75)
		inst.Light:SetIntensity(.7)
		inst.Light:SetColour(70/255,230/255,12/170)
		end
end

local refreshTime = 1/5
	inst:DoPeriodicTask(refreshTime, function() SeeDark(inst, refreshTime) end)

I suppose you can try the same thing to put night vision on it, although I couldn't do it, but I work in DST

I'll see if one of these days I decide to put on night vision but I feel satisfied with the light.

Ah i assume this would only be seen via the character on multiplayer right?

Link to comment
Share on other sites

--try this
local function SetNightVision(inst) --This should be obvious
        if (TheWorld.state.isnight or TheWorld:HasTag("cave"))and getstate(inst)==0 then
            if not inst:HasTag("nightvision") then
                inst:AddTag("nightvision")
            end
            inst.components.playervision:ForceNightVision(true)
            inst.components.playervision:SetCustomCCTable("images/colour_cubes/purple_moon_cc.tex")
        else
        if inst:HasTag("nightvision") then
            inst:RemoveTag("nightvision")
        end
        inst.components.playervision:ForceNightVision(false)
        inst.components.playervision:SetCustomCCTable(nil)
        end
end

local common_postinit = function(inst)
    inst:WatchWorldState( "isday", function() SetNightVision(inst) end)
      inst:WatchWorldState( "isdusk", function() SetNightVision(inst) end)
      inst:WatchWorldState( "isnight", function() SetNightVision(inst)  end)
    inst:WatchWorldState( "iscaveday", function() SetNightVision(inst) end)
      inst:WatchWorldState( "iscavedusk", function() SetNightVision(inst) end)
      inst:WatchWorldState( "iscavenight", function() SetNightVision(inst)  end)

    SetNightVision(inst)
end

Link to comment
Share on other sites

--try this
local function SetNightVision(inst)
        if (TheWorld.state.isnight or TheWorld:HasTag("cave")) then--getstate is useless here, my bad
            if not inst:HasTag("nightvision") then
                inst:AddTag("nightvision")
            end
            inst.components.playervision:ForceNightVision(true)
            inst.components.playervision:SetCustomCCTable("images/colour_cubes/purple_moon_cc.tex")
        else
        if inst:HasTag("nightvision") then
            inst:RemoveTag("nightvision")
        end
        inst.components.playervision:ForceNightVision(false)
        inst.components.playervision:SetCustomCCTable(nil)
        end
end

local common_postinit = function(inst)
    inst:WatchWorldState( "isday", function() SetNightVision(inst) end)
      inst:WatchWorldState( "isdusk", function() SetNightVision(inst) end)
      inst:WatchWorldState( "isnight", function() SetNightVision(inst)  end)
    inst:WatchWorldState( "iscaveday", function() SetNightVision(inst) end)
      inst:WatchWorldState( "iscavedusk", function() SetNightVision(inst) end)
      inst:WatchWorldState( "iscavenight", function() SetNightVision(inst)  end)

    SetNightVision(inst)
end

Link to comment
Share on other sites

On 8/2/2023 at 5:15 PM, Glommer2 said:

--try this
local function SetNightVision(inst)
        if (TheWorld.state.isnight or TheWorld:HasTag("cave")) then--getstate is useless here, my bad
            if not inst:HasTag("nightvision") then
                inst:AddTag("nightvision")
            end
            inst.components.playervision:ForceNightVision(true)
            inst.components.playervision:SetCustomCCTable("images/colour_cubes/purple_moon_cc.tex")
        else
        if inst:HasTag("nightvision") then
            inst:RemoveTag("nightvision")
        end
        inst.components.playervision:ForceNightVision(false)
        inst.components.playervision:SetCustomCCTable(nil)
        end
end

local common_postinit = function(inst)
    inst:WatchWorldState( "isday", function() SetNightVision(inst) end)
      inst:WatchWorldState( "isdusk", function() SetNightVision(inst) end)
      inst:WatchWorldState( "isnight", function() SetNightVision(inst)  end)
    inst:WatchWorldState( "iscaveday", function() SetNightVision(inst) end)
      inst:WatchWorldState( "iscavedusk", function() SetNightVision(inst) end)
      inst:WatchWorldState( "iscavenight", function() SetNightVision(inst)  end)

    SetNightVision(inst)
end

Ah this works perfectly, tho i definatly will be changing the night vision to be either full moon or moggle vision

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...