Jump to content

Attaching Enable/Disable Script to object


bientje

Recommended Posts

Hi,

 

I'm looking for an easy way to have an object (Or XMarker with links to multiple objects) be disabled/enabled upon a certain condition, for example Quest Stages Done.

 

Would this work:

Quest property TESTQUEST01 auto 

Int property QuestStageProperty auto

Event OnCellAttach() 
     If TESTQUEST01.IsStageDone(PROPERTY) 
     ObjectReference.Enable() 
     endif

EndEvent

Any other suggestions to get the desired result would be very welcome!

Link to comment
Share on other sites

It should work if you change it to this:

 

Quest property TESTQUEST01 auto 

Int property QuestStageProperty auto

Event OnCellAttach() 
     If TESTQUEST01.IsStageDone(QuestStageProperty) 
         Self.Enable() 
     endif
EndEvent

Self points to whatever the script is attached to.

Link to comment
Share on other sites

Thank you for the speedy reply!

 

If I multiple objects I want enabled at a certain quest stage.

- I create an xMarker and gives this xMarker the script you corrected for me.

 

Then if I want all of these objects to dissappear again after a certain quest stage, could I just expand the script?

Quest property TESTQUEST01 auto 
Quest property TESTQUEST02 auto 

Int property QuestStageProperty auto

Event OnCellAttach() 
     If TESTQUEST01.IsStageDone(QuestStageProperty) 
         Self.Enable() 
     endif
Event OnCellAttach() 
     If TESTQUEST02.IsStageDone(QuestStageProperty) 
         Self.Disable() 
     endif
EndEvent

And what would I do if I only wanted a select few objects disabled instead of all of them?

 

Thank you!

 

Link to comment
Share on other sites

For that, you would use Elseif and not the event twice as that won't compile. :

 

Quest property TESTQUEST01 auto 
Quest property TESTQUEST02 auto 


Int property QuestStageProperty auto


Event OnCellAttach() 
     If TESTQUEST01.IsStageDone(QuestStageProperty) 
         Self.Enable() 
     ElseIf TESTQUEST02.IsStageDone(QuestStageProperty) 
         Self.Disable() 
     endif
EndEvent

To only disable certain objects, I would make another xmarker ref and link it to the objects you want to disable / enable and use a separate script on it. Or you could put your objects in formlists with a while loop to enable / disable them directly:

 

 

 

Quest property TESTQUEST01 auto 
Quest property TESTQUEST02 auto 


Int property QuestStageProperty auto

Formlist Property MyObjectRefsA auto 
Formlist Property MyObjectRefsB auto 
;drag and drop ObjectReferences from a cell into these lists in the Creation Kit.

Event OnCellAttach() 
     If TESTQUEST01.IsStageDone(QuestStageProperty) 
         ;enable all ObjectReferences in MyObjectRefsA
         Int M = MyObjectRefsA.GetSize() ;get number of items in list 
         While M > 0 
             M -= 1 
             ObjectReference CurrentRef = MyObjectRefsA.GetAt(M) as ObjectReference 
             CurrentRef.Enable() 
         EndWhile 
         
     ElseIf TESTQUEST02.IsStageDone(QuestStageProperty) 
         ;Disable all ObjectReferences in MyObjectRefsB
         Int M = MyObjectRefsB.GetSize() ;get number of items in list 
         While M > 0 
             M -= 1 
             ObjectReference CurrentRef = MyObjectRefsB.GetAt(M) as ObjectReference 
             CurrentRef.Disable() 
         EndWhile 
     endif
EndEvent

 

 

Link to comment
Share on other sites

You might want to use a formlist to make it more dynamic which objects you're enabling / disabling. You can add and remove objects to a formlist with script. The only objects you can remove from a formlist though are those that are added by a script, not those added in the CK. Another option if you're using links if you don't want to use separate scripts is to use your link markers in one script, like so:

 

Quest property TESTQUEST01 auto 
Quest property TESTQUEST02 auto 

Int property QuestStageProperty auto

ObjectReference Property ObjectLinkA auto 
ObjectReference Property ObjectLinkB auto 
;drag and drop ObjectReferences from a cell into these lists in the Creation Kit.

Event OnCellAttach() 
     If TESTQUEST01.IsStageDone(QuestStageProperty) 
         ObjectLinkA.Enable()
         
     ElseIf TESTQUEST02.IsStageDone(QuestStageProperty) 
         ObjectLinkB.Disable()
     endif
EndEvent
Link to comment
Share on other sites

Thank you. I need some time to process the last two options (with the formlist) that you gave me.

 

In the meantime, I reached my original goal. I attached a script to a Xmarker and it worked. This was the actual script I ended up using:

Scriptname MOD_FireOffScript extends ObjectReference  
{Quest property MQ104 auto 

Int property 160 auto

Event OnCellAttach() 
     If MQ104.IsStageDone(160) 
         Self.Disable() 
     endif
EndEvent}

This script disables the fires at Western Watchtower that are there permanently after the Dragon Rising quest (the first dragon fight). Bethesda already used a xMarker for enabling the fire effects, so it was quite easy to disable them :)

 

BTW, I love your mods, dylbill.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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