Jump to content

Quest aliases and arrays


Recommended Posts

I'd like to create a mod such that, when I create a store in workshop mode, a container is also created that is associated with the store. When I move the store, the container needs to move with it, and when I remove the store, the container needs to be deleted. I've got all the relevant event types, so it would be something like:

Event OnWorkshopObjectPlaced(ObjectReference akReference)
	ObjectReference myContainer = akReference.PlaceAtMe(StoreContainer)
EndEvent

Event OnWorkshopObjectGrabbed(ObjectReference akReference)
	myContainer.Disable()
EndEvent

Event OnWorkshopObjectMoved(ObjectReference akReference)
	myContainer.SetPosition(akReference.GetPosition)
	myContainer.Enable()
EndEvent

Event OnWorkshopObjectDestroyed(ObjectReference akReference)
	myContainer.RemoveAllItems(akTransferTo = WorkshopContainer)
	myContainer.Delete()
EndEvent

So… umm… how would I go about doing all that? How do I make sure I'm using the right container reference? I guess potentially I could just look for the container nearest to the store, and then I wouldn't need an array. I'm still not entirely sure where to add the script though, and how to use an alias to make sure it only acts on workshop stores rather than any workshop object. On the other hand, if I were to figure out how to do it with arrays, I assume I could use that to make my Provisioner Caravan Guards mod less invasive and finally create a version that's compatible with Workshop Framework and Sim Settlements, which would be nice!

 

Link to comment
Share on other sites

Set a LinkedReference from the Store to the Container when it is created:

thisStore.SetLinkedRef(myContainer, myKeyword)

Then you can always get it and do event triggered magic:

ObjectReference myContainer = Self.GetLinkedRef(myKeyword)

Link to comment
Share on other sites

Thank you! This, essentially, has worked. The problem I'm having now is, I want to add the container to the stores so I can display items, à la the magazine and bobblehead racks, but I'm realising, when the containers are moved by console commands, the displayed items don't move with them. So it looks like that will require some creativity… Obvious thing is to make the container itself the workshop object, and the actual functional store the linked object. I'll have to check that doesn't create problems when trying to assign settlers though. And it will definitely create problems with existing stores. Hmmmmmmmm.

Edited by adb3nj
Link to comment
Share on other sites

  • Recently Browsing   0 members

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