Editing
Complete Example Scripts
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= A helper script with functions to get the current moonphase, sync between the two moons and day of the week = <syntaxhighlight lang="papyrus"> Scriptname ExtendedUtility Import Utility Import Math ;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + GetPassedGameDays() returns the number of fully passed ingame days + as int. + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; Int Function GetPassedGameDays() Global Float GameDaysPassed GameDaysPassed = GetCurrentGameTime() Return GameDaysPassed As Int EndFunction ;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + GetPassedGameHours() returns the number of passed ingame hours of + the current day as int. + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; Int Function GetPassedGameHours() Global Float GameTime Float GameHoursPassed GameTime = GetCurrentGameTime() GameHoursPassed = ((GameTime - (GameTime As Int)) * 24) Return GameHoursPassed As Int EndFunction ;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + GetCurrentMoonPhase() returns an integer representing the current + phase of the moons Masser and Secunda based on "SkyrimClimate". + Between 12:00 AM and 11:59 AM the phase during the night from last + day to this day is returned. Between 12:00 PM and 11:59 PM the + phase for the night from this day to next day is returned. Thus + a call to the function at night (between 8:00 PM and 6:00 AM) all- + ways returns the currently visible phase. + + The returncodes are as follows: + 0 - Full Moon + 1 - Decreasing Moon 3/4 + 2 - Decreasing Moon 1/2 + 3 - Decreasing Moon 1/4 + 4 - New Moon + 5 - Increasing Moon 1/4 + 6 - Increasing Moon 1/2 + 7 - Increasing Moon 3/4 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; Int Function GetCurrentMoonphase() Global Int GameDaysPassed Int GameHoursPassed Int PhaseTest GameDaysPassed = GetPassedGameDays() GameHoursPassed = GetPassedGameHours() If (GameHoursPassed >= 12.0) GameDaysPassed += 1 EndIf PhaseTest = GameDaysPassed % 24 ;A full cycle through the moon phases lasts 24 days If PhaseTest >= 22 || PhaseTest == 0 Return 7 ElseIf PhaseTest < 4 Return 0 ElseIf PhaseTest < 7 Return 1 ElseIf PhaseTest < 10 Return 2 ElseIF PhaseTest < 13 Return 3 ElseIf PhaseTest < 16 Return 4 ElseIf PhaseTest < 19 Return 5 ElseIf PhaseTest < 22 Return 6 EndIf EndFunction ;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + GetCurrentMoonSync() returns an integer that resembles where we are + in the 5 day cycle of the Snychronisation between the moons. + + Returncodes: + 0 - Moons appear at the same time + 1 - not yet determined how far ahead/behind Secunda is + 2 - not yet determined how far ahead/behind Secunda is + 3 - not yet determined how far ahead/behind Secunda is + 4 - not yet determined how far ahead/behind Secunda is + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; Int Function GetCurrentMoonSync() Global Int GameDaysPassed Int GameHoursPassed Int SyncTest GameDaysPassed = GetPassedGameDays() GameHoursPassed = GetPassedGameHours() If (GameHoursPassed >= 12) GameDaysPassed += 1 EndIf SyncTest = GameDaysPassed % 5 return SyncTest EndFunction ;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + 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() Global Int GameDaysPassed GameDaysPassed = GetPassedGameDays() return GameDaysPassed % 7 EndFunction </syntaxhighlight> '''How to make this script work''' *Put it to your "Data/Scripts/Source" Folder and compile. *Call it's functions in other scripts either by import and call by function name or by using ExtendedUtility.<FunctionName>()
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Landing page
Tutorials
Game Systems
Editor Reference
Scripting Reference
Recent changes
Help
Tools
What links here
Related changes
Special pages
Page information
Page values