HornetCorset Posted August 3, 2016 Share Posted August 3, 2016 I've got a character mod for Don't Starve that people have been begging me to port to DST since it started over a year ago. Now that I have DST, and some extra time, and have already ported it to Shipwrecked, I'd like to actually do the porting. However, I've run across a few problems. While I do need some extra art for the port, the main problem for which I have created this thread is this: my character steals Woodie's nightvision in the singleplayer version, and I am entirely unable to figure out how Woodie's nightvision works in the multiplayer. I've looked all over Woodie's code and none of it seems to have anything to do with nightvision. I can't figure this out myself, though that might be because my one mod is literally all my experience in both Don't Starve coding and in Lua. So, anyway, would someone please explain how to do nightvision in DST? Link to comment Share on other sites More sharing options...
DarkXero Posted August 4, 2016 Share Posted August 4, 2016 On 2/8/2016 at 10:13 PM, HornetCorset said: So, anyway, would someone please explain how to do nightvision in DST? local BEAVERVISION_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 UpdateNightVision(inst, phase) local enable = phase == "night" and inst.modnightvision:value() inst:DoTaskInTime(enable and 0 or 1, function(inst) inst.components.playervision:ForceNightVision(enable) inst.components.playervision:SetCustomCCTable(enable and BEAVERVISION_COLOURCUBES or nil) end) end local function OnInitNightVision(inst) if TheWorld.ismastersim or inst.HUD then inst:WatchWorldState("phase", UpdateNightVision) inst:ListenForEvent("modnightvisiondirty", UpdateNightVision) UpdateNightVision(inst, TheWorld.state.phase) end end local function common_postinit(inst) inst.modnightvision = net_bool(inst.GUID, "player.modnightvision", "modnightvisiondirty") inst.modnightvision:set(false) inst:DoTaskInTime(0, OnInitNightVision) end Use this and use inst.modnightvision:set(true) to turn it on, false to turn it off. DST has a playervision component, which is used in Woodie's SetBeaverVision function, which is called many times in there. Link to comment Share on other sites More sharing options...
HornetCorset Posted August 5, 2016 Author Share Posted August 5, 2016 1 hour ago, DarkXero said: DST has a playervision component, which is used in Woodie's SetBeaverVision function, which is called many times in there. ... wow, my reading comprehension is terrible. It all seems so obvious now. Thank you very much! Link to comment Share on other sites More sharing options...
Jpianist Posted August 20, 2016 Share Posted August 20, 2016 After coping and pasting this, i don't get the nightvision, do i have to replace something with my characters name? Link to comment Share on other sites More sharing options...
DarkXero Posted August 21, 2016 Share Posted August 21, 2016 2 hours ago, Jpianist said: After coping and pasting this, i don't get the nightvision, do i have to replace something with my characters name? If you copied and pasted, I hope you did NOT end with two common_postinit functions in the same file. Also, you should have used somewhere inst.modnightvision:set(true) to activate the nightvision at night. This way you can toggle it if there's a chance that your character may not be able to see in the dark (after all, Woodie only sees in the dark when he's the Werebeaver). I also posted alternative versions here: The first one uses a empty table for colourcubes (so you don't get a orange screen). The second one relies in sanity. And the third one is a modification for a mod that has a dwarf that drinks a tonic that grants him the ability to see in the dark. Link to comment Share on other sites More sharing options...
Jpianist Posted August 21, 2016 Share Posted August 21, 2016 (edited) Thanks for replying, now i know that i shouldn't have more than 1 common_postinit, so i'll just add the codes to my existing common_postinit. I'm gonna try the codes from the link you just gave me, i'm guessing that if i use this it will work for my char: local function common_postinit(inst) inst:DoTaskInTime(0, OnInitNightVision) end I'll use that in the common_postinit. Is it possible to triger the nightvision only when equipping myitem? Edited August 21, 2016 by Jpianist Link to comment Share on other sites More sharing options...
HornetCorset Posted August 24, 2016 Author Share Posted August 24, 2016 (edited) On 8/20/2016 at 7:49 PM, Jpianist said: Is it possible to triger the nightvision only when equipping myitem? In your item code, there should be a local function onequip (inst, owner). I believe that function should contain something along these lines: if owner.prefab=="esctemplate" then owner.modnightvision:set(true) end Similarly, there's a local function onunequip (inst, owner) that should have the same code, but with a false instead of a true. What that does is make it so that the item grants nightvision, but only if the character is the one you're working on. Edited August 24, 2016 by HornetCorset 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