CreativexFreedo Posted September 5, 2019 Share Posted September 5, 2019 I've recently started making a custom Character, and I'd like them to have Night vision but am unsure how to go about this. For this character only I'd like it to be like the light of a full moon all the time, without affecting the other players. How might I be able to achieve this? I can't seem to figure out how to look at other mods code to find examples, so I'm at a loss here. Link to comment Share on other sites More sharing options...
Thomas Die Posted September 5, 2019 Share Posted September 5, 2019 inst.components.playervision:ForceNightVision(true) Link to comment Share on other sites More sharing options...
CreativexFreedo Posted September 6, 2019 Author Share Posted September 6, 2019 Whereabouts would I place this? It would go in the character LUA yes? Link to comment Share on other sites More sharing options...
Ultroman Posted September 6, 2019 Share Posted September 6, 2019 Whenever you want to enable nightvision. If you want it on constantly, I think you can just put that line in the character LUA inside the master_postinit. I'm not sure if it persists after dying and then being resurrected. You'll have to test things like that out. Link to comment Share on other sites More sharing options...
suteneko Posted September 7, 2019 Share Posted September 7, 2019 Sorry for butting in but I wanted to utilize this code for one of my characters as well but it didn't work as intended. This code actually messes up vision during the daytime. Looks like a filter on top of the game. Is there another way to go about it so it only works during the night? Link to comment Share on other sites More sharing options...
Thomas Die Posted September 7, 2019 Share Posted September 7, 2019 inst:WatchWorldState("phase", function(inst,phasr) if phase == "day" then inst.components.playervision:ForceNightVision(false) elseif phase == "night" then inst.components.playervision:ForceNightVision(true) elseif phase == "dusk" then inst.components.playervision:ForceNightVision(false) end end) if you want custom colors check out the woodie file Link to comment Share on other sites More sharing options...
Ultroman Posted September 7, 2019 Share Posted September 7, 2019 23 minutes ago, thomas4845 said: inst:WatchWorldState("phase", function(inst, phase) if phase == "day" then inst.components.playervision:ForceNightVision(false) elseif phase == "night" then inst.components.playervision:ForceNightVision(true) elseif phase == "dusk" then inst.components.playervision:ForceNightVision(false) end end) Fixed the typo Link to comment Share on other sites More sharing options...
suteneko Posted September 7, 2019 Share Posted September 7, 2019 @thomas4845 Thank you! I just tested it and it worked! I'll look into the color thing since I was dumb and got the wrong idea. My idea of "night vision" was just making it so night wasn't pitch black and there was still some visibility from star and moonlight (which isn't what night vision means--). Link to comment Share on other sites More sharing options...
Hornete Posted September 7, 2019 Share Posted September 7, 2019 Don't you need to add a net bool and also activate the night vision for clients? It's what I had to do for Wilba in Hamlet characters, and Woodie does it too Link to comment Share on other sites More sharing options...
Ultroman Posted September 7, 2019 Share Posted September 7, 2019 (edited) 14 minutes ago, Hornete said: Don't you need to add a net bool and also activate the night vision for clients? It's what I had to do for Wilba in Hamlet characters, and Woodie does it too Yeah, I just got back to this one because I remembered that. Good catch, @Hornete!! The "parent" is just the player inst, right? local function ToggleMoggleRPC(inst) inst.player_classified.mogglevision:set(not inst.components.playervision.forcenightvision) end AddModRPCHandler("mycustomnamespace", "togglemoggle", ToggleMoggleRPC) and then where you want to toggle the nightvision you use SendModRPCToServer(MOD_RPC["mycustomnamespace"]["togglemoggle"], parent) You can still split it into an On and Off toggle, though, like this: local function TurnOnMoggleVisionRPC(inst) inst.player_classified.mogglevision:set(true) end local function TurnOffMoggleVisionRPC(inst) inst.player_classified.mogglevision:set(false) end AddModRPCHandler("mycustomnamespace", "turnonmoggle", TurnOnMoggleVisionRPC) AddModRPCHandler("mycustomnamespace", "turnoffmoggle", TurnOffMoggleVisionRPC) and then call these to turn it on or off: -- To turn it on SendModRPCToServer(MOD_RPC["mycustomnamespace"]["turnonmoggle"], parent) -- To turn it off SendModRPCToServer(MOD_RPC["mycustomnamespace"]["turnoffmoggle"], parent) Edited September 7, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Thomas Die Posted September 7, 2019 Share Posted September 7, 2019 Senpie we just spoke about spoiling the new comers Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now