Locating a specific building in a location's JSON?
- XJDHDR
- Posts: 258
- Joined: Thu Jan 10, 2019 5:15 pm
- Location: New Zealand
- Contact:
Locating a specific building in a location's JSON?
I have a question about the JSON files that are exported when you use the "dumplocation" function. The scenario is that I want to modify the data for a specific building in a settlement. What is the best way to figure out which of the numerous buildings in the Buildings array is the one I'm looking for.
For example, let's say that I've modified one of the houses in a Map Block Record to be a shop. Now I want to modify the corresponding data for that building in a location file. What is the best way to pinpoint which of the array's objects is the one I need to modify? So far, this hasn't been a problem for me because the buildings I've modified were unique ones in that settlement and I only needed to search for the data that made it unique. This won't work if it's a building that is not unique.
For example, let's say that I've modified one of the houses in a Map Block Record to be a shop. Now I want to modify the corresponding data for that building in a location file. What is the best way to pinpoint which of the array's objects is the one I need to modify? So far, this hasn't been a problem for me because the buildings I've modified were unique ones in that settlement and I only needed to search for the data that made it unique. This won't work if it's a building that is not unique.
My DF Unity mods:
Unofficial Block, Location and Model Fixes
Skip Intro Video
My other creations and essays:
https://xjdhdr.gitlab.io/
Unofficial Block, Location and Model Fixes
Skip Intro Video
My other creations and essays:
https://xjdhdr.gitlab.io/
- Ralzar
- Posts: 2211
- Joined: Mon Oct 07, 2019 4:11 pm
- Location: Norway
Re: Locating a specific building in a location's JSON?
I've not messed with exporting like that myself, but when I needed the object ID of fountains in towns, Hazelnut gave me this tips:
viewtopic.php?p=50266#p50266
viewtopic.php?p=50266#p50266
- XJDHDR
- Posts: 258
- Joined: Thu Jan 10, 2019 5:15 pm
- Location: New Zealand
- Contact:
Re: Locating a specific building in a location's JSON?
Thanks for the help Ralzar. I do use those tips for some of the other things I've had to modify but it doesn't help in this one. This is an example of what an object in the Buildings array looks like:
As you can see, the model used by the building is not present in this data. That's defined in the Map Block Record. I suspect that locating the building in question involves the order in which the list of MBRs used by the location is processed.
Code: Select all
{
"NameSeed": 5039,
"FactionId": 0,
"Sector": 4,
"LocationId": 50032,
"BuildingType": "Town23",
"Quality": 8
},
My DF Unity mods:
Unofficial Block, Location and Model Fixes
Skip Intro Video
My other creations and essays:
https://xjdhdr.gitlab.io/
Unofficial Block, Location and Model Fixes
Skip Intro Video
My other creations and essays:
https://xjdhdr.gitlab.io/
- BadLuckBurt
- Posts: 948
- Joined: Sun Nov 05, 2017 8:30 pm
Re: Locating a specific building in a location's JSON?
You are correct, the order is determined by the array indexes of both lists. Easiest would be to merge them into one list which is trivial to do.
Another solution would be to generate a unique identifier for each entry and assign it to the items of both lists for cross referencing them
Another solution would be to generate a unique identifier for each entry and assign it to the items of both lists for cross referencing them
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Locating a specific building in a location's JSON?
If you just want to replace a building, use a building override - it allows some metadata to be defined. Works for a guild, but not sure it would work for a shop as not sure where name seed would come from and don't have time to look right now. What is it that you want to change exactly? It's hard to pinpoint which location building record matches each building because it's done at runtime using certain rules. I'd need to refresh my memory to say more, and first I want to know what you need to achieve.XJDHDR wrote: ↑Mon Dec 21, 2020 8:16 am I have a question about the JSON files that are exported when you use the "dumplocation" function. The scenario is that I want to modify the data for a specific building in a settlement. What is the best way to figure out which of the numerous buildings in the Buildings array is the one I'm looking for.
For example, let's say that I've modified one of the houses in a Map Block Record to be a shop. Now I want to modify the corresponding data for that building in a location file. What is the best way to pinpoint which of the array's objects is the one I need to modify? So far, this hasn't been a problem for me because the buildings I've modified were unique ones in that settlement and I only needed to search for the data that made it unique. This won't work if it's a building that is not unique.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- XJDHDR
- Posts: 258
- Joined: Thu Jan 10, 2019 5:15 pm
- Location: New Zealand
- Contact:
Re: Locating a specific building in a location's JSON?
Sorry, I may have been a bit unclear. I'm not trying to modify a single building in a specific settlement. I'm modifying buildings in Blocks such that those changes will apply to every location that uses this Block. Which means a building override won't work.
As for exactly what I'm doing, I've made a number of changes to a number of Blocks in the game. Some of those are to the BuildingData for the buildings; the FactionId and BuildingType in particular. Finding the right place to edit in the Block override is easy but the change is incomplete unless I also make the same change to the BuildingData for every location which uses that Block. That means that I need to work out which of the objects in the Buildings array for a location corresponds with the building in the block used by that location. This is easy to do if there is only one or two of that building in the location; you just need to search for the data that makes it unique (e.g. if you want to edit the Fighter's Guild, you just need to find the building that is in the FG faction). What I'm asking about are buildings that don't have unique data, like a house.
As for exactly what I'm doing, I've made a number of changes to a number of Blocks in the game. Some of those are to the BuildingData for the buildings; the FactionId and BuildingType in particular. Finding the right place to edit in the Block override is easy but the change is incomplete unless I also make the same change to the BuildingData for every location which uses that Block. That means that I need to work out which of the objects in the Buildings array for a location corresponds with the building in the block used by that location. This is easy to do if there is only one or two of that building in the location; you just need to search for the data that makes it unique (e.g. if you want to edit the Fighter's Guild, you just need to find the building that is in the FG faction). What I'm asking about are buildings that don't have unique data, like a house.
My DF Unity mods:
Unofficial Block, Location and Model Fixes
Skip Intro Video
My other creations and essays:
https://xjdhdr.gitlab.io/
Unofficial Block, Location and Model Fixes
Skip Intro Video
My other creations and essays:
https://xjdhdr.gitlab.io/
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Locating a specific building in a location's JSON?
Yes it will, that's all a building override does. It's like a block override but just for a single building in the block so it's less unneccessary data overridden and also means two+ buildings in a single block can be overridden by different mods/modders in a compatible manner.
Why do you think differently? Is my documentation ambiguous? If so where, and I'll fix that. Don't want to be giving the wrong idea to people.
I recall that new special buildings are not matched - I had to re-code that when some bugs were found. (note that Houses are not matched in DFU, only special buildings) I think that if you convert a house to a special building that it uses the metadata in a building override then it works fine except for a house converted to a shop/tavern you can't define the name seed which is an oversight on my part. I should have realised this when I did the armorer conversion at the end of Mountain Rumors quest, and it will be nice to have some (vague) control over the name with a name seed.As for exactly what I'm doing, I've made a number of changes to a number of Blocks in the game. Some of those are to the BuildingData for the buildings; the FactionId and BuildingType in particular. Finding the right place to edit in the Block override is easy but the change is incomplete unless I also make the same change to the BuildingData for every location which uses that Block. That means that I need to work out which of the objects in the Buildings array for a location corresponds with the building in the block used by that location. This is easy to do if there is only one or two of that building in the location; you just need to search for the data that makes it unique (e.g. if you want to edit the Fighter's Guild, you just need to find the building that is in the FG faction). What I'm asking about are buildings that don't have unique data, like a house.
Regarding block overrides, I'm going to need to review the code but I think it works as per the normal DFU matching rules implemented in RMBLayout.GetLocationBuildingData() - so either look there or wait until I can re-read and tell you what it does.
However, if you're just replacing buildings I think you would find it easier to use building overrides. I will see how I can add name seed to metadata soon. The reason why you would want to do a block override is if you're modifying all the buildings, or the layout & ground textures, or you're creating an entire new block. It doesn't sound like your requirement matches any of those, so building overrides would be preferable.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- XJDHDR
- Posts: 258
- Joined: Thu Jan 10, 2019 5:15 pm
- Location: New Zealand
- Contact:
Re: Locating a specific building in a location's JSON?
I'm sorry. It seems that I either didn't read that part or forgot about it. I was assuming that the BlockIndex portion of the file's name was a location number or something. That said, what does the BlockIndex do? You explained what the other two parts of the file's name does but seem to have glossed over that one.Hazelnut wrote: ↑Tue Feb 02, 2021 1:49 pm Yes it will, that's all a building override does. It's like a block override but just for a single building in the block so it's less unneccessary data overridden and also means two+ buildings in a single block can be overridden by different mods/modders in a compatible manner.
Why do you think differently? Is my documentation ambiguous? If so where, and I'll fix that. Don't want to be giving the wrong idea to people.
You don't have to check. I've already worked out what the behaviour is. BuildingData in a Block Override is overwritten by the equivalent data in MAPS.BSA. If someone doesn't use a building override, they have to modify both the Block and Location.
Thanks, I'll look into it.Hazelnut wrote: ↑Tue Feb 02, 2021 1:49 pm However, if you're just replacing buildings I think you would find it easier to use building overrides. I will see how I can add name seed to metadata soon. The reason why you would want to do a block override is if you're modifying all the buildings, or the layout & ground textures, or you're creating an entire new block. It doesn't sound like your requirement matches any of those, so building overrides would be preferable.
My DF Unity mods:
Unofficial Block, Location and Model Fixes
Skip Intro Video
My other creations and essays:
https://xjdhdr.gitlab.io/
Unofficial Block, Location and Model Fixes
Skip Intro Video
My other creations and essays:
https://xjdhdr.gitlab.io/
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Locating a specific building in a location's JSON?
So I've been reviewing how building replacements work while adding name seed, and I neglected to mention another advantage of using them is that you don't need to modify the location building lists as you can specify specifically for the building. This is sufficient (+easier) unless you change a special (shop/tavern/guild) into a residence for some reason.. or you really require different values for different locations. (unlikely for modified existing blocks unless also modifying all locations using the block)
So I've updated the section titled "Altering an existing town building" in this post viewtopic.php?p=32886#p32886 with details of how the building list stuff works with building overrides, as well as the NameSeed I've added. (should hopefully be in the next DFU release)
Please give it a read and let me know if you have any questions, or whether it's clear?
Also, if you need any assistance with converting any work from block to building overrides I'm happy to help. I know this stuff is confusing and I definitely want the initial mods to be good examples of efficient use of the world data system. Obviously the NameSeeds wont work until the next release of DFU though, but I'll help review all of your changes to see what can be simplified, most of the json will be the same just less of it with a building override... so more files but smaller.
Oh, while doing this I realised that my building override in my Roleplay & Realism mod was incorrect because it converts a residence (one that is actually an armorer, just not marked as such) into a shop without specifying a factionId so DFU tries to match it to a location building record and fails... warnings are in the logs, guess I just ignored em before. Have now added a name seed, but also not planning to use it as I am going to set a name override when the variant is active. However I tested that the name seed works when I am not overriding the name.
Lastly, the blockname and index in the filename are redundant, but I didn't realise that at first and then I was used to having both easily visible. Block names map 1:1 to block indexes and you can convert between them etc.
So I've updated the section titled "Altering an existing town building" in this post viewtopic.php?p=32886#p32886 with details of how the building list stuff works with building overrides, as well as the NameSeed I've added. (should hopefully be in the next DFU release)
Please give it a read and let me know if you have any questions, or whether it's clear?
Also, if you need any assistance with converting any work from block to building overrides I'm happy to help. I know this stuff is confusing and I definitely want the initial mods to be good examples of efficient use of the world data system. Obviously the NameSeeds wont work until the next release of DFU though, but I'll help review all of your changes to see what can be simplified, most of the json will be the same just less of it with a building override... so more files but smaller.
Oh, while doing this I realised that my building override in my Roleplay & Realism mod was incorrect because it converts a residence (one that is actually an armorer, just not marked as such) into a shop without specifying a factionId so DFU tries to match it to a location building record and fails... warnings are in the logs, guess I just ignored em before. Have now added a name seed, but also not planning to use it as I am going to set a name override when the variant is active. However I tested that the name seed works when I am not overriding the name.
Lastly, the blockname and index in the filename are redundant, but I didn't realise that at first and then I was used to having both easily visible. Block names map 1:1 to block indexes and you can convert between them etc.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Locating a specific building in a location's JSON?
Now your website is working for me I can see that you've documented every change - nice work, very impressed actually! (I imagine that I'd have not done that and then regretted it half way though making the mod if it were me )
One of the RMBs you've modified is the same one as I change in my mod. I'm going to see if the override system handles this as I hope it will, it's a good test. I can see that as currently implemented it wont have a record to match in location data, so I think converting to building override will help avoid having to override every location it's present, but to get the name to vary by location would require some more changes.
Thinking of maybe making the NameSeed get combined with location index to achieve this as a way to automate and avoid lots of location data overrides being required for this type of change. I tried it out and it works great. What do you think?
One of the RMBs you've modified is the same one as I change in my mod. I'm going to see if the override system handles this as I hope it will, it's a good test. I can see that as currently implemented it wont have a record to match in location data, so I think converting to building override will help avoid having to override every location it's present, but to get the name to vary by location would require some more changes.
Thinking of maybe making the NameSeed get combined with location index to achieve this as a way to automate and avoid lots of location data overrides being required for this type of change. I tried it out and it works great. What do you think?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods