Talk:Global Scripts

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Nomination[edit source]

I've found activators to be much more powerful global scripts (all function-like and squishy... I mean, all function-like). There should at least be a link or something mentioning them too (well, there is some, but it talks about them locally). And again, cut out the Creation sections like Creating a New Cell.--Haama 00:44, 21 March 2008 (EDT)

Working on an extended version here.--Haama 14:34, 20 July 2008 (EDT)

Quest condition or CTD?[edit source]

--Kkuhlmann 20:27, 24 March 2006 (EST) Removed section about having to add a condition to a quest or the game will crash. Not true. There are plenty of quests without any conditions. If the game is crashing, it must be for some other reason (perhaps something in the script itself).

Probably right. The Player.GetIsRace function might be failing before the game is successfully initiated or loaded. At the very least, adding that particular condition to my own plugin forces the player to be playing a valid race before the game is loaded. --JT 21:36, 24 March 2006 (EST)
The script, for reference:
scriptname JTKhNightEyeScript

float fQuestDelayTime
short nighteye_toggle

begin GameMode

;If the player is not a Khajiit, we have to return here.  Unfortunately, we can't just stop
; the script because the player will not be a Khajiit until his/her race has been selected.
; I'll have to do some research into the chargen states in Oblivion.
if ( Player.GetIsRace "Khajiit" != 1 )
	return
endif

;Until the player is a Khajiit, this script will execute only once every 5 seconds or so,
; based on Oblivion's standard quest engine.
;If this point is reached, then the player is a Khajiit and we want to process this script every
; frame to allow perfect resolution of the player's Eye of Night power.
set fQuestDelayTime to ( 0.001 )

;The player has cast the Eye of Night power.
if ( Player.IsSpellTarget "LpRaceKhajiitNightEye" )
	if ( nighteye_toggle == 0 ) ;If we are not currently in night-vision mode...
		Player.Dispel "LpRaceKhajiitNightEye"
		Player.AddSpell "JTKhNightEyeAbility"
		set nighteye_toggle to 1
	else ;If we are currently in night-vision mode...
		Player.Dispel "LpRaceKhajiitNightEye"
		Player.RemoveSpell "JTKhNightEyeAbility"
		set nighteye_toggle to 0
	endif
endif

end GameMode
--Kkuhlmann 06:51, 25 March 2006 (EST)
Quest conditions only apply to the quest's dialogue, and since your quest doesn't involve dialogue, having a condition or not shouldn't have any impact. _Shouldn't_... obviously something strange is going on though.
Strange. I'll do some stress testing. Maybe I'll be able to work out a good synopsis for your codemonkeys. ;-) --JT 18:18, 25 March 2006 (EST)

When do quest scripts run?[edit source]

Quest scripts are not always running!

I was trying to use a global script to do something when the players journal/inventory was open. It appears these scripts will stop when a menu is open. Any other suggestions for my delemma?

Thanks

--Reflection 01:08, 19 October 2006 (EDT)

Sure they are. The problem you're having there -- I'm assuming -- is that you're using the GameMode block type like in the example. If you want your script to execute when the menus are open, you need to use the MenuMode blocktype instead.
One of the issues with Oblivion modding is that there is no real way to have a single block which executes regardless of whether the menu is open or not, however, so if you want the same code to execute while the menu is open as well as when the game is in progress, you'll have to copy-and-paste it into the MenuMode block too.
Most of the time, there's no need to run the GameMode code in the MenuMode block because when you're in MenuMode, there's no passage of time and thus no real need to affect the game world. --JT 18:10, 19 October 2006 (EDT)
(interrupted while trying to say somethign similar.) You can put a flag in the MenuMode block such that when back in GameMode it wil pick it up. You can also change fQuestDelayTime to make it pick up the flag change quicker. Not sure if this helps (?) GuidoBot 18:13, 19 October 2006 (EDT)
Dragoon Wraith TALK 18:57, 19 October 2006 (EDT): This was an issue for me from when I first saw this Wiki (i.e. before Oblivion was even released), and as soon as I had the CS I tried writing a script that read "Begin GameMode || MenuMode" and it compiled without a complaint. I've never had a need for this, so I've never tested it... Might be worth checking.
I think this is just another example of a less-than-perfect compiler and not additional functionality. See http://cs.elderscrolls.com/constwiki/index.php/Talk:Scripting_Tutorial:_My_Second_Script. GuidoBot 19:37, 19 October 2006 (EDT)
Thanks. I assumed GameMode was just a general 'code wrapper', like main in C. Silly me. Of course my code now crashes Oblivion, but thats another problem. --Reflection 00:52, 20 October 2006 (EDT)

