Goregonzola Posted February 11, 2021 Share Posted February 11, 2021 (edited) Have a great day, reader! I would like to ask for a little help about the following situation: I found this coding about custom night vision for Don't Starve singleplayer: Spoiler local light = inst.entity:AddLight() light:SetFalloff(0.2) light:SetIntensity(0.9) light:SetRadius(6.0) light:SetColour(RRR/255, GGG/255, BBB/255) light:Enable(false) inst:AddTag("sight_off") local function NightVision(inst) if GetClock() and GetWorld() then if GetClock():IsDay() and inst:HasTag("sight_on") and not GetWorld():IsCave() or GetClock():IsDusk() and inst:HasTag("sight_on") and not GetWorld():IsCave() then light:Enable(false) inst:AddTag("sight_off") inst:RemoveTag("sight_on") end if GetClock():IsNight() and inst:HasTag("sight_off") or GetWorld():IsCave() and inst:HasTag("sight_off") then light:Enable(true) inst:AddTag("sight_on") inst:RemoveTag("sight_off") end end end inst:DoPeriodicTask( 0.0, function(inst) NightVision(inst) end) My question is: If there's a way, how can this coding be transformed to be DST compatible, and to make it fit into a custom hat's prefab file (so the wearer gains the vision)? I'm incredibly grateful for any tiny help Edited February 11, 2021 by BillTheCipher Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/ Share on other sites More sharing options...
CarlZalph Posted February 11, 2021 Share Posted February 11, 2021 It's much easier here in DST. In your item's equippable's OnEquip: owner.components.playervision:ForceNightVision(true) owner.components.playervision:SetCustomCCTable({}) You can set the custom colour cube table to something else if you want some display effect like Woodie's sepia tone or moggles/etc. Then with OnUnequip: owner.components.playervision:ForceNightVision(false) owner.components.playervision:SetCustomCCTable(nil) 1 Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428025 Share on other sites More sharing options...
Goregonzola Posted February 11, 2021 Author Share Posted February 11, 2021 (edited) @CarlZalph Thanks for the info! How can I get more informations about the colour cube tables? Edit: I've tried the codings. I might have messed up something, but they don't seem to work. Neither this way: Spoiler local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_hat", "vrhead", "swap_hat") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") owner.components.playervision:ForceNightVision(true) owner.components.playervision:SetCustomCCTable({}) print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEADBASE") owner.AnimState:Show("HEADBASE_HAT") end end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") owner.components.playervision:ForceNightVision(false) owner.components.playervision:SetCustomCCTable(nil) if owner:HasTag("player") then owner.AnimState:Show("HEADBASE") owner.AnimState:Hide("HEADBASE_HAT") end end or this way: Spoiler local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_hat", "vrhead", "swap_hat") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEADBASE") owner.AnimState:Show("HEADBASE_HAT") end owner.components.playervision:ForceNightVision(true) owner.components.playervision:SetCustomCCTable({}) end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEADBASE") owner.AnimState:Hide("HEADBASE_HAT") end owner.components.playervision:ForceNightVision(false) owner.components.playervision:SetCustomCCTable(nil) end Edited February 11, 2021 by BillTheCipher Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428045 Share on other sites More sharing options...
Wonderlarr Posted February 11, 2021 Share Posted February 11, 2021 2 hours ago, BillTheCipher said: @CarlZalph Thanks for the info! How can I get more informations about the colour cube tables? Edit: I've tried the codings. I might have messed up something, but they don't seem to work. Neither this way: Hide contents local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_hat", "vrhead", "swap_hat") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") owner.components.playervision:ForceNightVision(true) owner.components.playervision:SetCustomCCTable({}) print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEADBASE") owner.AnimState:Show("HEADBASE_HAT") end end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") owner.components.playervision:ForceNightVision(false) owner.components.playervision:SetCustomCCTable(nil) if owner:HasTag("player") then owner.AnimState:Show("HEADBASE") owner.AnimState:Hide("HEADBASE_HAT") end end or this way: Hide contents local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_hat", "vrhead", "swap_hat") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") print('A') if owner:HasTag("player") then print('B') owner.AnimState:Hide("HEADBASE") owner.AnimState:Show("HEADBASE_HAT") end owner.components.playervision:ForceNightVision(true) owner.components.playervision:SetCustomCCTable({}) end local function OnUnequip(inst, owner) owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEADBASE") owner.AnimState:Hide("HEADBASE_HAT") end owner.components.playervision:ForceNightVision(false) owner.components.playervision:SetCustomCCTable(nil) end What exactly isn't working? I have recent experience with getting night vision working on an item like this, if you're having a similar problem that I was having, try seeing if Charlie will attack your character while the night vision would be applied. There's a chance it's only taking effect on the server side, and I can help you fix that. Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428113 Share on other sites More sharing options...
Goregonzola Posted February 11, 2021 Author Share Posted February 11, 2021 @TheSkylarr When I equip the headwear, the character just wears it without the night vision. Charlie still damages the character Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428152 Share on other sites More sharing options...
Wonderlarr Posted February 11, 2021 Share Posted February 11, 2021 (edited) 35 minutes ago, BillTheCipher said: @TheSkylarr When I equip the headwear, the character just wears it without the night vision. Charlie still damages the character That's... really weird. Are you absolutely sure the code is actually running? I sometimes accidentally load the workshop version of my mod instead of the dev version for example, which is different code. Only reason I can think of for nightvision not working when called is if something else is CONSTANTLY forcing it back off again, but as far as I know, the only thing in the entire vanilla game that uses ForceNightVision is Woodie's transformation, which I hope you aren't using to test it lol. Edit: I tested your code on one of my own hats from my mod, it seems to grant Night Vision correctly, so now I am ultra confused as to why it's not working for you. Edited February 11, 2021 by TheSkylarr Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428172 Share on other sites More sharing options...
Goregonzola Posted February 11, 2021 Author Share Posted February 11, 2021 @TheSkylarr I've double checked everything, I feel sillier and sillier I updated the whole mod here: LeVR.rar Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428198 Share on other sites More sharing options...
Wonderlarr Posted February 11, 2021 Share Posted February 11, 2021 Just now, BillTheCipher said: @TheSkylarr I've double checked everything, I feel sillier and sillier I updated the whole mod here: LeVR.rar 11.5 MB · 0 downloads I'm taking a look right now, I'll reply again if I figure anything out. @BillTheCipher After testing your code, the only edits I made were to enable normal characters to wear the headset, it seems to grant the nightvision correctly in the local world, and only server side in a multiplayer setting. I can help fix the problem with multiplayer, but charlie shouldn't be able to hit you if that's the case regardless. 1 Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428201 Share on other sites More sharing options...
Goregonzola Posted February 11, 2021 Author Share Posted February 11, 2021 @TheSkylarr So, if I understand it right, the headset can only provide night vision if the tag requirement is erased? Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428217 Share on other sites More sharing options...
Wonderlarr Posted February 12, 2021 Share Posted February 12, 2021 4 hours ago, BillTheCipher said: @TheSkylarr So, if I understand it right, the headset can only provide night vision if the tag requirement is erased? Well, I don't think it was because of that, though you could give it a try. I believe you should fully restart your game if you haven't already and give it a try in a local world, that is a world without caves set to 1 max player. If it works there, let me know, as well as check the tag requirement thing. It really shouldn't be that though. Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428319 Share on other sites More sharing options...
Goregonzola Posted February 12, 2021 Author Share Posted February 12, 2021 @TheSkylarr I tried the coding with a local world, it do seems to work that way. What can be done about this? Link to comment https://forums.kleientertainment.com/forums/topic/126968-help-adding-night-vision-to-custom-helmet/#findComment-1428422 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