Jump to content

[LE] Script to Replace an Inventory Item With Another?


McTAL

Recommended Posts

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

What kind of script are you using currently?

ReferenceAlias with Quest or ObjectReference directly attached to the baseobject

 

next is like IsharaMeradin scripts:

  Reveal hidden contents

Edited by ReDragon2013
Link to comment
Share on other sites

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 by huggibee
Link to comment
Share on other sites

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?

 

 

  Reveal hidden contents

 

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...