Jump to content
  • Announcements

    • AndalayBay

      Orphan Attachments   07/31/2018

      I have been doing some housekeeping lately and I've noticed that I had a lot of orphaned attachments. Attachments get orphaned when the PM or post is deleted without removing the attachment first. Deleting a PM or post does not delete the attachment and the file or image remain on the server. I'd like to ask all members to go through their attachments and delete any attachments you don't need anymore or those that have been orphaned. Where can I get a list of my attachments? Click on your display name in the upper right corner of the forums and pick "My Attachments" from the drop-down list. How can I tell an attachment is orphaned? If the PM has been deleted, you'll see a message like this in your attachment list: Unfortunately there is no message if the post has been deleted, so please check your old posts. We do purge old birthday threads every once in a while. Also some hosted projects have been shut down, so you may have orphaned attachments on one of those locations. Thanks!
Sign in to follow this  
FricativeMelon

OBSE: Using GetCurrentRegions?

Recommended Posts

I've been trying to use GetCurrentRegions to allow the player to rename regions in-game, and it does return a list of proper Region FormIDs of the correct size, but GetName doesn't work. When called like (GetName region) it returns "<no name>", and when called like region.GetName, it says region is a null reference or base object. ToString returns "<no name>" as well, and HasName returns 0. So Regions don't have names in that sense, it seems.

And there doesn't seem to be a single other function relating to regions besides the deprecated GetCurrentRegion, at least not any on the Construction Set Wiki. So I can't get any information dynamically from regions in game, nor modify them. Am I missing something, or is GetCurrentRegions actually useless for mod-added regions you don't know about in advance, and you can't actually change region names in-game at all?

I mostly want to change the name that appears on the local map and load doors to that region (the only ways region map names matter), but I still need to know the name anyway to know if I need to change it. Only other way I could imagine doing it is somehow grabbing the name from the U.I., and changing it the same way, using the OBSE U.I. functions, but then I'd also have to change what appears when you mouse over doors to the region, which I don't even know how I'd do, and all for a simple cosmetic change. I'm not going to even attempt to do that unless someone actually knows how I'd do it fairly easily.

Share this post


Link to post
Share on other sites
17 hours ago, FricativeMelon said:

I've been trying to use GetCurrentRegions to allow the player to rename regions in-game, and it does return a list of proper Region FormIDs of the correct size, but GetName doesn't work. When called like (GetName region) it returns "<no name>", and when called like region.GetName, it says region is a null reference or base object. ToString returns "<no name>" as well, and HasName returns 0. So Regions don't have names in that sense, it seems.

And there doesn't seem to be a single other function relating to regions besides the deprecated GetCurrentRegion, at least not any on the Construction Set Wiki. So I can't get any information dynamically from regions in game, nor modify them. Am I missing something, or is GetCurrentRegions actually useless for mod-added regions you don't know about in advance, and you can't actually change region names in-game at all?

I mostly want to change the name that appears on the local map and load doors to that region (the only ways region map names matter), but I still need to know the name anyway to know if I need to change it. Only other way I could imagine doing it is somehow grabbing the name from the U.I., and changing it the same way, using the OBSE U.I. functions, but then I'd also have to change what appears when you mouse over doors to the region, which I don't even know how I'd do, and all for a simple cosmetic change. I'm not going to even attempt to do that unless someone actually knows how I'd do it fairly easily.

So you've got an array of regions, correct? I would dump the contents of that array to see what it contains. I use a function called ArrayDeepDump which automatically goes through multi-dimensional arrays, if needed. If you like, I can post my version which I configured to use a Conscribe log.

If these are mod added regions you're looking to change, why don't you just fix the region names in the CS?

Anyway if you could post what GetCurrentRegions returns, I could investigate further.

Share this post


Link to post
Share on other sites
2 hours ago, AndalayBay said:

So you've got an array of regions, correct? I would dump the contents of that array to see what it contains. I use a function called ArrayDeepDump which automatically goes through multi-dimensional arrays, if needed. If you like, I can post my version which I configured to use a Conscribe log.

If these are mod added regions you're looking to change, why don't you just fix the region names in the CS?

Anyway if you could post what GetCurrentRegions returns, I could investigate further.

** Dumping Array #197 **
Refs: 0 Owner 05: RenamePlayerHomes.esp
[ 0.000000 ] : <no name> (0006EF2F)
[ 1.000000 ] : <no name> (000688E1)
[ 2.000000 ] : <no name> (0008D753)
[ 3.000000 ] : <no name> (0007B864)
[ 4.000000 ] : <no name> (03014E9F)

