Sign in to follow this  
Rivecoder

[HELP] Nightvision mask

Recommended Posts

Rivecoder    46

I know i can just add the tag "nightvision" and the mask will work, however i'm looking for a way to get a different colourcube and not that strange negative color effect moggles have

I rather not to add a light, I'd really like the real nightvision, how could I be able to do that? i'm still newbie with this kind of stuff

Sorry for bad english tho

Share this post


Link to post
Share on other sites
Tosh    621

I'm actually trying to do something similar for a mod I've been repairing, though I don't know enough about lua yet to do it.

 

The easiest way to do it should be to inject your custom nightvision values into components/playervision.lua with a tag that you can put in your modded item. This is how it is done in-game for non-player prefabs (e.g. the nightvision and goggles tags). If I find out how to do it, I'll post the solution here.
 


For example, I want to try create a custom "gearvision" tag and give it nightvision and a custom colour cube. I understand how to set this up correctly from within components/playervision.lua, but I have no idea how to get it to behave correctly outside of that file.

Is there a way to set this up in either modmain.lua, the prefab file or through a custom component?

 

I've been searching for a solution, but all the examples I could find only work for modded characters (which already reference components/playervision.lua).

This is the current gears_hat_goggles prefab file:

Quote

 


local assets =
{
	Asset("ANIM", "anim/gears_hat_goggles.zip"),
	--Asset("IMAGE", "images/colour_cubes/goggles_on_cc.tex"),
	--Asset("IMAGE", "images/colour_cubes/goggles_off_cc.tex"),
}


local function generic_perish(inst)
	local fin = SpawnPrefab("ruins_battery")
	fin.Transform:SetPosition(inst.Transform:GetWorldPosition())	
    inst:Remove()
end

local function goggles_perish(inst)
	if inst.components.equippable ~= nil and inst.components.equippable:IsEquipped() then
		local owner = inst.components.inventoryitem ~= nil and inst.components.inventoryitem.owner or nil
		if owner ~= nil then
			goggles_turnoff(owner)
		end
	end
	inst:Remove()
end

local function ontakefuel(inst)
    inst.SoundEmitter:PlaySound("dontstarve/common/nightmareAddFuel")
end

local function fn()
	local function onequip(inst, owner)
		owner.AnimState:OverrideSymbol("swap_hat", "gears_hat_goggles", "swap_hat")
		owner.AnimState:Show("HAT")
		owner.AnimState:Show("HAT_HAIR")
	    
		inst.components.fueled:StartConsuming()        
	end

	local function onunequip(inst, owner)
		owner.AnimState:Hide("HAT")
		owner.AnimState:Hide("HAT_HAIR")
	
		if owner:HasTag("player") then
			owner.AnimState:Show("HEAD")
			owner.AnimState:Hide("HEAD_HAIR")
		end
		
		inst.components.fueled:StopConsuming()      
	end
	
	local function goggles_onequip(inst, owner)
        onequip(inst, owner)
		owner.SoundEmitter:PlaySound("dontstarve_DLC001/common/moggles_on")
    end

    local function goggles_onunequip(inst, owner)
        onunequip(inst, owner)
		owner.SoundEmitter:PlaySound("dontstarve_DLC001/common/moggles_off")
    end
	
	local inst = CreateEntity()

	inst:AddTag("gearvision")
	inst:AddTag("goggles") 	

	inst.entity:AddTransform()
	inst.entity:AddAnimState()
	inst.entity:AddNetwork()
	
	MakeInventoryPhysics(inst) 

The current WIP mod is attached below.

If anyone is able to help us with this, that'd be amazing.

gears_hat_goggles.zip

Edited by Tosh

Share this post


Link to post
Share on other sites
Tosh    621

Bumping this.

I've been looking around for a solution to this, but I don't think there's a way I can do it without help at my current skill level. 

The two potential routes I can think of are:

  1. Using AddComponentPostInit in the modmain to set up my custom 'Gearvision' values in components/playervision.lua. 
  2. Finding a way to reference components.playervision properly.

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
Sign in to follow this