pra Posted August 7, 2017 Share Posted August 7, 2017 I just noticed that the workshopID in my Home Plate is -1. Is that normal?If no, how could that have happened?If yes, do other workshops have that as well? How do I even tell workshops apart then? Link to comment Share on other sites More sharing options...
Magicockerel Posted August 8, 2017 Share Posted August 8, 2017 Home Plate isn't in the WorkshopParent Workshops array because it's not considered a settlement, as it's an interior workshop. Settlements are always workshops, but workshops aren't always settlements. Indexes are a reliable way to distinguish between settlements. However, I'd imagine that they can change when you add/remove settlements from your save-game. To account for this, I use the WorkshopParent WorkshopLocations array to adjust script properties that I've assigned to workshops. Workshop locations shouldn't change between saves, so it should prove to be reliable.You can have a look at this recent thread where we discuss obtaining workshop indexes and determining whether a workshop is owned.You can have a look at the source code to the scripts in my Workshop Control Panel mod to see how I account for workshop index changes. Specifically, check out the functions that I run when the script is first initialised and when the player subsequently loads the game in the housekeeping script. Link to comment Share on other sites More sharing options...
pra Posted August 8, 2017 Author Share Posted August 8, 2017 Seems like getLinkedRef(WorkshopItemKeyword) is what I was looking for. So, if I call it within the script of my ObjectReference, it should return a WorkshopRef? It is a workshop object which has to be built first. Link to comment Share on other sites More sharing options...
Magicockerel Posted August 8, 2017 Share Posted August 8, 2017 All workshop items should be linked to their respective workshop via the WorkshopItemKeyword. There are a couple exceptions, like some of the tatos on Abernathy Farm. However, that's a bug, and is patched by the UFO4P. You won't encounter this bug if you're dealing with an ObjectReference that you placed in workshop mode, as they should all be given the WorkshopItemKeyword if it's set up correctly. That's the method that I use to get the workshop reference in my mods. Keep in mind that the workbench in each respective settlement is the workshop reference. So, if the target's a workbench (for whatever reason), then you already have the workshop reference (so, you don't need to use GetLinkedRef()). It's a rare case, but I do come across it in my aforementioned mod, so it's worth mentioning if you're looking at the mods scripts. Link to comment Share on other sites More sharing options...
pra Posted August 8, 2017 Author Share Posted August 8, 2017 Ok, I think I got it. Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts