Jump to content

Recommended Posts

Hey guys, 

Found a mod called Taronci with night vision configuration but I found that his night vision uses inst.Light instead of color cubes.

Quote

-- modinfo.lua
{
        name = "NightVision",
        label = "Vision",
        options =
        {
            {description = "On", data = true},
            {description = "Off", data = false},            
            
       },
        default = true,

--modmain lua

local function NightVision(inst)
    inst.Light:Enable(GetModConfigData("NightVision"))
end
AddPrefabPostInit("taro", NightVision)


My night vision uses Color Cubes. so I tried to change the inst.Light part into inst.components.playervision. My code doesn't work and I think I'm using the wrong statement for this. 

Quote

-- modinfo.lua

{
      name = "nightvision",
      label = "Nightvision",
      hover = "Depending on your playstyle, Do you want nightvision?",
      options =    {
              {description = "On (Default)", data = true},
              {description = "Off", data = false},
            },
      default = true,
    },


--modmain lua

local function NightVision(inst)
    inst.components.playervision:Enable(GetModConfigData("nightvision"))
end
AddPrefabPostInit("illyria", nightvision)

What statement should I be using for Color Cubes, instead of inst.light?

Any help is appreciated, thanks 

Edited by AiZenaku

So I finally figured out the night vision config but now I have a problem that every time my character transforms into a lycan and back into a human, the night vision turns off? Is there a way to make it loop (meaning she'll have night vision in either form)? or just her lycan form has night vision?

For easy viewing I have:

Quote


local function applynightvision(inst)
    if TUNING.NIGHTVISION == 1 then
        if inst.components.playervision then
            if inst.nightvision:value() then
                seasoncheck(inst)
                inst.components.playervision:SetCustomCCTable(NIGHTVISION_COLOURCUBES)
                inst.components.playervision:ForceNightVision(true)
            else
                inst.components.playervision:ForceNightVision(false)
            end
        end
    end
end

local function registernightvisionlistener(inst)
    inst:ListenForEvent("nightvisiondirty", applynightvision)
end

local function initializenightvision(inst)
    if TUNING.NIGHTVISION == 1 then
        inst.nightvision = net_bool(inst.GUID, "player.nightvision", "nightvisiondirty")
        inst.nightvision:set(false)
        inst:DoTaskInTime(0, registernightvisionlistener)
    end
end

local function checkphase(inst)
    if inst.task1 ~= nil then
        inst.task1:Cancel()
        inst.task1 = nil
    end
    if inst:HasTag("playerghost") == false and TUNING.NIGHTVISION == 1 then
        if TheWorld:HasTag("cave") then
            inst.components.playervision:SetCustomCCTable(NIGHTVISION_COLOURCUBES)
            inst.components.playervision:ForceNightVision(true)
            initializenightvision(inst)
            inst.nightvision:set(true)
        elseif TheWorld.state.phase == "day" then
            inst.nightvision:set(false)
        elseif TheWorld.state.phase == "dusk" then
            inst.nightvision:set(false)
        elseif TheWorld.state.phase == "night" then
            inst.components.playervision:SetCustomCCTable(NIGHTVISION_COLOURCUBES)
            inst.components.playervision:ForceNightVision(true)
            inst.nightvision:set(true)

        end
    end
end
 

 

onbecamehuman(inst)

Quote

local function onbecamehuman(inst)
    -- Set speed when reviving from ghost (optional)
      inst.task1 = inst:DoPeriodicTask(1,checkphase)

common_postinit

Quote


local common_postinit = function(inst)
  initializenightvision(inst)
 

 

master postinit

Quote

local master_postinit = function(inst)

  if TUNING.NIGHTVISION == 1 then
    inst:WatchWorldState("phase",checkphase)
    end

 

EDIT: I figured out a problem in one of my coding lines (which was in my modmain), but still trying to add lycan only night vision

illyria.lua

modinfo.lua

modmain.lua


Don't know if this is worth noting but I'm using Kzisor's transformation. Is there anything I could add in modmain lua?

I have tried adding this code (false and true versions or nil) or variants of it, but it never seems to work out the way I want it to, it usually turns into moggle nightvision.

Quote

  inst.components.playervision:SetCustomCCTable(NIGHTVISION_COLOURCUBES)
          inst.components.playervision:ForceNightVision(true)

Sorry for the very long post, but I've also posted this before in a different thread. Wanted to try my luck again 

Edited by AiZenaku

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
×
  • Create New...