Variable consistency when loading[edit source]

New topic: When restoring a game using Quickload (or load of Quicksave) it seems many things with more complicated scripts to not reload their global variables correctly. If you restart OB and load however all will seem fine for the same save game. This could be more general but I've experienced it will MODs just using justing quest scripts. Does anyone have any more input on this? Is it because the quest is resetting in some way, in which case can it be avoided/detected? The fact you can reload after restarting OB suggests this is truely a bug in OB. GuidoBot 18:19, 19 October 2006 (EDT)

Not really anything to do with how complicated the script is; OB just does a sloppy job of cleaning up data when reloading a savegame. I've noticed it mainly with variables in quest scripts, like you mentioned. There are also issues when loading a savegame from within the same cell, like objects that were altered during the current game not being restored to the state in which they were saved. O.o Looks like the devs may have chosen faster load times over stability. Scruggs 20:10, 19 October 2006 (EDT)
This is exactly what I also assumed was going on. I haven't determined whether this also applies to scripted object variables (e.g. tokens) because I have such mixtures of stuff in my MODs right now. If not then this would be a reason to avoid quest scripts for global variables! This is a very nasty bug in OB, one that the majority of modders should be made aware of and, hopefully, Bethseda themselves for a later patch. It might explain many of the wierder bugs experienced in script-based MODs to date - in fact I'm amazed it isn't a source of issues for their own [quest] scripts [that do not rely on stages]. GuidoBot 20:44, 24 October 2006 (EDT)
There might be a difference between how the game handles plugin-added scripts and those existing in the .esm. Not that I have any evidence to back that up. ;) I do kinda doubt a bug like that affecting the vanilla quests would slip by QA, though. Would be a good thing to test. Scruggs 20:54, 24 October 2006 (EDT)

Post-Merger Revision[edit source]

I have completed the long-due ( I think ) merger of the Quest Scripts article with the Global scripts article. Changes include transfer of most content from the Quest scripts article, some content revision and a few cosmetic changes. I had also managed to re-write most part of the article, removing the 1st person perspective, except for the last section.

The stuff that needs to be done now :

  • A proof reading and error correction
  • Re-writing the last bits
  • Renaming the article to "Global / Quest Scripts" or something similar.
  • Deleting the Quest Scripts article

shademe 08:32, 11 January 2009 (EST)

Uh... I don't feel that Quest Scripts and Global Scripts are necessarily the same thing. "Global" scripts usually refer to scripts that run every frame all the time and aren't truly tied to any actual quest. Global scripts are a type of Quest script, but not all Quest scripts are Global scripts, IMO.
Other than that, though, I'm really glad to see some work getting done on these older articles; they need improvement like this. We should discuss this whole global/quest thing, but no matter what this article has been substantially improved, so kudos and thanks for that.
Dragoon Wraith TALK 13:02, 11 January 2009 (EST)

To your 1st comment, true - I never thought of it. I just mechanically merged the articles ( in accordance to the reminder in the Portal page ). Means that it requires a revision, over a discussion.

It's a pity that there aren't many editors around. It's a wiki after all -- shademe 13:10, 11 January 2009 (EST)