I've confirmed that two of those FormIDs are the FormIds of two of the regions I was in when calling the function (outside Frostcrag Spire). I doubt that these register as arrays for ArrayDeepDump in any case, though I don't know much about that function. They do register as Regions under GetObjectType.

My mod intends to allow the player to rename any player-owned interior structure. For example, if they have Frostcrag Spire DLC (which is what I've been using for testing since it has basically all the parts I want) and use the rename trigger right outside Frostcrag Spire, it will determine that the common name is "Frostcrag Spire" by analyzing interior name prefixes, and allow you to change all interiors, keys, and corresponding map markers to that string all at once (So given the new name "My Magic House", you will have "My Magic House Main Level", "My Magic House Living Area", "My Magic House Vault", "My Magic House Key", and a map marker "My Magic House"). All that works, but I'd also like to rename corresponding regions, so that load doors and the local map respect that change. I'm not looking to change any specific mods: I'd like this to work on any player-owned interior setup. Otherwise, it isn't that useful if I need a patch for every mod-added player home, or the player still sees the old name every time he leaves his renamed home.

I am using DLCFrostcrag, and HUD Status Bars (since I can't really just disable that mod without breaking the U.I., I discovered), while testing. Not that either of those should affect GetCurrentRegions, but just in case it matters.

Edited by FricativeMelon

Share this post


Link to post
Share on other sites

It's definitely an array and would register just fine. I use it for all arrays since it formats the data better.

Anyway you can't use Form ID's as is. They will change according to load order. You need to translate those Form ID's into a proper reference. I'd have to play with this function a bit more to see if it's like getHighActors. You might have to use GetFormFromMod. If you do, you should also use IsModLoaded or the game will crash if you reference a non-existent mod. Otherwise you might be able to do something like this:

ref regionRef
array_var arRegions
array_var arRegn
string_var sRegion

let arRegions := getCurrentRegions

foreach arRegn <- arRegions
  let regionRef := arRegn["value"]
  let sRegion := regionRef.getName
  ...
loop
...

 

Share this post


Link to post
Share on other sites

The code I had was exactly what you suggest. I got a null exception on regionRef.getName, and it didn't even set the string I was trying to store it in to anything. SetName doesn't work at all either, any way I call it.

The wiki says that GetFormFromMod only works with FormID literals, which as I've explained I cannot hardcode into my script. I have to use the return value of GetCurrentRegions.  Supposing the wiki is wrong and it does work, do you mean something like iterating through all the mods the user has using GetNthModName, and calling GetFormFromMod on each region and each mod, to see if it returns a valid reference, and if so set it? I'm pretty sure any duplicated FormIDs would screw that up anyway, even if it's unlikely enough for me to ignore.

Share this post


Link to post
Share on other sites

That’s exactly what GetFormFromMod does: it gives you the proper form ID. Basically it takes the last 6 digits of the form ID, which you would get from GetCurrentRegions and looks up the actual form ID in the mod. We have to use it for an item detection script in Dark Brotherhood Chronicles. Having said that, you should be getting the proper form ID from GetCurrentRegions, so you don’t need to make that adjustment.

I’m wondering if it’s the region name you want to change. Are they even set? I’ve been away from modding for over 2 years now, so I don’t remember. I’m wondering if it’s actually the exterior cell names you want to modify. As I think about it, most mods probably don’t change the exterior cell names, so they would be null, which the CS shows as “Wilderness”.

I suggest having a look at what TES4Edit shows for the data you’re trying to change. If the region has a name, it will show it.

Share this post


Link to post
Share on other sites

Thanks Schtearn that explains why Get or SetName isn't working - there isn't one. That's what I was wondering. You can get at Editor ID's in-game - OBSE has functions for that. As that article explains though, Editor ID's are not unique. They are base objects, which are instantiated in-game.

Share this post


Link to post
Share on other sites

Okay, thanks for your help. It seems like there's no way to change the display name on the local map or load doors to exterior cells dynamically in game, then. That value is in the Map tab in the Region editor, but seems inaccessible in-game, as is basically all other Region data. EditorIDs cannot help me access that data, as far as I'm aware.

Is the reason OBSE includes basically no support for regions because the team never found where the data is stored? Or was it just never a priority and could be accomplished fairly easily by someone familiar with making OBSE plugins?

Share this post


Link to post
Share on other sites

I really don’t know. However it looks like the name is derived from the Editor ID, which is a major departure from the regular implementation of the Editor ID, so it might all be hard-coded in the engine and there’s nothing OBSE can do.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×