Mansh00ter Posted February 14, 2012 Share Posted February 14, 2012 So I need to get the number of hours player has spent sleeping and have run into a problem: OnSleepStop event doesn't return anything like that. OnSleepStart event returns floats which are basically unreadable (you get something like 0.486658 representing the full date and game time). If I knew how these were constructed I could calculate at least the number of hours the player wanted to sleep. But I don't even know where to look. I hoped that the existing script responsible for giving rested bonuses would have a timer of some sorts, but it doesn't (and yeah, you can get a well rested bonus for one hour of sleeping, funny). So anyone has any idea how to tackle this? Is there a direct means of getting the number of hours spent sleeping?And are there any string operations for Papyrus, like substring or string to number? Then I could use substring to extract the data from the Utility.GameTimeToString return result, turn that back into number format and do calculations with that. Cause without a reliable way to get the number of hours spent sleeping, there is no way to do a proper Sleep component of basic needs... and since those worked just fine in older games I am assuming I simply am missing something. So... heeeeeeelp! Link to comment Share on other sites More sharing options...
Mansh00ter Posted February 14, 2012 Author Share Posted February 14, 2012 Just noticed there is a "Hours Slept" stat in the ingame statistics screen - anyone knows if those values are accessible from the editor? I'm thinking of maybe comparing the starting and end values using the OnSleepStart and OnSleepEnd events , that would maybe work. Link to comment Share on other sites More sharing options...
Pronam Posted February 14, 2012 Share Posted February 14, 2012 If it's a misc stat, you could try using this. Link to comment Share on other sites More sharing options...
Mansh00ter Posted February 14, 2012 Author Share Posted February 14, 2012 Heh, just figured that one out while poking around the CK Wiki - it works just fine. So if anyone has the same problem, what you do is RegisterForSleep() in your script, then use Game.QueryStat("Hours Slept") to get the number of hours slept, both on the OnSleepStart and OnSleepStop events. The difference between the two is the number of hours spent sleeping. Works like a charm. :) Link to comment Share on other sites More sharing options...
Recommended Posts