Sign in to follow this  
Batmanwarrior

Need help to make nightvision player-only.

Recommended Posts

Hey guys,

 

I found some code to enable a lightsource at night (nightvision) but right now it is visible for all the players on the server. I want it to be playervision-only. :-)

 

This is the code for the "light":

--Nightvision
local light = inst.entity:AddLight()
inst.Light:Enable(false)
inst.Light:SetRadius(15)
inst.Light:SetFalloff(0.75)
inst.Light:SetIntensity(.6)
inst.Light:SetColour(70/255,255/255,12/255)

 

Is it possible to make this light (or any other light) player-only? I really think that nightvision is a cool perk, but it's a gamebreaker when everyone can see it. 

I looked into woddie's code for beaver, but it's just the same as stated above. Since it was singleplayer, it worked as intended.

Is it possible to make a player-only light now when it's multiplayer? 

Best regards

Edited by Batmanwarrior

Share this post


Link to post
Share on other sites
rezecib    3175
woddie's code for beaver, but it's just the same as stated above.
That's because he hasn't actually been updated yet.

 

I don't think anyone's really solved this problem in DST yet, but I had an idea for it a while back that I was thinking of turning to get Woodie fixed... If you actually have light there, then it has to be for all players. But you can separate out the two components of the light: the visual effect, and the removal of Charlie. So you could remove the "grue" component, and then write code for a light that's only client-side. Not sure exactly how to do the second part yet, but I'll let you know if I get around to figuring it out. 

Share this post


Link to post
Share on other sites
Sarcen    21

I definitely think this is doable, simply by only adding the light component to the inst when the inst is the local player.

 

 

AddPlayerPostPrefab(function(player)

player:ListenForEvent("setowner", function(inst)  

if inst == ThePlayer then

inst.entity:AddLight()

...

end

end)

end)

 

Something like that

Share this post


Link to post
Share on other sites
Woodside235    1

I definitely think this is doable, simply by only adding the light component to the inst when the inst is the local player.

 

 

AddPlayerPostPrefab(function(player)

player:ListenForEvent("setowner", function(inst)  

if inst == ThePlayer then

inst.entity:AddLight()

...

end

end)

end)

 

Something like that

 

Can you give a little more context on how to use this? I'm a bit confused.

Share this post


Link to post
Share on other sites
DarkXero    2892

How about removing inst.entity:AddNetwork() on the light source.

Kinda like how lanterns and mining hats were before they fixed them.

 

EDIT: Now I remember the client lights couldn't be seen by clients.

Edited by DarkXero

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