Jump to content

Enabling/Disabling many items at once


saintgrimm92

Recommended Posts

I'm needing to enable/disable over 50 items at the same time and am worried that doing so in a quest will cause problems as that many aliases + all of them being enabled/disabled in a single quest stage, in my opinion, would probably be too much load on the quest.

 

I'll go into a little bit more detail so that it's understood more...

 

All of the NPCs in a specific town have been turned to stone. I've created static statues to resemble each NPC in the town.

 

After the spell is broken, I need the statues gone and the NPCs in the town.

 

The quest already has a good number of aliases as it's a pretty long quest with a lot to do. So adding another 50 some aliases seems like it might just be too much for it to handle.

 

Is there any other way, possibly easier than typing a papyrus fragment 50+ times to enable/disable all of these items? I'm hoping someone can help me with a script that will fire when the quest hits a certain stage and work by enabling/disabling all the properties in a script instead of adding all this papyrus and the aliases to the quest itself.

Link to comment
Share on other sites

Easily done with an array.


ReferenceAlias[] QuestAliases


Function AddRefToArray() ; First we will add the alaises to an array.
QuestAliases = new ReferenceAlias[100] ; change that to how many aliases you have.
Int iRefIndex = self.GetNumAliases() ; Collecting all the aliases this quest has.
Int iReference = 0
Int i
While (i < iRefIndex)
    ReferenceAlias Ref = self.GetNthAlias(iRefIndex) as ReferenceAlias
    if !Ref
        QuestAliases[iReference] = Ref
        iReference += 1
    endif
EndWhile

EndFunction       

Function EnableReference(bool abDisable = false) ; false by default. Change this to whatever depending on your needs.

Int iReference = QuestAliases.Length

if (abDisable == false) 
    While (iReference)
        iReference -= 1
        QuestAliases[iReference].GetReference().Enable()
    EndWhile
elseif (abDisable == true)
    While (iReference)
        iReference -= 1
        QuestAliases[iReference].GetReference().Disable()
    EndWhile
Endif

EndFunction
 

Place these in your quest script.

 

Function 1: So that you don't have to spend time manually adding the aliases to an array property in the CK. Also if you make changes to the property at run time, it will do unexpected things because the previous elements are baked in the save. Put this in a stage in your quest, and call that stage.

 

Then test out function 2 in another stage.

 

This is mainly experimental because GetNumAliases() is first time use for me.

Edited by Elathia
Link to comment
Share on other sites

I've never used an array before, not even sure what it is lol

 

I'll have to research it a bit to fully understand how to use the script.

 

I do not wish to disable/enable ALL of the quest aliases as there are many that are meant to be present. Should I instead make a separate quest and add only the aliases I wish to enable/disable to it, the stage of the main quest setting the stage of the quest this script is attached to?

 

If yes, would I need 1 quest for the aliases I need disabled and a 2nd quest for the ones I need enabled?

Link to comment
Share on other sites

Arrays: http://www.creationkit.com/Arrays_%28Papyrus%29

 


 

If yes, would I need 1 quest for the aliases I need disabled and a 2nd quest for the ones I need enabled?

 

No. They were meant to be used for the quest that contain your aliases.

 

Since you don't want all of them enabled/disabled, it wont help you anyway. I haven't learned how to do different things to different elements while not messing with other elements. (Like changing element 5 while ignoring element 1)

Link to comment
Share on other sites

awh you were late on this one bizkit :P

 

I already created another quest, deleted all the statue aliases from my main quest, added ALL of them and ALL of the NPCs to another quest and added the array to the quest.

 

I THINK the script will work, all my research points to yes, but I'm not at a testing stage for the update yet. (this is a new quest that'll be added to Dark Haven with the first Alpha Version)

 

I can't figure out how to make the script fire. The "statue holder" quest only has 1 stage, stage 10. The stage of the main quest that is supposed to "free" all of the "stoned people" (haha) sets the statue holder to stage 10.

 

I've created a new script with the array and added it to the quest under the scripts tab. And I'm not sure if I need papyrus in stage 10 to tell the script to fire, or if it automatically fires when the quest is started?

Link to comment
Share on other sites

Use an enable parent marker. It's more efficient by a lot. Arrays are great but not necessary at all here.

 

Drop an XMarker in, and select every single object that should be enabled/disabled (Ctrl + Left click to every one). Press - while in the render window. Choose Set Enable Parent (keep it true). Select Reference in Render Window and select your XMarker.

 

Now, the items are now linked to that XMarker. When the XMarker is enabled to begin with, they'll be enabled (to start disabled set the XMarker initially disabled). So, you only need ONE line of code to enable/disable JUST your XMarker wih a typical ObjectReference property.

 

https://m.youtube.com/watch?v=FZE08mO0l-A

 

Do NOT NOT NOT use arrays or aliases here. SO inefficient.

Link to comment
Share on other sites

Hmm yeah, enable parent is much better for you considering your inexperience with papyrus. One single enable parent can control all of them, or you can use multiples, to enable/disable certain ones. If my array method is far too advanced(and I still don't know if it'll work) go with enable parents.

 

Unlike what the guy above said, using arrays or even tons of elseifs aren't "less efficient" since this is just... enabling/disabling objects. All this is, is another way to do what you want.

Edited by Elathia
Link to comment
Share on other sites

  • Recently Browsing   0 members

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