1. API Rundown: the basics - Sairion350/OStim GitHub Wiki

Written by Sairion

OStim is single threaded (only runs one animation at a time, no matter what) and asynchronous. It also fires a couple of events as well. All of the code of the mod is located in OsexIntegrationMain.psc. Functions under the "utilities" section will probably be the most useful to you, but you can call any code within that script if you have to.

You don't have to worry about thread IDs or anything like that. Just grab the OStim main script, feed actors into the script and call functions in the script.

You'll need SkyUI's SDK to compile scripts with OStim (SkyUI powers the OStim HUD). Just dump the source files here in the usual place in your install and you should be good to go

Example A: start an animation and run code during it

    OsexIntegrationMain ostim = OUtils.GetOStim()
    ostim.StartScene(playerref,  secondActor, zstartinganimation = "0MF|Cy6!DDy6|Sx|DoggyLiPopSxHT") ;start in the doggystyle position
    while ostim.animationrunning()
        ;run code while the animation plays
        ostim.endAnimation()
    endwhile

Example B: run code when player orgasms

    function register()
        RegisterForModEvent("ostim_orgasm", "Ostimorgasm")
    endfunction

    Event Ostimorgasm(string eventName, string strArg, float numArg, Form sender)
        if (ostim.getMostRecentOrgasmedActor() == playerref)
            ;code
        endif
    endevent

Example C: Force disable stripping setting. all settings are just properties on the main script you can toggle if you absolutely must

    OsexIntegrationMain ostim = OUtils.GetOStim()
    ostim.alwaysUndressAtAnimStart = false ; best to turn it back on after 

    ostim.StartScene(playerref,  secondActor)

The general design philosophy behind more advanced API usage is to register to an event and run the code you need to inside of events. Thus, the general thought process behind creating an addon is as follows

  1. Consider when you need to run code to make your idea work (on orgasm, when the animation changes to something, at the start of a new scene, at the end of a scene, etc).
  2. Ctrl + f osexintegrationmain for "sendmodevent" to see all of the points you can register up to
  3. Register to those, and call OStim from within your event functions. With the exception of the Sound event, no OStim events send data with them, so you don't have to worry about fumbling with that and you can just get the data you need from the OStim api

Also if you're new to the papyrus scripting language and how that works in Skyrim, this might help you: Modding Skyrim: Scripter's Edition