Jump to content

Help With A Script


MadTod

Recommended Posts

I need a script that will add the contents of a levelled list to a container once it has been placed (created) from the settlement workshop menu.

 

The workshop does not allow items to spawn in containers that are created even if the is in fact items within, so I need a script for it.

 

 

I would like the script to do 2 things, 1: add the items to the container upon creation, and 2: refill the container whenever you load into the cell, regardless of whether or not anything has actually been taken.

 

I tried a slightly edited version of the RefillInventoryOnLoadScript which is used by the vault supply containers from the Vault Workshop DLC but that script is insufficient for my needs.

 

 

As my scripting knowledge is fairly basic (limited to copying and simple edits) I would greatly appreciate any help that can be provided, thanks.

Link to comment
Share on other sites

I havan't tested this but of the top of my head I would try it like this. Place the following script on the container you want this to happen for:

FormList Property YourFormList Auto

Event OnWorkshopObjectPlaced(ObjectReference akReference)
    Int i = 0
    While (i < YourFormList.GetSize())
        Self.AddItem(YourFormList.GetAt(i)) ;If you want to add more than one of the items then you can add ",X" after .GetAt(i) whithout quotes where x is the amount you want.
    i += 1
    EndWhile
EndEvent

Event OnCellLoad()
Self.RemoveAllItems() ;If you don't mind items getting added that where still there you can skip this line.
    Int i = 0
    While (i < YourFormList.GetSize())
        Self.AddItem(YourFormList.GetAt(i)) ;If you want to add more than one of the items then you can add ",X" after .GetAt(i) whithout quotes where x is the amount you want.
    i += 1
    EndWhile
EndEvent
Link to comment
Share on other sites

Thanks, I'll give it a try then report my findings.

 

Findings:

 

Papyrus Compiler Version 2.8.0.4 for Fallout 4

Copyright © ZeniMax Media. All rights reserved.

Starting 1 compile threads for 1 files...

Compiling "WorkshopSupplies_ComponentSCRIPT"...

C:\User\Me\AppData\Local\Temp\PapyrusTemp\WorkshopSupplies_CompontensSCRIPT.psc(3,19): const scripts may only contain const auto properties. Property FLWorkshopSupplies_Components cannot be defined

C:\User\Me\AppData\Local\Temp\PapyrusTemp\WorkshopSupplies_ComponentsSCRIPT.psc(3,19): const script may not contain data, script variable ::FLWorkshopSupplies_Components_var cannot be difined

No output generated for WorkshopSupplies_ComponentsSCRIPT, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on WorkshopSupplies_ComponentsSCRIPT

 

 

I changed the "YourFormList" to "FLWorkshopSupplies_Components" and added the value ",1000" to "Self.AddItem(FLWorkshopSupplies_Components.GetAt(I),1000)

 

I assume the "YourFormList" is for a Form List not a LeveledItem List or can it be either.

Edited by TanisDuncan
Link to comment
Share on other sites

It works wonderfully thanks, you have no idea how long I've been trying to achieve this (well since the creation kit's release).

 

I'll be sure to credit you for the script in the mod's description.

 

Thanks again.

Link to comment
Share on other sites

It would be better to put the loop into a function.

 

 

FormList Property YourFormList Auto

Function AddItemsToContainer()
    
    Int i = 0
    
    While (i < YourFormList.GetSize())
        Self.AddItem(YourFormList.GetAt(i)) ;If you want to add more than one of the items then you can add ",X" after .GetAt(i) whithout quotes where x is the amount you want.
        i += 1
    EndWhile
    
EndFunction


Event OnWorkshopObjectPlaced(ObjectReference akReference)

    AddItemsToContainer()
        
EndEvent

Event OnCellLoad()

    Self.RemoveAllItems() ;If you don't mind items getting added that where still there you can skip this line.
    AddItemsToContainer()

EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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