Jump to content

Recommended Posts

I've been quite desperate looking for a way how to let several hours elapse while the player is passed out, but couldn't find a practical method to achieve this. All I found were mechanics using sleep or wait (with the menu popping up) or servetime(), which has its own issues.

 

Finally, the secret was revealed to me, when I was researching something unrelated, and in an example of code I noticed the global variable GameHour.

To spare the effort of figuring this one out to any other potential beginner modders like me, I'm posting the solution here. Hopefully someone will find it handy.

 

Now, there are actually four important Global Variabless we need to manipulate, in order to have a working means of how to let some time slip:
GameHour, GameDay, GameMonth, GameYear.

 

GameHour is a float, while the others are integers.

 

Now, I wanted to add twelve hours to the player's time, regardless of when this scene happens, which means I had to account for it being less than 12 hours till midnight, possibly also on the last day of the month, and possibly on the last day of year.
Through waiting for a very long time, I discovered that the Elder Scrolls calendar is exactly the same as ours, i.e. 12 months, alternating between 31 days, 30 days and 28 days, just like in real life. I didn't go as far as to determine whether there's a 29th every four years. Please let me know, if you find out.

So I wrote this little script to account for all of that. Works like a charm. Now, please bear with me, I am a beginner, so I'm sure it could have been written much more efficiently and with less redundance. Please post your own versions if you like. This version has the advantage of being very easy to read and understand. Feel free to use it, if you like.


I haven't fully tested this yet, so there might still be some errors. The script compiles nevertheless and worked on the occasions I tested it. The important takeaway being, Simply setting the value of one of those global values changes the in-game date correspondingly.

 

e.g. GameHour.SetValue(6.66)

 

Point the Properties to Global Variables of the same name.

 

Script follows:

 

;;;;;;;;;;;; Properties and Variables ;;;;;;;;;;;;;;

 

GlobalVariable Property GameHour Auto
GlobalVariable Property GameDay Auto
GlobalVariable Property GameMonth Auto
GlobalVariable Property GameYear Auto

float Hour = GameHour.GetValue() as float


int Day = GameDay.GetValue() as int
float HoursTillMidnight = (24 - Hour)
float HoursInNewDay = (12 - HoursTillMidnight)
int Month = GameMonth.GetValue() as int
int Year = GameYear.GetValue() as int
int MonthLength
bool LastOfMonth = false
bool EndOfYear = false

                

;;;;;;;;;;; Populating Variables ;;;;;;;;;;;;;;;;;;;

 

                If Month == 2 && Day == 28
                    MonthLength = 28
                    LastOfMonth = true
                ElseIf ((Month == 1 || 3 || 5 || 7 || 8 || 10 || 12) && Day == 31)
                    MonthLength = 31
                    LastOfMonth = true
                ElseIf ((Month == 4 || 6 || 9 || 11) && Day == 30)
                    MonthLength = 30
                Else
                    LastOfMonth = false
                EndIf
                
                
                If Month == 12
                    EndOfYear = true
                else
                    EndOfYear = false
                Endif
                
                
 ;;;;;;;;;;; Date Analysis + Apply New Values ;;;;;;;;;;
                
                If HoursTillMidnight < 12
                    
                    Hour = HoursInNewDay
                    GameHour.SetValue(Hour)
                    
                    If LastOfMonth == false
                        Day = (Day + 1)

                        GameDay.SetValue(Day)
                        
                    ElseIf (LastOfMonth == true && EndOfYear == false)
                        Month = Month + 1
                        Day = 1
                        GameMonth.SetValue(Month)
                        GameDay.SetValue(Day)
                        
                    ElseIf (LastOfMonth == True && EndOfYear == true)
                            Month = 1
                            Day = 1
                            Year = Year + 1
                            GameYear.SetValue(Year)
                            GameMonth.SetValue(Month)
                            GameDay.SetValue(Day)
                            
                    EndIf
                    
                Else
 
                    Hour = (Hour + 12)
                    GameHour.SetValue(Hour)
 
                Endif

 

Edited by gargamel9
Added missing line to apply correct day when it's not the end of a month.
Link to comment

Interested to know just how far out of sync this might put the game days.  The engine is terrible at processing dates and scripts that push the date past midnight on Sunday often cause the date to desync.  In general, that doesn't matter too much, but it is a big reason why AI procedures that are meant to run on weekends or specific days are highly unreliable.  Just curious if this might make it worse (or better?)

Link to comment
12 minutes ago, Seijin8 said:

Interested to know just how far out of sync this might put the game days.  The engine is terrible at processing dates and scripts that push the date past midnight on Sunday often cause the date to desync.  In general, that doesn't matter too much, but it is a big reason why AI procedures that are meant to run on weekends or specific days are highly unreliable.  Just curious if this might make it worse (or better?)

Hard to say, for that we would have to know the evaluating logic... I'm surprised there isn't much written, on these topics.

Link to comment
1 hour ago, ?????? 1627 said:

Properly rewritten , could you use for that?

 

  Hide contents

ScreenShot71.jpg.8ce412b059614fd30372cf8776eabf58.jpg

 

Sorry, I don't really see how that's related. This seems to be a counter within SexLab. Possibly that's a global variable, too, so you can probably change it the same way, but it doesn't have anything to do with time and date manipulation, so the part about detecting end of month and end of year wouldn't apply here. So, I guess I'm not sure what you're asking.

Link to comment
1 hour ago, gargamel9 said:

but it doesn't have anything to do with time and date manipulation,

Since it is still a counter, you could use it as a starting point to correct the sexlab counter that , as I read, it is also based on the time factor?

Of course it will have to be recompiled to be used , eliminating factor: day, month, year ? 

Link to comment
32 minutes ago, ?????? 1627 said:

Since it is still a counter, you could use it as a starting point to correct the sexlab counter that , as I read, it is also based on the time factor?

Of course it will have to be recompiled to be used , eliminating factor: day, month, year ? 

Can't say. Haven't even started digging into the Sexlab script yet, so I have no clue as to how it handles what. I only just recently got the grasp of basic Papyrus. But I still went ahead and posted this, as I could not find this solution anywhere on the net myself, and I believe this is a pretty useful thing to know...

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use