EXTRA: How to port a Sexlab mod to OStim - Sairion350/OStim GitHub Wiki
How to port a Sexlab mod to OStim
Written by OsmosisWrench
This will outline how to either port an existing sexlab mod to OStim, or in the advanced section at the bottom how to include support for both sexlab and ostim at the same time (Not yet done, soz). This will also cover the common gotcha's and differences that can trip you up when developing a port.
This guide is written under the assumption that you have a basic familiarity with both programming and papyrus, and a partial understanding of general Skyrim modding.
If you feel you don't have that, or find anything in this guide confusing then I recommend checking out the following guide on the Nexus: Modding Skyrim - Scripter's Edition
Let's have a chat about permissions
Out of both curtesy to the original creators and from a legal perspective, please don't post ports of mods you don't have permission to modify on Loverslab or Nexus. It's just a bad look for everybody, and the last thing we need is more asinine modding Drama.
Obviously, if you're just porting this for yourself to use in private go ahead and do whatever you want. Nobody can control what you do on your computer in your own time.
Requirements
You will definitely need the following:
- The SSE Creation Kit
- XEdit
I also highly recommend the following:
- SSE Creation Kit Fixes - This makes the CK a LOT more stable.
Getting Started
At its' most basic level, porting a mod from Sexlab to OStim only requires four steps:
- Converting Sexlab scene calls to OStim scene calls.
- Removing Sexlab script properties and replacing them with OStim properties.
- Reworking extraneous Sexlab dependant code.
- Removing Sexlab as an ESP master.
Converting Sexlab scene calls to OStim
In sexlab, all scenes are started with one of a small number of function calls. This is the best place to start when trying to convert a Sexlab mod to OStim, search all the source files of the sexlab mod for something along the lines of:
Sexlab.QuickStart
or
sslThreadModel Model = SexLab.NewThread()
; bunch of calls adding actors and animations etc.
Model.StartThread()
If it's the first of the two, you'll find it's extremely easy to just line up the arguments of the Sexlab.QuickStart function to OStim.StartScene from OSexIntergrationMain.psc
For the second style of scene start, it's a little more complex. You'll have to actually read the code and understand what actors, animations etc it is pushing to the thread and instead set those as arguments for OStim.Startscene()
Replacing Script Properties
You'll next need to open the mod up in the CK (Setting the mod to be the Active Plugin) but also include OStim.esp as one of the loaded plugins.
Next you'll want to open up whatever quest contains the script you just edited, go to the scripts page and select the Properties button and then add a new property. Call it OStim and link it to OSexIntergrationMain, if it doesn't show up as an option make sure you added OStim as a loaded plugin.
While you're here, remove the Sexlab Property from this script as well.
Reworking extraneous Sexlab dependant code
I define "Extraneous" as anything that uses sexlab functions without actually starting a scene. So this could be things like checking the sex of an actor, detecting when a scene starts or ends, searching for animations, etc.
For these you'll find generally there is enough info to be found by checking the other articles or searching through the ostim scripts. Just apply some basic logic to what you're seeing and it'll normally be enough.
Common Gotchas
There are a few common gotcha's that can trip you up when using OStim compared to Sexlab, I'll outline some of them here:
OStim returns on scene start
Sexlab start functions don't return until the scene is finished, OStim functions return when the scene starts. If you have a Sexlab mod that has something like the following:
Sexlab.QuickStart(dom, sub)
quest.setstage(55)
In Sexlab, the setstage wouldn't fire until the scene finished, but with OStim the setstage will fire during the ostim scene startup. This can obviously cause issues, so in these cases you can perform the following hack.
OStim.StartScene(dom, sub)
While OStim.AnimationRunning()
Utility.wait(1)
endwhile
quest.setstage(55)
Though obviously the best way to handle this is to register for OStim_End and move the setstage into that event.
Sexlab GetGender returns int
In Sexlab, when you call Sexlab.GetGender(act) it will return an int, 0 for invalid, 1 for female and 2 for male. (Plus other stuff for creature genders, but those aren't relevant for us here.)
OStim on the other hand, has two similar but different explicit checks:
Ostim.IsFemale()which will returntrueif the actor isn't in the SOS Penis faction. (If SOS isn't installed it will fall back to the function below.)Ostim.AppearsFemale()which will returntrueif the actor is female according to their Vanilla Skyrim record.
An example of where you might see this sort of code:
if Sexlab.GetGender(actor2) == 1 ; if actor2 is female, actor1 should be dominant
Sexlab.QuickStart(actor1, actor2)
elseif Sexlab.GetGender(actor2) == 2 ; if actor2 is male, actor2 should be dominant
Sexlab.QuickStart(actor2, actor1)
else ; if not 1 or 2, report bad scene.
Utility.Notification("Bad Scene")
endif
The equivalent for this in OStim would be:
if OStim.IsFemale(actor2) ; if actor2 is female, actor1 should be dominant
OStim.StartScene(actor1, actor2)
else ; if actor2 isn't female, actor2 should be dominant
OStim.StartScene(actor2, actor1)
endif
or simply:
OStim.StartScene(actor1, actor2)
...since OStim does gender auto-sorting for MF scenes in StartScene unless you override it with a property.
Removing Sexlab as an ESP master
Now you'll need to open up the esp in XEdit, right click on it and Select Clean Masters and if you're fortunate Sexlab will no longer be listed as a master under the File Header section. If it's still listed there however, you've got more work to do.
You'll now need to comb through the esp and find all places Sexlab is being used or referenced. A quick way to do this is use the Report Masters script in XEdit:
Right Click, Apply Script, Script: Report Masters, Apply and select Sexlab.esm
This will give you a list of all parts of the mod that reference Sexlab. Each of these will need to be either deleted because they aren't needed or replaced with an OStim equivalent if they are. This is by far the most time consuming part of conversion, as it's mostly just tedious editing of records or scripts.
However, once that's done you've sucesfully ported a mod to use OStim instead of Sexlab! Congratulations, I hope you remembered to get permission to post it from the creator or else nobody but you is ever gonna see it 😭.
Common Issues & Questions
None at the moment, but I'll add more in the future.
Random useful code snippets
None at the moment, but I'll add some as I think of them.