Codelyy Posted November 25, 2015 Share Posted November 25, 2015 I've been trying to figure out this problem for a while but due to *cough* lack of programming skill *cough*I've had issues. Basically i want my character to have night vision so I've basically took the night vision code from Woodie and put it on my character but added a bit so it fits what i want it to do. This is the night vision code (Not the entire script):local MONSTERVISION_COLOURCUBES ={ day = "images/colour_cubes/beaver_vision_cc.tex", dusk = "images/colour_cubes/beaver_vision_cc.tex", night = "images/colour_cubes/beaver_vision_cc.tex", full_moon = "images/colour_cubes/beaver_vision_cc.tex",}local function NightVision(inst)if not TheWorld.ismastersim then inst.components.playervision:ForceNightVision(true) inst.components.playervision:SetCustomCCTable(MONSTERVISION_COLOURCUBES)endendlocal function NightVision2(inst)if not TheWorld.ismastersim then inst.components.playervision:ForceNightVision(false) inst.components.playervision:SetCustomCCTable(nil) endendinst:WatchWorldState("startnight", NightVision)inst:WatchWorldState("startday", NightVision2)The code seems to work fine but according to a friend I've messed up the porting of my mod to DST as whenever my character comes into vision of another player on a dedicated server, it crashes with this error: "[00:05:09]: [string "scripts/components/playervision.lua"]:43: attempt to index field 'inventory' (a nil value)" I just don't know what to do sadly and i was wondering if someone could help me? Link to comment https://forums.kleientertainment.com/forums/topic/59392-problem-with-nightvision/ Share on other sites More sharing options...
Mobbstar Posted November 25, 2015 Share Posted November 25, 2015 @codelyoko373, the following is the relevant section of code. local function OnEquipChanged(inst) local self = inst.components.playervision if self.nightvision == not inst.replica.inventory:EquipHasTag("nightvision") then self.nightvision = not self.nightvision if not self.forcenightvision then self:UpdateCCTable() inst:PushEvent("nightvision", self.nightvision) end endend I have no idea why or how it didn't crash for you, but this code pre-assumes the instance has a replica of inventory. This function probably shouldn't run under the circumstances you described. Again, I have no idea why equipment-related code would have anything to do with player proximity, so this is actually a very likely point. What crashes? You, the other player, or the whole server? Link to comment https://forums.kleientertainment.com/forums/topic/59392-problem-with-nightvision/#findComment-688575 Share on other sites More sharing options...
Codelyy Posted November 25, 2015 Author Share Posted November 25, 2015 (edited) @codelyoko373, the following is the relevant section of code. local function OnEquipChanged(inst) local self = inst.components.playervision if self.nightvision == not inst.replica.inventory:EquipHasTag("nightvision") then self.nightvision = not self.nightvision if not self.forcenightvision then self:UpdateCCTable() inst:PushEvent("nightvision", self.nightvision) end endend I have no idea why or how it didn't crash for you, but this code pre-assumes the instance has a replica of inventory. This function probably shouldn't run under the circumstances you described. Again, I have no idea why equipment-related code would have anything to do with player proximity, so this is actually a very likely point. What crashes? You, the other player, or the whole server?The person that is playing my character on a dedicated server as the host crashes when they come into the view of another player. I'm not sure if this also effects a client though. Edited November 25, 2015 by codelyoko373 Link to comment https://forums.kleientertainment.com/forums/topic/59392-problem-with-nightvision/#findComment-688602 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