Script not doing what it should...

Post » Wed Sep 07, 2011 7:06 pm

Set HKOne to GetHotKeyItem 1Set HKTwo to GetHotKeyItem 2Set HKThree to GetHotKeyItem 3Set HKFour to GetHotKeyItem 4Set HKFive to GetHotKeyItem 5Set HKSix to GetHotKeyItem 6Set HKSeven to GetHotKeyItem 7Set HKEight to GetHotKeyItem 8Set sAttackKey to GetControl 4If HKOne != aaaMalonnHotKeyTorch || HKTwo != aaaMalonnHotKeyTorch || HKThree != aaaMalonnHotKeyTorch || HKFour != aaaMalonnHotKeyTorch || HKFive != aaaMalonnHotKeyTorch || HKSix != aaaMalonnHotKeyTorch || HKSeven != aaaMalonnHotKeyTorch || HKEight != aaaMalonnHotKeyTorch		ReturnElseif (HKOne == aaaMalonnHotKeyTorch && IsControlPressed 18) || (HKTwo == aaaMalonnHotKeyTorch && IsControlPressed 19) || (HKThree == aaaMalonnHotKeyTorch && IsControlPressed 20) || (HKFour == aaaMalonnHotKeyTorch && IsControlPressed 21) || (HKFive == aaaMalonnHotKeyTorch && IsControlPressed 22) || (HKSix == aaaMalonnHotKeyTorch && IsControlPressed 23) || (HKSeven == aaaMalonnHotKeyTorch && IsControlPressed 24) || (HKEight == aaaMalonnHotKeyTorch && IsControlPressed 25)		Player.EquipItemNS Torch02 1Endif


...is an excerpt from a script that won't do what it's supposed to. There is more to the script, but it doesn't apply to the problem I'm having. I created a hotkey to equip a torch when the associated hotkey is pressed, like OOO. I was having issues with double-hotkey items, so equipping the torch from a hotkey that is assigned to something else would also equip the torch and the item assigned to the hotkey. I corrected that with the return statement seen above. Problem is the next if statement isn't doing what it should. It should equip the torch if my hotkey item is assigned to the slot, and you press the correct button. But, with my play testing, I have the equip torch item assigned to hotkey 8, and it doesn't equip. I just get a message saying "You cannot equip this item", and the torch is not pulled out from the players inventory.

On a side note, using "EquipItemNS" should remove that annoying spam, but doesn't.

Some insight from good scripters would be appreciated.
User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am

Post » Wed Sep 07, 2011 7:53 am

I see the problem. It's not getting past the "return" statement. Noob logical error on my part. Let me try something and see if it corrects it. I'll post the script if it works correctly.
User avatar
Kelvin
 
Posts: 3405
Joined: Sat Nov 17, 2007 10:22 am

Post » Wed Sep 07, 2011 8:44 am

I'm having trouble figuring out how to write the script.

What I want to happen is (see the above script), I don't want the rest of the script to process if you do NOT press the hotkey associated with the aaaMalonnHotkeyTorch hotkey item. So, say it's assigned to hotkey 1, if you press hotkeys 2 - 8, the script shouldn't process. In that example, the rest of the script should process only if hotkey 1 is pressed.

Maybe someone can steer me in the right direction on that. I've blindly tried a couiple of things, but so far I can't get it to do what I want.
User avatar
Shelby Huffman
 
Posts: 3454
Joined: Wed Aug 08, 2007 11:06 am

Post » Wed Sep 07, 2011 1:37 pm

Let me elaborate. The above isn't accurate. I can do what I posted above, but, to be more precise, what I want is for the script to not process only when pressing the hotkey not assigned to the torch hotkey item. Only that one time, in all other cases, the script should process every frame. And the script should process when you press the hotkey assigned to the torch hotkey item. I hope that makes sense.
User avatar
Neliel Kudoh
 
Posts: 3348
Joined: Thu Oct 26, 2006 2:39 am

Post » Wed Sep 07, 2011 11:38 am

Okay. I figured it out. Just had to stop, clear my mind, and attack what I was trying to do. I have to refine the script a little and then I'll post it and maybe someone can tell me a more efficient way to write the script.

Sorry for spamming the forum.

I can tell by the fact that TNO has visited these forums and did not respond that I have done something wrong. I know he knows the most efficient way to do what I was trying to do...
User avatar
Lucky Girl
 
Posts: 3486
Joined: Wed Jun 06, 2007 4:14 pm

Post » Wed Sep 07, 2011 10:25 pm

I can tell by the fact that TNO has visited these forums and did not respond that I have done something wrong. I know he knows the most efficient way to do what I was trying to do...
Spying on me? :P

To be on topic, I must admit that I think your explanation made it harder to understand what you want ;) ...but I think you should do something entirely different...

First, a player hotkeys a torch, it will be equipped without the need for additional code, so I don't understand the need for additional code. Secondly, it will not work at all with my Enhanced Hotkeys mod (which is the most-used hotkey mod by far), since GetHotKeyItem will not return anything meaningful then.

