Talk:Global Scripts
--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)
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)
- 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)
- 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.
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)