Jump to content

Getting thisWorkshop settlers into an Array


Recommended Posts

This I'm trying to get the all settlers from a specific workshop into an array in a Quest script.

 

workshopScript thisWorkshop = pWorkshopParent.getWorkshopFromLocation(Game.getPlayer().getCurrentLocation())
ObjectReference[] settlers = pWorkshopParent.GetWorkshopActors(thisWorkshop)
Debug.Notification("Number of settlers : " + settlers.length)

But the array length is always zero...

 

Link to comment
Share on other sites

Considerations:

 

(1) GetWorkshopFromLocation is the first thing to fail in the modded commonwealth due to location overwrites and workshops being removed. You may want to test for none return and run a backup:

ObjectReference[] FoundWorkshops = pPlayerRef.FindAllReferencesWithKeyword(pWorkshopKeyword, 10240)

(2) Non unique actor settlers are non persistent objects, if they are not in the 3d loaded area around the player defined by uGridsToLoad you will not find them. An issue with extended build/sandbox borders.

 

(3) Rather than stress busy 'ol WorkshopParentScript, make the call it makes direct:

ObjectReference[] WorkshopActors = ThisWorkshop.GetWorkshopResourceObjects(pWorkshopRatingPopulation)  as ObjectReference[]

Be aware it excludes Cows, Codsworth, Dogmeat, RobotCurie, GraygardenWorkers, DLC robots as they do not count for population with WorkshopRatingPopulation = 0

Link to comment
Share on other sites

Compare with an alternative function:

ObjectReference[] WorkshopActors = ThisWorkshop.GetActorsLinkedToMe(pWorkshopItemKeyword) as ObjectReference[]

BUT this does include Codsworth, Dogmeat, RobotCurie, GraygardenWorkers, Brahmin, Dogs, Turrets ... any actor object type.

Link to comment
Share on other sites

At first with the alternative function it was not working, but because I forgot to assign the properties in ck.... ahhh

 

But now it's working thanks again.

 

I learning by looking at tutorials and looking at other script. Too bad the Papyrus info is scattered like that. I look for a good book on Papyrus scripting but didn't find any.

 

 

 

Thanks.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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