Maybe there's something to it that I don't understand, but if a player wants the torch hotkeyed, why not just assume that he hotkeys it, without adding any special code? The hotkey torch item added by OOO's DLT has always been a nuicance to me.
User avatar
Gavin boyce
 
Posts: 3436
Joined: Sat Jul 28, 2007 11:19 pm

Post » Wed Sep 07, 2011 1:10 pm

Spying on me? :P

lol, no. Just checked my thread and saw you had responded to someone.

To be on topic, I must admit that I think your explanation made it harder to understand what you want ;) ...but I think you should do something entirely different...

First, a player hotkeys a torch, it will be equipped without the need for additional code, so I don't understand the need for additional code. Secondly, it will not work at all with my Enhanced Hotkeys mod (which is the most-used hotkey mod by far), since GetHotKeyItem will not return anything meaningful then.

Maybe there's something to it that I don't understand, but if a player wants the torch hotkeyed, why not just assume that he hotkeys it, without adding any special code? The hotkey torch item added by OOO's DLT has always been a nuicance to me.

Well, it's because I have a torch hotkey item. An spiffy icon with the intention of hotkeying torches and nothing else. I was trying to remove the spam and have attached a script to the item designed to give the player the drop lit torches effect, among other things.
Here's the working script. Maybe you can look at it and spot a more efficient way :D

Begin GameMode		Set HKOne to GetHotKeyItem 1	Set HKTwo to GetHotKeyItem 2	Set HKThree to GetHotKeyItem 3	Set HKFour to GetHotKeyItem 4	Set HKFive to GetHotKeyItem 5	Set HKSix to GetHotKeyItem 6	Set HKSeven to GetHotKeyItem 7	Set HKEight to GetHotKeyItem 8	Set sAttackKey to GetControl 4	If HKOne != aaaMalonnHotKeyTorch && HKTwo != aaaMalonnHotKeyTorch && HKThree != aaaMalonnHotKeyTorch && HKFour != aaaMalonnHotKeyTorch && HKFive != aaaMalonnHotKeyTorch && HKSix != aaaMalonnHotKeyTorch && HKSeven != aaaMalonnHotKeyTorch && HKEight != aaaMalonnHotKeyTorch		Return	Elseif (HKOne == aaaMalonnHotKeyTorch && IsControlPressed 18) || (HKTwo == aaaMalonnHotKeyTorch && IsControlPressed 19) || (HKThree == aaaMalonnHotKeyTorch && IsControlPressed 20) || (HKFour == aaaMalonnHotKeyTorch && IsControlPressed 21) || (HKFive == aaaMalonnHotKeyTorch && IsControlPressed 22) || (HKSix == aaaMalonnHotKeyTorch && IsControlPressed 23) || (HKSeven == aaaMalonnHotKeyTorch && IsControlPressed 24) || (HKEight == aaaMalonnHotKeyTorch && IsControlPressed 25)		If Player.GetItemCount Torch02 > 0			If Player.IsTorchOut == 0				Player.UnequipItemNS aaaMalonnHotKeyTorch				Player.EquipItemNS Torch02 1			Elseif Player.IsTorchOut				Player.UnequipItemNS Torch02 1			Endif		Endif	Elseif (HKOne != aaaMalonnHotKeyTorch && IsControlPressed 18) || (HKTwo != aaaMalonnHotKeyTorch && IsControlPressed 19) || (HKThree != aaaMalonnHotKeyTorch && IsControlPressed 20) || (HKFour != aaaMalonnHotKeyTorch && IsControlPressed 21) || (HKFive != aaaMalonnHotKeyTorch && IsControlPressed 22) || (HKSix != aaaMalonnHotKeyTorch && IsControlPressed 23) || (HKSeven != aaaMalonnHotKeyTorch && IsControlPressed 24) || (HKEight != aaaMalonnHotKeyTorch && IsControlPressed 25)		Return	Endif...


I still get the damned "You cannot equip this item" spam.
User avatar
Benji
 
Posts: 3447
Joined: Tue May 15, 2007 11:58 pm

Post » Wed Sep 07, 2011 10:00 am

Okay, new problem. Here's the full script:

