Complete Example Scripts: Difference between revisions

Jump to navigation Jump to search
no edit summary
imported>Mr6
imported>ChrisT1981
No edit summary
Line 265: Line 265:


♥ and thanks to our friends at Bethesda for such an awesome Creation Kit!
♥ and thanks to our friends at Bethesda for such an awesome Creation Kit!
=== A helper script with functions to get the current moonphase, sync between the two moons and day of the week ===
<source lang="papyrus">
Scriptname ExtendedUtility
Import Utility
Import Math
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ GetPassedGameDays() returns the number of fully passed ingame days
+ as int.
+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/;
Int Function GetPassedGameDays() Global
Float GameTime
Float GameDaysPassed
GameTime = GetCurrentGameTime()
GameDaysPassed = Floor(GameTime)
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 = Floor((GameTime - Floor(GameTime)) * 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 >= 1 && PhaseTest <= 3)
return 0
EndIf
If (PhaseTest >= 4 && PhaseTest <= 6)
return 1
EndIf
If (PhaseTest >= 7 && PhaseTest <= 9)
return 2
EndIf
If (PhaseTest >= 10 && PhaseTest <= 12)
return 3
EndIf
If (PhaseTest >= 13 && PhaseTest <= 15)
return 4
EndIf
If (PhaseTest >= 16 && PhaseTest <= 18)
return 5
EndIf
If (PhaseTest >= 19 && PhaseTest <= 21)
return 6
EndIf
If (PhaseTest >= 22 || PhaseTest == 0)
return 7
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()
Int GameDaysPassed
GameDaysPassed = GetPassedGameDays()
return GameDaysPassed % 7
EndFunction
</source>
==== 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>()
Anonymous user

Navigation menu