Difference between revisions of "User:Rasikko"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Rasikko
m
imported>Rasikko
Line 49: Line 49:


== Time Functions ==
== Time Functions ==
'''NOTE: The calculations for functions dealing with weeks or months, or years appear to be inaccurate. Currently in the process of reviewing calculations and making corrections.'''
Various functions for calculating time in skyrim. Most use [[GetCurrentGameTime - Utility]] as it returns the total game days passed. Making it easier for conversions.<br>
Various functions for calculating time in skyrim. Most use [[GetCurrentGameTime - Utility]] as it returns the total game days passed. Making it easier for conversions.<br>
This simple function converts days passed into hours passed.
This simple function converts days passed into hours passed.

Revision as of 13:55, 11 February 2018

Remove from Array

Int[] Function RemoveFromArray(Int[] array, int startIndex, int numOfElementsToRemove = 1) Global
	; Removes a number of elements from an array from the starting index.
	; Change the return, parameter, and variable type to suit the array type you are using.
	
	int arrayLength = array.length
	
	if (startIndex == 0 && numOfElementstoRemove == 0)
		array[startIndex] = 0
		return array
	elseif numOfElementsToRemove >= arrayLength
		; To prevent an error. Returns the array unchanged.
		return array
	else
		while (startIndex < numOfElementsToRemove + 1)
			array[startIndex] = 0
			startIndex += 1
		endwhile
	endif
	
	return array
EndFunction

Reverse an Array

Form[] Function ReverseArray(Form[] array) Global
	; Reverses the order from the smallest index to the largest and returns the array.
	; Change the return, parameter, and variable type to suit the array type you are reversing.
 
	Int index = array.length
	Int i = 0
	Form temp
 
	while (i < (index / 2))
		temp = array[i]
		array[i] = array[(index - 1) - i]
		array[(index - 1) - i] = temp
		i += 1
	endwhile
 
	return array
EndFunction

Unit Converions

The Unit page lists the Skyrim Unit to metric/imperial conversions, centimeters to inches is obvious, though it doesn't list the calculations when going to feet, so here it is: FT = Unit * 0.046875 --Rasikko (talk) 2018-01-10T12:18:45 (EST)

Time Functions

Various functions for calculating time in skyrim. Most use GetCurrentGameTime - Utility as it returns the total game days passed. Making it easier for conversions.
This simple function converts days passed into hours passed.

Float Function GetGameHoursPassed()
	; Converts the game days passed to game time hours.
	return Utility.GetCurrentGameTime() * 24
EndFunction


This function takes the game days passed and converts them into minutes passed.

Float Function GetGameMinutesPassed()
    ; Converts the game days passed to game minutes passed.
    return Utility.GetCurrentGameTime() * 24 * 60
EndFunction


To get the total real minutes passed since the game started, you do the following:

Game.GetRealHoursPassed() * 60


Short note about game time: Game time is paused when in a menu. While this is a well known fact, it can be easily forgotten when working with it along side real time, as real time obviously keeps running.

Skyrim has no leap years, and thus has common years, where the first day and last day of the year are on the same day of the week.

Self Reminders

  • When time permits, add another example concerning the Events OnActivate, OnTriggerEnter and OnTriggerLeave.
  • Test out function for acquiring the xp for the next level and add it to the condition function page of the same name as an alternative to it.