Foxrai Posted February 18, 2015 Share Posted February 18, 2015 I know DST doesn't have ROG yet, but I want to put this part in the code for both - DS and DST. It's about to fix character freezing during winter, but not overheating during summer (more less like Wilson's beard, which won't kill him in summer ) Goes in char.lua: inst:WatchWorldState("startday", function(inst) if TheWorld.state.issummer then inst.components.temperature.inherentinsulation = 0 endend) inst:WatchWorldState("startday", function(inst) if TheWorld.state.iswinter then inst.components.temperature.inherentinsulation = 125 endend)Game starts. But when character enters the world such error appears, saying that WorldWatchState is a nil value... in everything.. DST and DS and ROG. I more less know what a nil value is, but just no idea how to fix that here :/ Link to comment Share on other sites More sharing options...
DarkXero Posted February 18, 2015 Share Posted February 18, 2015 DS and RoG have no WatchWorldState function. Only DST has it.If the log message says that WorldWatchState is a nil value, did you look for a WorldWatchState that should be a WatchWorldState? Link to comment Share on other sites More sharing options...
Foxrai Posted February 18, 2015 Author Share Posted February 18, 2015 did you look for a WorldWatchState that should be a WatchWorldState? That's my typo indeed. I meant WatchWorldState. Already know that WatchWorldState is DST only... So I could use a ListenForEvent then, ye? And then - it should work on all 3 - DS,DST and DS ROG? (not really a point of having this for normal NOT-ROGed DS, since you can't overheat but still) Link to comment Share on other sites More sharing options...
Kzisor Posted February 18, 2015 Share Posted February 18, 2015 @Foxrai, if you are trying to code this for both DS/DS:ROG and DST then you need to determine whether or not the engine you are running it in is for DS or DST. The issue is that DST doesn't use ListenForEvent to denote season changes like DS does, so you will have to have additional code for it to work in both. My original Pond Manager mod worked very similar to this in nature, until I broke it apart and decided to test another theory. Look at my previous topics and you should be able to find a working example by simplex on how to accomplish the check for the version. Link to comment Share on other sites More sharing options...
Foxrai Posted February 18, 2015 Author Share Posted February 18, 2015 (edited) @Kzisor, really appreciate your patience to myself. Also found this:The events pushed in singleplayer by the Clock and SeasonManager components ("dusktime", "daycomplete", "rainstart", "seasonChange", etc.) no longer exist in multiplayer, having been replaced by world state watching (e.g.inst:WatchWorldState("isdaytime", callback_fn)), but for cross-compatibility the original events were wrapped using wicker, so from the mod perspective they still exist as they do in singleplayer. What wicker does is, if in multiplayer, intercepting theinst:ListenForEvent() calls for these particular events and replacing them with the corresponding inst:WatchWorldState() calls (and doing the reverse analogue forinst:RemoveEventCallback). Thus, at the mod level, usage remains exactly as in singleplayer, including the contents of the data table passed as the second parameter to some event callbacks.Made it more clear. So the code:local function WatchPhase(inst, phase) if phase == "summer" then inst.components.temperature.inherentinsulation = 0end if phase == "winter" then inst.components.temperature.inherentinsulation = 1233456endendinst:WatchWorldState("phase",WatchPhase,TheWorld)Should work in DST. Then If I want to make it work in DS/ROG, the easiest way, is to change inst:WatchWorldState("phase",WatchPhase,TheWorld)intoinst:ListenForEvent(...and ye.. what? phase? or winter/summer?). Don't really get what will be the "event" here :/ Edited February 18, 2015 by Foxrai Link to comment Share on other sites More sharing options...
Kzisor Posted February 18, 2015 Share Posted February 18, 2015 @Foxrai, you want to use the following: inst:ListenForEvent("seasonChange", OnSeasonChange, GetWorld()) Inside OnSeasonChange you want to use the following: local season = GetSeasonManager():GetSeason() Now you can determine the season based on SEASONS enum. Link to comment Share on other sites More sharing options...
rezecib Posted February 18, 2015 Share Posted February 18, 2015 @Foxrai, I don't believe this is necessary at all. Insulation against cold and insulation against heat are actually separate values in the temperature component in RoG: self.inherentinsulation = 0 self.inherentsummerinsulation = 0 Link to comment Share on other sites More sharing options...
Foxrai Posted February 19, 2015 Author Share Posted February 19, 2015 (edited) @rezecib,Wait since my problem is about temperature not some other feature, instead of writing whole lines like this: inst:WatchWorldState("startday", function(inst) if TheWorld.state.issummer then inst.components.temperature.inherentinsulation = 0 endend) I can just add it as those simple codes right under stats of Hunger,sanity etc? inst.components.temperature.inherentinsulation = 123456inst.components.temperature.inherentsummerinsulation = 123456 (and it's like: 1 - is overheating faster, than for example 100?) Literally what I want to achieve is character which: 1.acts like Wilson WITH beard during WINTER (so is not freezing SO FAST)2.acts like Wilson WITHOUT beard during SUMMER (so is not overheating faster and can cool down same quick as other characters) While point 1 makes cooling down hard in summer.. This I'm wondering if those simple codes will do it Edited February 19, 2015 by Foxrai Link to comment Share on other sites More sharing options...
rezecib Posted February 19, 2015 Share Posted February 19, 2015 @Foxrai, Both inherentinsulation values are zero by default, so you can just set the inherentinsulation one. No need to touch the inherentsummerinsulation, if you look at RoG's temperature code it basically adds negative summer insulation if you have a beard. Link to comment Share on other sites More sharing options...
Foxrai Posted February 19, 2015 Author Share Posted February 19, 2015 @rezecib, ok so I can just use this literally:nst.components.temperature.inherentinsulation = 120 (<<<that's around rabbit earmuffs value if im right...)inst.components.temperature.inherentsummerinsulation = 0 And then I won't freeze SO fast in winter like Wilson, but I will be able to cool down in summer like for example Wendy or Willow? Just making sure Link to comment Share on other sites More sharing options...
rezecib Posted February 20, 2015 Share Posted February 20, 2015 @Foxrai, Rabbit earmuffs are 60, 120 is winter hat. Beard comes to 135, I believe, with beefalo hat at 240. 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