GameMode
Syntax:
begin GameMode
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.
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
The companion to this Blocktype is MenuMode, which executes whenever GameMode does not.
Notes[edit | edit source]
- 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.
External Links[edit | edit source]
Link to TES4 Construction Set Wiki: GameMode.