. . . Posted December 12, 2016 Share Posted December 12, 2016 (edited) Hello, I need help with a problem I have . So, I want to use this code to give my character night vision (like vision you get when wearing molehat) act.target.components.playervision:ForceNightVision(true) and it works fine on world with no caves, but on world with caves it just makes you immune to grue & nothing else happens... Anyone know what I can do to fix this or give character mole vision properly? I appreciate any help thank you very much for reading my problem have a great day/night ! Edited December 13, 2016 by SuperDavid Link to comment Share on other sites More sharing options...
DarkXero Posted December 13, 2016 Share Posted December 13, 2016 Because it has to run on the client as well as the server. Game achieves this by making both server and client listen to the changes in the player's equipslots. local function ApplyNightvision(inst) if inst.components.playervision then -- get net variable value and use it local val = inst.givemethenightvision:value() inst.components.playervision:ForceNightVision(val) end end local function RegisterNightvisionListener(inst) -- reaction when value changes inst:ListenForEvent("givemethenightvisiondirty", ApplyNightvision) end local function common_postinit(inst) -- net variable inst.givemethenightvision = net_bool(inst.GUID, "player.givemethenightvision", "givemethenightvisiondirty") -- default value inst.givemethenightvision:set(false) -- setup after deserialization inst:DoTaskInTime(0, RegisterNightvisionListener) end for your character. Now you do on your action if act.target.givemethenightvision then act.target.givemethenightvision:set(true) end And the variable change will propagate to clients, which were listening to the change, as well as the server, because we put our code in common_postinit. Link to comment Share on other sites More sharing options...
. . . Posted December 13, 2016 Author Share Posted December 13, 2016 Thank you so very much, DarkXero !! 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