wilwhitt56 Posted March 23 Author Share Posted March 23 21 minutes ago, IsharaMeradin said: Add some debug statements to see how far things are going in the script. ...How do i do that? ( i'm sorry, I haven't touched scripts in a while and i'm still trying to learn.) Link to comment Share on other sites More sharing options...
xkkmEl Posted March 23 Share Posted March 23 (edited) [Redacted. I had missed that you are starting new games for every test.] Edited March 23 by xkkmEl Link to comment Share on other sites More sharing options...
xkkmEl Posted March 23 Share Posted March 23 What is the purpose of the "GoldVault" variable? Here are two suggestions for debug statements: Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem == gold001 Debug.notification( "Added count = " + count + " items = " + aiItemCount) count += aiItemCount DisplayPiles(count) EndIf Endevent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If akBaseItem == gold001 Debug.messageBox( "Removed count = " + count + " items = " + aiItemCount) count -= aiItemCount DisplayPiles(count) EndIf Endevent You could also use Debug.trace, if you know where to find the papyrus logs... Link to comment Share on other sites More sharing options...
wilwhitt56 Posted March 23 Author Share Posted March 23 (edited) 22 minutes ago, xkkmEl said: What is the purpose of the "GoldVault" variable? Here are two suggestions for debug statements: Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem == gold001 Debug.notification( "Added count = " + count + " items = " + aiItemCount) count += aiItemCount DisplayPiles(count) EndIf Endevent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If akBaseItem == gold001 Debug.messageBox( "Removed count = " + count + " items = " + aiItemCount) count -= aiItemCount DisplayPiles(count) EndIf Endevent You could also use Debug.trace, if you know where to find the papyrus logs... just saw something that was off when i used the debug. I got a message saying: Added gold *amount added*=0=*amount added* Edited March 23 by wilwhitt56 Link to comment Share on other sites More sharing options...
wilwhitt56 Posted March 23 Author Share Posted March 23 1 hour ago, IsharaMeradin said: Add some debug statements to see how far things are going in the script. I figured out whats wrong with your script. It's working, but in the wrong way. Rather than add to the pile, it's going through each object reference like a step, rather then an addition to the pile. I add 10000 gold, it only shows Vaultloot3. jump to 100k, it only shows Vaultloot6. Link to comment Share on other sites More sharing options...
xkkmEl Posted March 23 Share Posted March 23 1 hour ago, wilwhitt56 said: just saw something that was off when i used the debug. I got a message saying: Added gold *amount added*=0=*amount added* 1st rule of debug trace messages: Make sure the bug is not in the trace itself! Link to comment Share on other sites More sharing options...
wilwhitt56 Posted March 23 Author Share Posted March 23 (edited) 1 hour ago, xkkmEl said: 1st rule of debug trace messages: Make sure the bug is not in the trace itself! noted, but also I figured it out. Read the message i sent to Ishara. I just need to figure out how to fix it. Edited March 23 by wilwhitt56 Link to comment Share on other sites More sharing options...
wilwhitt56 Posted March 24 Author Share Posted March 24 (edited) @IsharaMeradinAre you there? Spoiler Function DisplayPiles(Int value) Int index = MaxValue.Length Int myActive = -1 While index >= 0 ; scan from end to beginning (i.e. largest to smallest) index -= 1 If (value > MaxValue[index]) && (myActive == -1) ; enable only the first highest value pile <-----------------I think this is the problem. myActive = index VaultLoot[index].enable() Else Edited March 24 by wilwhitt56 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 24 Share Posted March 24 I was at work tonight. So no, I was not 'here'. So... this boils down to not knowing the full intention. In most scenarios, one would want to disable anything not associated with the current thing. That is how this is set up. It sounds as if you are relying on all the previous "piles" still being present. If that is the case, remove every instance of the myActive variable that I had added. The script would then enable any "pile" that is lesser than the value and disable any "pile" that is greater. Link to comment Share on other sites More sharing options...
wilwhitt56 Posted March 24 Author Share Posted March 24 15 hours ago, IsharaMeradin said: I was at work tonight. So no, I was not 'here'. So... this boils down to not knowing the full intention. In most scenarios, one would want to disable anything not associated with the current thing. That is how this is set up. It sounds as if you are relying on all the previous "piles" still being present. If that is the case, remove every instance of the myActive variable that I had added. The script would then enable any "pile" that is lesser than the value and disable any "pile" that is greater. Yup, that did it. Thanks for all the help Ishara. The full Script, in case someone wants to use it: Spoiler ObjectReference property Vaultloot01 auto ObjectReference property Vaultloot02 auto ObjectReference property Vaultloot03 auto ObjectReference property Vaultloot04 auto ObjectReference property Vaultloot05 auto ObjectReference property Vaultloot06 auto ObjectReference property VaultLoot07 auto ObjectReference property VaultLoot08 auto ObjectReference property VaultLoot09 auto ObjectReference property Vaultloot10 auto ObjectReference property Vaultloot11 auto ObjectReference property Vaultloot12 auto ObjectReference property Vaultloot13 auto ObjectReference property Vaultloot14 auto ObjectReference property Vaultloot15 auto ObjectReference property Vaultloot16 auto ObjectReference property GoldVault auto MiscObject Property gold001 Auto ObjectReference[] VaultLoot Int[] MaxValue int count = 0 Event OnInit() VaultLoot = new ObjectReference[16] VaultLoot[0] = Vaultloot01 VaultLoot[1] = Vaultloot02 VaultLoot[2] = Vaultloot03 VaultLoot[3] = Vaultloot04 VaultLoot[4] = Vaultloot05 VaultLoot[5] = Vaultloot06 VaultLoot[6] = Vaultloot07 VaultLoot[7] = Vaultloot08 VaultLoot[8] = Vaultloot09 VaultLoot[9] = Vaultloot10 VaultLoot[10] = Vaultloot11 VaultLoot[11] = Vaultloot12 VaultLoot[12] = Vaultloot13 VaultLoot[13] = Vaultloot14 VaultLoot[14] = Vaultloot15 VaultLoot[15] = Vaultloot16 MaxValue = new Int[16] MaxValue[0] = 999 MaxValue[1] = 4999 MaxValue[2] = 9999 MaxValue[3] = 24999 MaxValue[4] = 49999 MaxValue[5] = 99999 MaxValue[6] = 199999 MaxValue[7] = 299999 MaxValue[8] = 399999 MaxValue[9] = 499999 MaxValue[10] = 649999 MaxValue[11] = 749999 MaxValue[12] = 999999 MaxValue[13] = 1249999 MaxValue[14] = 1499999 MaxValue[15] = 1999999 EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem == gold001 count += aiItemCount DisplayPiles(count) EndIf Endevent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If akBaseItem == gold001 count -= aiItemCount DisplayPiles(count) EndIf Endevent Function DisplayPiles(Int value) Int index = MaxValue.Length While index >= 0 ; scan from end to beginning (i.e. largest to smallest) index -= 1 If (value > MaxValue[index]) VaultLoot[index].enable() Else ; disable all other entries if previously enabled If VaultLoot[index].isEnabled() VaultLoot[index].disable() EndIf EndIf EndWhile EndFunction Link to comment Share on other sites More sharing options...
Recommended Posts