ScriptName MalonnHotkeyTorchRef rShieldRef HKOneRef HKTwoRef HKThreeRef HKFourRef HKFiveRef HKSixRef HKSevenRef HKEightShort sAttackKeyShort sActivatedBegin GameMode		Set rShield to Player.GetEquippedObject 13	Set HKOne to GetHotKeyItem 1	Set HKTwo to GetHotKeyItem 2	Set HKThree to GetHotKeyItem 3	Set HKFour to GetHotKeyItem 4	Set HKFive to GetHotKeyItem 5	Set HKSix to GetHotKeyItem 6	Set HKSeven to GetHotKeyItem 7	Set HKEight to GetHotKeyItem 8	Set sAttackKey to GetControl 4	If HKOne != aaaMalonnHotKeyTorch && HKTwo != aaaMalonnHotKeyTorch && HKThree != aaaMalonnHotKeyTorch && HKFour != aaaMalonnHotKeyTorch && HKFive != aaaMalonnHotKeyTorch && HKSix != aaaMalonnHotKeyTorch && HKSeven != aaaMalonnHotKeyTorch && HKEight != aaaMalonnHotKeyTorch		Return	Endif	If (HKOne != aaaMalonnHotKeyTorch && IsControlPressed 18) || (HKTwo != aaaMalonnHotKeyTorch && IsControlPressed 19) || (HKThree != aaaMalonnHotKeyTorch && IsControlPressed 20) || (HKFour != aaaMalonnHotKeyTorch && IsControlPressed 21) || (HKFive != aaaMalonnHotKeyTorch && IsControlPressed 22) || (HKSix != aaaMalonnHotKeyTorch && IsControlPressed 23) || (HKSeven != aaaMalonnHotKeyTorch && IsControlPressed 24) || (HKEight != aaaMalonnHotKeyTorch && IsControlPressed 25)		Return	Elseif (IsControlPressed 18 && sActivated == 0) || (IsControlPressed 19 && sActivated == 0) || (IsControlPressed 20 && sActivated == 0) || (IsControlPressed 21 && sActivated == 0) || (IsControlPressed 22 && sActivated == 0) || (IsControlPressed 23 && sActivated == 0) || (IsControlPressed 24 && sActivated == 0) || (IsControlPressed 25 && sActivated == 0)		Set sActivated to 1		If Player.IsTorchOut			If Player.IsInCombat				Set aaaMalonnDropLitTorches.Dropped to 1				Player.UnequipItemNS Torch02				Player.AddItemNS aaaTorchLight 1				Player.UnequipItemNS aaaMalonnHotKeyTorch				Player.Drop Torch02 1				TapKey sAttackKey 			Else				Player.UnequipItemNS Torch02			Endif		Elseif Player.GetItemCount Torch02 > 0			If Player.IsShieldOut && Player.IsWeaponOut				Set aaaMalonnDropLitTorches.Dropped to 1				Player.UnequipItemNS Torch02				Player.AddItemNS aaaTorchLight 1				Player.UnequipItemNS aaaMalonnHotKeyTorch				Player.Drop Torch02 1			Elseif Player.IsWeaponOut				If Player.GetWeaponAnimType == 2 || Player.GetWeaponAnimType == 3					Set aaaMalonnDropLitTorches.Dropped to 1					Player.UnequipItemNS Torch02					Player.AddItemNS aaaTorchLight 1					Player.UnequipItemNS aaaMalonnHotKeyTorch					Player.Drop Torch02 1				Else					Player.EquipItemNS Torch02				Endif			Else				Player.EquipItemNS Torch02			Endif		Endif	Elseif (IsControlPressed 18 && sActivated == 1) || (IsControlPressed 19 && sActivated == 1) || (IsControlPressed 20 && sActivated == 1) || (IsControlPressed 21 && sActivated == 1) || (IsControlPressed 22 && sActivated == 1) || (IsControlPressed 23 && sActivated == 1) || (IsControlPressed 24 && sActivated == 1) || (IsControlPressed 25 && sActivated == 1)		Return	Elseif (IsControlPressed 18 != 1 && sActivated == 1) || (IsControlPressed 19 != 1 && sActivated == 1) || (IsControlPressed 20 != 1 && sActivated == 1) || (IsControlPressed 21 != 1 && sActivated == 1) || (IsControlPressed 22 != 1 && sActivated == 1) || (IsControlPressed 23 != 1 && sActivated == 1) || (IsControlPressed 24 != 1 && sActivated == 1) || (IsControlPressed 25 != 1 && sActivated == 1)		Set sActivated to 0	Endif		If Player.GetItemCount Torch02 > 0		If Player.IsTorchOut 			If IsControlPressed 8 || IsControlPressed 4				If (Player.GetWeaponAnimType == 1 && Player.GetEquipped rShield == 0)					Return				Else					Set aaaMalonnDropLitTorches.Dropped to 1					Player.UnequipItemNS Torch02					Player.AddItemNS aaaTorchLight 1					Player.UnequipItemNS aaaMalonnHotKeyTorch					Player.Drop Torch02 1				Endif			Endif		Endif	Endif	DebugBreakEnd


Problem is unequipping a shield breaks the script. Everything works as I want it to if I don't unequip a shield, or if I switch shields without unequipping first.

Any ideas as to why?

EDIT:

It has to do with this script section:
Player.GetEquipped rShield == 0

If I remove that, it works almost as intended. The only problem is when I have a shield and sword equipped, the torch does not drop. But that line should not cause the script to not function correctly if you unequip the shield.

EDIT2:
I can use IsShieldOut, but the problem with that is, if you have a torch already equipped, it returns 0.
User avatar
Sheila Esmailka
 
Posts: 3404
Joined: Wed Aug 22, 2007 2:31 am


Return to IV - Oblivion