McTAL Posted February 4, 2019 Author Share Posted February 4, 2019 Uff -- I hate to bring this back, but I've been having some major issues with the script up to the point where it no longer works and I can't remember how I got it to work before. At some point the script repetitively added the CLs and DLs over and over regardless of conditions I set, or simply just stopped working. Is there another way around this, or perhaps another script that might work? Link to comment Share on other sites More sharing options...
ReDragon2013 Posted February 4, 2019 Share Posted February 4, 2019 (edited) What kind of script are you using currently?ReferenceAlias with Quest or ObjectReference directly attached to the baseobject next is like IsharaMeradin scripts: ScriptName LinenSwapScriptPlayerAlias extends ReferenceAlias {this runs for the player, not for the linen} MiscObject Property CL auto ; clean linens MiscObject Property DL auto ; dirty linens ; Note: "Place a copy of starting linen item in the player alias inventory section thus when quest is started, ; the player automatically gets the first item and thus we register for the update here." (IsharaMeradin) Bool isDirty = False ; -- EVENTs -- EVENT OnInit() Debug.Trace(" OnInit() - has been reached.. " +self) ; debugging only self.AddInventoryEventFilter(CL) ; add filter for clean item self.AddInventoryEventFilter(DL) ; add filter for dirty item RegisterForSingleUpdateGameTime(8.0) ; register for an update in 8 game hours ENDEVENT EVENT OnUpdateGameTime() ; timer is up after ingame 8 hours quest q = self.GetOwningQuest() Debug.Trace(" OnUpdateGameTime(" +isDirty+ ") - has been reached.. " +self) ; debugging only IF (q) && q.IsRunning() ELSE RETURN ; uninstalled or myQuest is not running ENDIF miscObject MO IF ( !isDirty ) ; are current linens clean MO = DL ; add the dirty linen ELSE ; are current linens dirty MO = CL ; add the clean linen ENDIF ;;; Game.GetPlayer().AddItem(MO) self.GetReference().AddItem(MO) RegisterForSingleUpdateGameTime(8.0) ; register for an update in 8 game hours ENDEVENT EVENT OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) IF (akBaseItem as MiscObject) ELSE RETURN ; failsafe, normally impossible caused by AddInventoryEventFilter(), not a miscobject was added to players inventory ENDIF ;----- IF (akBaseItem as MiscObject == CL) && (isDirty) ; is the added item clean linens isDirty = False ; indicate that the current item is clean ELSEIF (akBaseItem as MiscObject == DL) && (!isDirty) ; is the added item dirty linens isDirty = TRUE ; indicate that current linen are dirty ELSE RETURN ; not the desired miscObject ENDIF ;----- self.GetReference().RemoveItem(akBaseItem) ; remove the dirty or clean item, if necessary RegisterForSingleUpdateGameTime(8) ; register for an update in 8 game hours ENDEVENT Edited February 4, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
McTAL Posted February 5, 2019 Author Share Posted February 5, 2019 (edited) I was using reference alias -- and I placed a copy of the starting linens in the player inventory, but never received them upon game start. So maybe it's an issue of not getting the quest to run even though it's set to run on game start? Edit: Attempted the script given, but nothing seems to happen. I think it must be an issue with getting the quest to run in the first place. :/ Edit02: So I found the issue with getting the script to run -- one of my ref alias refused to fill and thus delayed the quest. Thank you for your help! Edited February 5, 2019 by huggibee Link to comment Share on other sites More sharing options...
McTAL Posted February 5, 2019 Author Share Posted February 5, 2019 After tinkering further, I'm able to get the script to fire, and after the first 8hrs, the clean linens are removed and the dirty linens are added -- great! . . . except, after the addition of new clean linens added via a custom crafting station, the script no longer fires. How can I fix this? Scriptname Laundryswap extends ReferenceAliasMiscObject Property CL Auto ; clean linensMiscObject Property DL Auto ; dirty linensBool isDirty = falseActor PlayerRefEvent OnInit()AddInventoryEventFilter(CL) ; add filter for clean itemAddInventoryEventFilter(DL) ; add filter for dirty itemPlayerRef = Self.GetReference() as Actor ; cast the object reference that this alias points to as an actor and store it.; if this give compile issues, just change to Game.GetPlayer()RegisterForSingleUpdateGameTime(8) ; register for an update in 8 game hours; place a copy of starting linen item in the player alias inventory section; thus when quest is started, the player automatically gets the first item and thus we register for the update hereEndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)If akBaseItem as MiscObject == DL ; is the added item dirty linensPlayerRef.RemoveItem(CL) ; remove the clean itemisDirty = true ; indicate that current linen are dirtyRegisterForSingleUpdateGameTime(8) ; register for an update in 8 game hoursEndIfEndEventEvent OnUpdateGameTime() ; timer is upIf isDirty == false ; are current linens cleanPlayerRef.AddItem(DL) ; add the dirty linenEndIfRegisterForSingleUpdateGameTime(8) ; register for an update in 8 game hoursEndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 5, 2019 Share Posted February 5, 2019 This block in your latest script code in the post above is part of the issue Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as MiscObject == DL ; is the added item dirty linens PlayerRef.RemoveItem(CL) ; remove the clean item isDirty = true ; indicate that current linen are dirty RegisterForSingleUpdateGameTime(8) ; register for an update in 8 game hours EndIf EndEvent Unlike the example that I posted on a previous page this one does not contain the necessary code to handle when clean linens are added to the player. See below: Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as MiscObject == CL ; is the added item clean linens PlayerRef.RemoveItem(DL) ; remove the dirty item isDirty = false ; indicate that the current item is clean RegisterForSingleUpdateGameTime(8) ; register for an update in 8 game hours ElseIf akBaseItem as MiscObject == DL ; is the added item dirty linens PlayerRef.RemoveItem(CL) ; remove the clean item isDirty = true ; indicate that current linen are dirty RegisterForSingleUpdateGameTime(8) ; register for an update in 8 game hours EndIf EndEvent If you only want the update event to run when the clean needs to become dirty, just remove the second RegisterForSingleUpdateGameTime line in the example above. After all, there would be no need to run the update event to swap from dirty to clean should the intent be to have the player craft / buy clean linens. Link to comment Share on other sites More sharing options...
McTAL Posted February 5, 2019 Author Share Posted February 5, 2019 Thank you very much! Link to comment Share on other sites More sharing options...
Recommended Posts