Talk:Script Processing

From the Oblivion ConstructionSet Wiki
Revision as of 11:27, 12 November 2007 by imported>Haama (→‎Problem with specific assertions: Some answers)
Jump to navigation Jump to search

Good job here. There are at least two other timing effects I'm pretty sure I'm seeing. Firstly when you first AddItem to a remote (persistant) actor/container, this seems to force the GameMode on that item to be processed one time. Secondly there may be something going on with cells linked via a door. My token scripts, on a persistant actor in a shop in IC, trigger when I approach the (outside) door to the shop. I've also seen this while in connected interior cells. GuidoBot 17:34, 11 November 2006 (EST)

Scripts on actors: AI packages required?

Is it necessary that an actor have one or more AI packages in order for a script on that actor to run when the player is in a different cell? Abramul 12:27, 5 April 2007 (EDT)

Problem with specific assertions

# Scripts on references: processed every frame when its cell is loaded, not at all when the cell is not loaded. So these scripts run only when the player is nearby (which means these are often a good place to put relatively expensive scripts, doing things like distance checks).

I have a countainer in an interior cell linked by two doors with the IC Waterfront District, namely cells 02 and 03. Within that interior cell is a container using a non-persistent reference. However, its MenuMode block gets executed from the very begining - the first menu when entering the game, when no game is even loaded! try the following script, it will display the message "Entered MenuMode..." on top of the very first menu... Any clue?

scn fjPCMStoneChestLarge1Script
Short CheckContainer
Short DoIt
Begin OnLoad
	If fjPCMGlobalStoneChestLarge1
		pms fjPCMeffectStatueMarvels
	Endif
End

;---***** THE FOLLOWING BLOCK EXECUTES FROM THE VERY FIRST MENU, WHEN NO GAME IS EVEN LOADED!
Begin MenuMode	;--- Should be MenuMode 1008 for container Menu, but it  does not work
	Set CheckContainer to 1
	message "Entered MenuMode..."
	Return
End
;---*****

Begin OnReset	;--- Notify a Respawn Event
	; (... several sets and checks code ...)
	If DoIt
		Set fjPCMGlobalStoneChestLarge1 to 1
		Messagebox "You've aquired so many experience levels, that a new armament up to your persona is at hand. If you use the correct set of magic stones in the correct order inside the Stand of Marvels in your Magic Room, a new Lord's Armor Set of Marvels will respawn. Watch out for Bubo and Siomo!"
	Endif
End

Begin GameMode
	If CheckContainer
		Set CheckContainer to 0
		Message "Verifying the Star Dust Receptacle's Inventory...",4
		if (GetItemCount fjPCMArmorMarvelousGreavesLvl1 > 0) || (GetItemCount fjPCMArmorMarvelousGreavesLvl5 > 0) || (GetItemCount fjPCMArmorMarvelousGreavesLvl11 > 0) || (GetItemCount fjPCMArmorMarvelousGreavesLvl16 > 0) || (GetItemCount fjPCMArmorMarvelousGreavesLvl21 > 0) || (GetItemCount fjPCMArmorMarvelousGreavesLvl27 > 0)
			Set fjPCMGlobalStoneChestLarge1 to 1
			pms fjPCMeffectStatueMarvels
		Else
			Set fjPCMGlobalStoneChestLarge1 to 0
			sms fjPCMeffectStatueMarvels
		Endif			
	Endif
End

# Scripts on objects in containers: these are processed when the container's script is processed -- so, items on actors are processed when the actor is processed; items in other containers are processed every frame when the cell is loaded.

When the cell is loaded is not correct in regards to the above-mentioned oddity. It needs to be clarified IMHO...

Surprised that it happens for non-persistent objects, but see When do remote activators run for more information. Haven't looked at this page, but it does sound like it needs to be updated.
--Haama 00:40, 10 November 2007 (EST)
Thanks haama! I am amazed to see how you are taking your time in replying to many moders, either here or on the Bethesda site. Indeed, it's very generous of you. Are you working on a mod? Since I am learning and building a mod, I also read others questions, and sometimes when I feel that I can leave a path of an answer (if not the answer itself), I respond. At the same time it makes me dig and learn more...
When you say that remote activators run once when the mod is first loaded, and when a variable is set on that remote activator, do you mean that if I did not set any variable within the above-mentioned MenuMode block (or if I include all its code within an if clause), then it wouldn't pass through and stop executing after the 1st frame? More over, it seems to go beyond a single frame pass, since that as in your case, a message (in my case "Entered MenuMode...") is displayed indefinitely until I get out of that menu (until I actually load a saved game)...
--HawkFest 20:09, 11 November 2007 (EST)
I try to help out a bit when people get stuck. At first I found modding very frustrating because the information on it is scattered and incomplete - I wasn't even sure if variables would reset themselves every frame, etc., so I try to help others away from the same frustrations. "Are you making a mod?" - LOL, yes, too many of them at one time in fact. Right now I'm working on updating the Alchemical Sorter for COBL, and then I'll probably get back to updating my own mods (Alchemical Formulas really needs an update).
Anyway, "do you mean that if I did not set any variable within the above-mentioned MenuMode block (or if I include all its code within an if clause), then it wouldn't pass through and stop executing after the 1st frame?" - yes. Get rid of the 'Set CheckContainer to 1' line and the script will only run the one time when entering the game. An 'if' clause would be good though, since you don't want the message to display every frame when the player finally enters the room. Container MenuMode (1008) works fine for me, but I don't think that's what you want (unless it's the only container in the room, well, actually couple of rooms since it'll remain loaded in memory). Do you want it to start once the player opens the container? If so, use an onActivate block instead (just be sure to never activate it from a remote object script). Good luck.
--Haama 11:27, 12 November 2007 (EST)