Jump to content

Enabling items via Formlist?


Recommended Posts

How would I go about enabling items with a formlist index? Do I need one FL with all the REFR from Cell View and another FL with the MiscObjects? What else would I need? I know how to enable and disable; single, linked ref and multiple objects, but not with a FormList. Lets says there is 30 refs I want to enable, how would I code it so the script checks a containers item count of each reference in a FormList and enables the corresponding index? Doing a formlist seems a lot easier then having 30+ reference properties...Thanks in advance!

Link to comment
Share on other sites

So you just want to enable everything in a formlist? Use a while loop.

 

Here is an example function:

Scriptname Myscript extends whatever

Function EnableAll(Formlist akFormlist)
    int x = 0
    While (x < akFormlist.GetSize())
        akFormlist.GetAt(x).Enable()
        x+=1
    EndWhile
EndFunction
Link to comment
Share on other sites

Are the items placed in the world by hand or generated by PlaceAtMe script ?

 

If placed in the world it may be easier to link them all to a single enable parent and trigger just that object in using a default script or quest stage.

 

Just FYI you cant enable/disable items in containers. If they are in a container they are available, you need to either disable the container or not put the item in the container until ready.

Link to comment
Share on other sites

30 items, each one different ID. I can't link all of them to 1 enable parent. I want 1 item to enable as long as the misc object of that item is in the container.

 

EX: (REALLY BROKEN...I KNOW)

If(Container.GetItemCount(Item1) >=1)
GetAtIndex[ 1 ]
Item1.Enable()  with corresponding index in FL2
Else
Item1.Disable()
EndIf
If(Container.GetItemCount(Item2) >=1)
GetAtIndex[ 2 ]
Item2.Enable() with corresponding index in FL2
Else
Item2.Disable()
EndIf
If(Container.GetItemCount(Item3) >=1)
GetAtIndex[ 3 ]
Item3.Enable() with corresponding index in FL2
Else
Item3.Disable()
EndIf
Edited by ZombicideII
Link to comment
Share on other sites

I dont understand what you want to do. I think you may be misunderstanding some stuff. So let me ask some questions first:

What is a final goal, enabling items in the world? If so why do you wan to use formlist or container at all? I dont understand whats the point of those indexes you want to have. Also, if you want to enable items in container then you wont be able to do that. Items in container dont have 3d and dont have object references if they arent persistent. So if you tell exactly what items you want to enable and just explain in more detail, there may be better solution and no formlist or container indexes will be required

Edited by shavkacagarikia
Link to comment
Share on other sites

This is what I'm looking for, but as is for some reason it doesn't enable at the index like it should. Unless I set up either the code wrong or the FL

Scriptname HoloDisplayScript extends ObjectReference

ObjectReference Property HoloDisplayRef1 Auto
ObjectReference Property HoloDisplayRef2 Auto
ObjectReference Property HoloDisplayRef3 Auto
ObjectReference Property HoloDisplayRef4 Auto
ObjectReference Property HoloDisplayRef5 Auto
ObjectReference Property HoloDisplayRef6 Auto


FormList Property HoloItemForm1 Auto
FormList Property HoloFormEnable Auto


Int Property IntRestrict1 Auto

Event OnItemAdded(Form akBaseItem, Int aiCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

Int iIndex = HoloItemForm1.GetSize()
While iIndex
iIndex=1
Form ItemReference = HoloItemForm1.GetAt(iIndex)
ObjectReference EnableReference = HoloFormEnable.GetAt(iIndex) as ObjectReference
If akBaseItem == ItemReference
EnableReference.Enable()
EndIf
EndWhile

If HoloItemForm1.HasForm(akBaseItem) && IntRestrict1 == 1
;Do Nothing
ElseIf IntRestrict1 == 1
RemoveItem(akBaseItem, aiCount, True, akSourceContainer)
debug.notification("Invalid Item")
Elseif IntRestrict1 == 0
;Do Nothing
EndIf
EndEvent

Event OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)

Int iIndex = HoloItemForm1.GetSize()
While iIndex
iIndex=1
Form ItemReference = HoloItemForm1.GetAt(iIndex)
ObjectReference EnableReference = HoloFormEnable.GetAt(iIndex) as ObjectReference
If akBaseItem == ItemReference
EnableReference.Disable()
EndIf
EndWhile
EndEvent
Edited by ZombicideII
Link to comment
Share on other sites

Well, that's fixed and it still doesn't work like it should. When I use this in game, the container still accepts any item that is not in the HoloItemForm. Also the ItemREF doesn't enable. I edited my properties correctly...I know it. So I'm unsure of why it's not working

Link to comment
Share on other sites

To be able to use onitemadded event you need the event filter for it. Do something like:

Event OnInit()

AddInventoryEventFilter(none);none parameter because you want to check every added item and remove if check is not true

Endevent

Edited by shavkacagarikia
Link to comment
Share on other sites

  • Recently Browsing   0 members

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