How to get the current day of the week in Papyrus ?

Post » Tue Jun 19, 2012 9:49 pm

Hi,

I see that in the console, you can get the current day of the week with GetDayOfWeek but I don't see any equivalent function in Papyrus...

I need a trigger event that will only apply on Sundas

Event OnTriggerEnter(ObjectReference akActionRef)    	 if("today is Sundas")			    GetOwningQuest().SetStage(800)	    endifEndEvent

There are a few global variables about GameTime already passed and Utility.GameTimeToString() but there's no String parsing function or calendar script AFAIK

The only solution I can see is using the Global variable GamesDayPassed % 7 and offset with the first week day of the game.

Any other solution ?

thanks.
User avatar
Averielle Garcia
 
Posts: 3491
Joined: Fri Aug 24, 2007 3:41 pm

Post » Tue Jun 19, 2012 7:08 pm

The only solution I can see is using the Global variable GamesDayPassed % 7 and offset with the first week day of the game.

No global variable needed. For such things I've created my own helper script that includes such functions. So long you declare your own functions as global you can invoke them from any other script by using MyhelperScript.MyhelperFunction() as long as you did compile the helper script.

I just quickly added the function you need to my helper script as it could be useful for me aswell. I placed the code below(Edit: hmm the code editor in this forum doesn't read tabs obviously, my original code is indented):

Spoiler

Import UtilityImport Math;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ GetPassedGameDays() returns the number of fully passed ingame days+ as int.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/;Int Function GetPassedGameDays() GlobalFloat GameTimeFloat GameDaysPassedGameTime = GetCurrentGameTime()GameDaysPassed = Floor(GameTime)return GameDaysPassed as IntEndFunction;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ GetDayOfWeek() returns the current ingame day of the week as int.++ Returncodes:+  0 - Sundas+  1 - Morndas+  2 - Tirdas+  3 - Middas+  4 - Turdas+  5 - Fredas+  6 - Loredas++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/;Int Function GetDayOfWeek()Int GameDaysPassedGameDaysPassed = GetPassedGameDays()return GameDaysPassed % 7EndFunction
User avatar
Anna Beattie
 
Posts: 3512
Joined: Sat Nov 11, 2006 4:59 am

Post » Tue Jun 19, 2012 5:26 pm

Yes, that's what I meant by using GamesDayPassed and I had implemented the same code but I was wondering if there was something directly in papyrus.

I agree with you it's definitely a reusable piece of code and I was very surprised not to see that off the box since most progammation languages have some sort of calendar.

thanks !
User avatar
Emma louise Wendelk
 
Posts: 3385
Joined: Sat Dec 09, 2006 9:31 pm

Post » Tue Jun 19, 2012 8:34 am

No unfortunatly there was no such thing in papyrus hence I also created functions for getting the current Moonphase aswell as the Synchronicity between the two moons from the number of passed ingame days.

In the end they gave us all we need, a function to get the passed ingame time, anything else can be derived from it :P.
User avatar
Ezekiel Macallister
 
Posts: 3493
Joined: Fri Jun 22, 2007 12:08 pm

Post » Tue Jun 19, 2012 11:25 am

you're right :biggrin:
User avatar
Bedford White
 
Posts: 3307
Joined: Tue Jun 12, 2007 2:09 am


Return to V - Skyrim