Jump to: navigation, search

Code placed inside this blocktype will be executed every frame during normal gameplay, i.e. whenever the player is not in any sort of menu.

For Quest scripts, GameMode code is executed once every X seconds, where X is whatever number is entered in to the "Script Processing Delay" field. By default this is every 5 seconds, but can be set as low as every tenth of a second.

For Object or Effect scripts, GameMode code is executed every frame, that is to say every time the game engine re-renders the current scene. This more or less directly corresponds to the player's framerate, meaning that GameMode code will be executed as frequently as 120 times per second. Keep this in mind when placing code in this block, and avoid invoking comparison or retrieval functions such as GetContainer or GetQuestRunning every frame.

The companion to this Blocktype is MenuMode, which executes whenever GameMode does not.


 begin GameMode


;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!

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

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


  • GameMode blocks will not run in items created at a workbench until dropped in the world or equipped (New Vegas).
  • Although comparison functions in GameMode blocks can induce a small amount of lag if run every frame, the problem becomes more pronounced in stacked objects held in inventory. As few as 25 stacked inventory items running functions like GetStage in every frame of the GameMode block will cause a 10-20 frame-per-second drop in framerate.