Skyrim Special Edition

Recently a new API feature called Scene Metadata was added to OStim. This feature is extremely simple but it's caused a good deal of confusion, since it's kind of unique to OStim and also is similar to some other systems that exist. Here's what the system does and how to make effective use of it

What is Scene Metadata?
In this context, Scene refers to the entire OStim interaction from the time you call StartScene() until it ends completely. 
You can essentially attach a tag to an OStim scene. That's all. Similar to tagging individual animations, but for the entire OStim sex scene itself. For example I might tag a prostitution scene with "prostitution" . This lets other mods know some context about the scene.

Tagging

Attatch a tag with *AddSceneMetadata(string MetaTag)* in OStim's main script. After that you can see if a tag is attached with *HasSceneMetadata(string MetaTag)*
You can read tags even after the scene is ended. Old tags are cleared when a new scene starts. However, you can also add tags BEFORE the scene starts and they will apply to the next scene. Note this excerpt from ORomance

ostim.AddSceneMetadata("oromance")
ostim.startscene(dom, sub, zStartingAnimation = startinganim, zThirdActor = third)


Here we add this tag before calling startscene. Basically, when a new scene starts only the old tags from the last scene are cleared. Any tags you've added since the last scene will stick.

Using these tags
There are a few uses for these. 
The first use is simply replacing some bool variables in your script. If you only want your SceneChanged code to run during specific types of scenes, like say scenes with Argonians in them, you can preform the check for that in prestart and attach a metadata tag so you don't have to do the check every time SceneChanged runs.
The second use is building compatibility with other mods. If I have a prostitution mod I can attach a prostitution tag to all of the scenes I start, and other mods will know what kind of scene that is and can behave differently.
The third use is building addons to other mods. Like the previous thing here, scene metadata makes inter-mod communication easier.

Misusing these tags
It is extremely easy to overuse tags as well so watch out. 

Don't
use tags to hardcode for other mods unless your mod is explicitly an addon for said mod. 

All of my addons do attach a metadata tag that includes the name of the addon, but you shouldn't use it in most cases.
For example, you want your mod to have special behavior when an npc scene runs so you check for the ONights tag ONights adds. Bad!
You should instead check ostim.isnpcscene(). Using this check will make sure your code is compatible with similar mods that will do the same thing in the future.
You should only specifically hardcode your addon for other addons by name if you are explicitly making an addon to that addon. 
Here are some commonly missed but useful scene checks in OStim's main script:
- IsSoloScene()
- IsPlayerInvolved()
- IsNPCScene()
- IsSceneAggressiveThemed()
- GetCurrentLeadingActor()


Don't
 go wild with tons of tags. Metadata tags use strings as logic which are easy to typo and can make your code harder to read. Additionally, base OStim will continue to pass information on the current scene primarily through getter functions like the ones above instead of replacing them with metadata tags. The reason is so that tab completion and compiler errors will catch mistakes and keep addon creation fast.

Article information

Added on

Written by

Sairion350

0 comments