Difference between revisions of "GameMode"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>D4v3
m (Reset init to 0 after the timer has run down)
imported>Qazaaq
m (revert, the script runs in gamemode, so setting init back to 0 will cause it to run constantly)
Line 31: Line 31:
; ... or no, the time is up!
; ... or no, the time is up!
else
else
                        ;make timer available for the next time this script is run
                        set init to 0
;code to execute after 25 seconds
;code to execute after 25 seconds
endif
endif

Revision as of 19:00, 12 July 2008

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.

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