Global Scripts/Extended

From the Oblivion ConstructionSet Wiki
Revision as of 15:44, 20 July 2008 by imported>Haama (So far)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Oblivion scripts, especially vanilla ones, tend to be object oriented, isolated, and independent. That is, the script is focused on the object alone, won't look at variables on other scripts, won't have variables that are set or even seen by other scripts, and the script will stop running once the player has left the cell. Even for quests, they act independent of other quests and only run until the quest is finished.

This is an extremely limited way of using scripts, but it is possible to hack and abuse the system a bit to make global scripts.

There are several types of global scripts, but essentially all can run whenever you want, all the time, and can share variables.


Oblivion scripts, especially vanilla ones, tend to be object oriented - each object acts independently of other objects, has their own set of variables that are untouched and unseen by other scripts, only run while the player is in the same cell, and even quests ignore the where the player is in other quests, run for a limited time (while the quest is unfinished), etc. This is an extremely limited way of using scripts, but there are tricks to

There are several types of global scripts, but (basically all are made for interconnecitvety... all are meant to always run...always in memory)


Global scripts are used to


MenuModes

Surprisingly, generic MenuMode blocks will run during the opening Main Menu (before the player has even loaded a game!). This is unnecessary and can even cause problems and CTDs. To prevent the script from running during this time, add a 1044 block with Return before the main, generic MenuMode block

begin GameMode
	...
end

begin MenuMode 1044 ;Main Menu
	return
end

begin MenuMode
	...
end

There are other menus that may cause problems or that don't require the script to be running. This if statement will cause the script to Return during those unnecessary menus. (Note that, due to wiki limiatations, the single if line has been broken into several lines)

begin MenuMode
	;If you're using an activator, make sure to test and set the Working variable
	if (MenuMode 1001) || (MenuMode 1007) || (MenuMode 1009) || (MenuMode 1012) || (MenuMode 1013)
	 || (MenuMode 1015) || (MenuMode 1016) || (MenuMode 1017) || (MenuMode 1018) || (MenuMode 1019)
	 || (MenuMode 1020) || (MenuMode 1021) || (MenuMode 1030) || (MenuMode 1032) || (MenuMode 1036)
	 || (MenuMode 1038) || (MenuMode 1039) || (MenuMode 1044) || (MenuMode 1047)
	 ;Loading Area screen, Dialog, Sleep/Wait, Pause, Options, Audio, Video, Video Display,
	 Gameplay, Controls, Class, Skills, Race/Sex, Load, Save, Main, Credits
		return
	endif
	...