Can anybody spot an error with this script?

Post » Sun Dec 05, 2010 3:04 am

This is my drop lit torches scripts. I am experiencing a problem though. The torches drop fine, no problem there, but when I go to pick them up, instead of picking up the torch and holding it, my PC places it in his inventory. Can anybody see a reason why he does this?

Here are the two main scripts. There is another one, but I know it's not responsible for this behavior. I think the problem lies in the second scipt, but I'll post both for clarity.

ScriptName TorchBrightnessScriptfloat fQuestDelayTimefloat Brightnessfloat Brightness05float Brightness06float fWeightfloat Weightfloat fLightingTimershort CaveCountshort OblivionCountshort Typeshort TypeCountshort bLightingTorchshort Armedshort Amountshort Weapref Torchref rWeapref Cellref ItemBegin GamemodeIf GetGameLoaded	Set fQuestDelayTime to 1	RunBatchScript "Data\Brighter Torches.ini"	PrintC "Brighter Torches Initialized"EndIfIf Player.GetItemCount Torch05 > 0		Player.RemoveItemNS Torch05 1EndIfIf bLightingTorch	Set fLightingTimer to fLightingTimer - GetSecondsPassed	If fLightingTimer <= 0		Set Armed To Player.IsWeaponOut		Set rWeap To Player.GetEquippedObject 16		If Player.GetEquipped Torch02 == 0 && Armed == 0 || Player.GetWeaponAnimType < 2 && Player.IsShieldOut == 0 && GetWeaponType rWeap != 4			Set bLightingTorch To 0			Player.EquipItemNS Torch02			Set TorchIsEquipped To 1		EndIf	EndIfEndIfSet Weap To Player.GetWeaponAnimTypeIf TorchRetrieveMalonn == 1	set TorchRetrieveMalonn to 0EndIfSet rWeap to Player.GetEquippedObject 16If Player.GetEquipped Torch02 == 1 && Player.IsWeaponOut == 1 && Player.IsShieldOut == 1 || Weap > 1 || rWeap != 0 && GetWeaponType rWeap == 4	Player.AddItemNS torch06 1	Player.EquipItemNS torch06	Player.Drop torch06 1	Player.RemoveItemNS Torch02 1	Set TorchIsEquipped to 0EndIfIf Player.GetEquipped Torch02 && Player.IsTorchOut == 0	Player.UnequipItemNS Torch02		EndIfIf Player.GetEquipped Torch02 || TorchIsEquipped	Set TorchIsEquipped To 1Else	Set TorchIsEquipped To 0EndIf....other stuff not related to DLT


Here's where I think the problem lies, but cannot find anything:

ScriptName retrievetorchMalonnfloat TorchBurnoutshort Startershort Armedfloat Tempfloat TorchXfloat TorchYfloat TorchZfloat TorchFXfloat TorchFZref LightRefref rWeapBegin GameModeSetOwnershipIf GetDisabled	LightRef.Disable	Enable	Activate PlayerEndIfIf GetDisabled == 0 && Starter == 0	Set Temp to GetPos Z + 80	SetPos Z, Temp	Set LightRef To PlaceAtMe Torch03light	Set Starter To 1EndIfSet TorchBurnout To TorchBurnout + GetSecondsPassedSet TorchX To GetPos X set TorchY To GetPos Yset TorchZ To GetPos ZLightRef.SetPos X, TorchXLightRef.SetPos y, TorchYLightRef.SetPos z, TorchZIf (HasFlames == 0 || TorchBurnout >= 250)	LightRef.Disable	RemoveFlames	DisableEndIfEndBegin OnActivate PlayerActivateSet TorchRetrieveMalonn To 1Set Starter To 0LightRef.DisableSet TorchBurnout To 0EndBegin OnAdd Player Set rWeap To Player.GetEquippedObject 16If GetDisabled == 0	Player.AddItemNS Torch02 1	If Player.GetEquipped Torch02 == 0		Set Armed To Player.IsWeaponOut		If Armed == 0 || Player.GetWeaponAnimType < 2 && Player.IsShieldOut == 0 && GetWeaponType rWeap != 4			Player.EquipItemNS Torch02			Set TorchIsEquipped To 1		ElseIf Player.IsInCombat == 0 && aaaTorchBrightnessQuest.bLightingTorch == 0			Set aaaTorchBrightnessQuest.bLightingTorch To 1			Set aaaTorchBrightnessQuest.fLightingTimer To 1.5		EndIf	EndIfEndIfEnd

User avatar
Alexxxxxx
 
Posts: 3417
Joined: Mon Jul 31, 2006 10:55 am

Post » Sat Dec 04, 2010 5:23 pm

Uh oh. Bump time.
User avatar
BEl J
 
Posts: 3397
Joined: Tue Feb 13, 2007 8:12 am

Post » Sun Dec 05, 2010 1:36 am

I know there are some good scripters out there that may have an idea...
User avatar
Toby Green
 
Posts: 3365
Joined: Sun May 27, 2007 5:27 pm

Post » Sun Dec 05, 2010 4:07 am

Hmm, it's hard to tell and I can't give it a try without a working pc, but I'm not sure the OnAdd block gets called when you pick up an item. I know OnActivate is, but am not sure OnAdd is as well afterwards. So I don't see the code in this one executed ever in the current setting. I could be wrong though so it would be best to check if this block ever is executed at all first.

Then make sure your conditions are really doing what you want. There's operator precedence in Oblivion scripting as far as I remember and without brackets those complex conditions perhaps might not do exactly what you're aiming at.

Also I think if the second script is running on the torch, some majorly unwanted effects will happen when it gets picked up. I don't think the instance will keep its variables' values when it gets put into your inventory, as last time I checked the instance itself didn't survive this act. There can be scripts running on objects lying on the ground and there can be scripts running on objects in containers (the inventory "is" a container), but I'm very hesitant to expect they will preserve their state when the transition between both takes place.

Unfortunately that's all I can come up with for now. I'm sorry I can't be of more help with this.
User avatar
Trista Jim
 
Posts: 3308
Joined: Sat Aug 25, 2007 10:39 pm

Post » Sun Dec 05, 2010 2:34 am

I don't have the time to go through it thoroughly, but I just recommend debugging it ingame. Put a ton of PrintToConsole commands all over the script, describing which action should be taken. Then ingame do your thing with the torches, and check the console for the messages, and figure out which part isn't running, or which part doesn't have the desired effect.

80% of my scripting time I am debugging, it's pretty rare I find the mistakes by simply reading over the text. You need to test it and narrow the problem down ingame.

Goodluck!
User avatar
Big mike
 
Posts: 3423
Joined: Fri Sep 21, 2007 6:38 pm

Post » Sat Dec 04, 2010 2:12 pm

Thanks for you input, Drake the Dragon and Maegfaer. It turns out, I think, that I just needed to add parentheses to the scripts. I didn't know this was required. Thanks again.

That's all I did was add parentheses. And it works now.
User avatar
Dragonz Dancer
 
Posts: 3441
Joined: Sat Jun 24, 2006 11:01 am


Return to IV - Oblivion