Difference between revisions of "GameMode"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Middas
imported>QQuix
(Added a note about exceptions)
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Script within the gamemode block will be run every frame while the game is in non-menu mode.  Most scripts will use this block type exclusively.
Script within the gamemode block will be run every frame while the game is in non-menu mode.  Most scripts will use this block type exclusively. '''This means that the block is run every fraction of a second; Non-menu mode meaning that you are not in a menu such as your inventory.'''
 
===Notes===
*The above statement is true, provided the script runs. Not all scripts run every frame, e.g, Quest scripts (see [[FQuestDelayTime]]) and scripts on references not loaded.


'''Example:'''
'''Example:'''
Line 10: Line 13:


begin GameMode
begin GameMode
; Has the timer been set up already?
if init == 0  
if init == 0  
;set the timer value
 
;set the timer value, count down 25 seconds
set timer to 25
set timer to 25
;Make sure we only set up the timer once!
set init to 1
set init to 1
;Add whatever you want to start at the beginning of the timer here
...
;The timer was set up already, lets count down!
else
else
; We still have some time left...
if timer > 0
if timer > 0
set timer to timer - getSecondsPassed
set timer to timer - getSecondsPassed
; ... or no, the time is up!
else
else
;code to execute after 25 seconds
;code to execute after 25 seconds
Line 23: Line 39:
end
end
</pre>
</pre>
Note: This does not mean it will run all the time.  This means that it will run only after you have activated the object, spell or quest that this is tied to.


[[Category: Commands]]
[[Category: Blocktypes]]

Latest revision as of 07:10, 24 December 2015

Script within the gamemode block will be run every frame while the game is in non-menu mode. Most scripts will use this block type exclusively. This means that the block is run every fraction of a second; Non-menu mode meaning that you are not in a menu such as your inventory.

Notes[edit | edit source]

  • The above statement is true, provided the script runs. Not all scripts run every frame, e.g, Quest scripts (see FQuestDelayTime) and scripts on references not loaded.

Example:

;sample timer script 
scn myScript

float 	timer
short 	init

begin GameMode
	; Has the timer been set up already?
	if init == 0 

		;set the timer value, count down 25 seconds
		set timer to 25

		;Make sure we only set up the timer once!
		set init to 1

		;Add whatever you want to start at the beginning of the timer here
		...

	;The timer was set up already, lets count down!
	else

		; We still have some time left...
		if timer > 0
			set timer to timer - getSecondsPassed

		; ... or no, the time is up!
		else
			;code to execute after 25 seconds
		endif
	endif
end