Jump to content

Threading and Stats in SL


Recommended Posts

I was experimenting with the SexLab framework the last two days and I got it working. Sex scenes are working almost the way I wanted. Which leads me to my questions.

 

Threading

As I was reading the documentation, I experienced the lack of documentation about threading. I learned that you can have finer control over the sex scenes only by using threads.

 

I tried to make a thread and control my sex scene with it, but the sex scenes failed to start. So how am I supposed to implement a thread correctly?

 

This is my try

 

 

sslBaseAnimation[] SexAnimationList
    Actor[] SexParticipant = new Actor[2]
    int GenderPC = (akPlayer.GetBaseObject() as ActorBase).GetSex()
    int GenderNPC = (akClient.GetBaseObject() as ActorBase).GetSex()
    string SexPartners

    if(GenderPC == 0 && GenderNPC == 0)
        SexParticipant[0] = akClient
        SexParticipant[1] = akPlayer
        SexPartners = "MF"
    elseif(GenderPC == 0 && GenderNPC == 1 || GenderPC == 1 && GenderNPC == 0)
        SexParticipant[0] = akPlayer
        SexParticipant[1] = akClient
        SexPartners = "MF"
    elseif(GenderPC == 1 && GenderNPC == 1)
        SexParticipant[0] = akPlayer
        SexParticipant[1] = akClient
        SexPartners = "FF"
    endif

    SexAnimationList = SexLab.GetAnimationsByTag(2, Variables.SexAct, SexPartners, tagSuppress = "Zaz")
 
    sslThreadModel th = SexLab.NewThread()
    th.AddActor( SexParticipant[0])
    th.AddActor( SexParticipant[1])
    th.SetAnimations(SexAnimationList)
    th.DisableLeadIn(true)
 
    Form EquipPC = SexLab.StripActor(akPlayer)
    Form EquipNPC = SexLab.StripActor(akClient)
 
    th.StartThread(SexParticipant, SexAnimationList)
 
    SexLab.UnstripActor(akPlayer, EquipPC)
    SexLab.UnstripActor(akClient, EquipNPC)
    SexLab.ApplyCum(akPlayer, CoverAreas) ; CoverAreas is an int which keeps track of the areas covered previously w/o cleaning herself

 

What can you do with hooking into the SexLab anims? I have seen, you could send a Message Object, can you play mono/dialogues between the sex scenes? Or pause the change of scenery to do something else like playing your own scene?

 

Statistics

Since I needed more stats which SexLab already tracks, but which aren't exposed public, I linked sslSystemResources into my script. I guess, as long as the underlying variables don't get their names changed in an update it is safe to use it. Or am I wrong with this assumption?

Link to comment

    int GenderPC = (akPlayer.GetBaseObject() as ActorBase).GetSex()
    int GenderNPC = (akClient.GetBaseObject() as ActorBase).GetSex()

This is the wrong way to get gender, you should use akClient/akPlayer.GetLeveledActorBase().GetSex() to get gender in Papyrus, casting as ActorBase will give you the base object, not the object references base. For example; a bandit could be either male or female, but they both use the same ActorBase, so casting to actorbase and useing GetSex() will result in potentially unexpected return, it may even return as -1, leading your whole if statement to breakdown.

 

That's for normal papyrus, in the case of SexLab, it would be better to use SexLab.GetGender(akClient/akPlayer), as this will properly check if the actor is flagged as a hermaphrodite for SexLab by other mods, and thus should return the appropriate use gender.

 

    if(GenderPC == 0 && GenderNPC == 0)
        SexParticipant[0] = akClient
        SexParticipant[1] = akPlayer
        SexPartners = "MF"
    elseif(GenderPC == 0 && GenderNPC == 1 || GenderPC == 1 && GenderNPC == 0)
        SexParticipant[0] = akPlayer
        SexParticipant[1] = akClient
        SexPartners = "MF"
    elseif(GenderPC == 1 && GenderNPC == 1)
        SexParticipant[0] = akPlayer
        SexParticipant[1] = akClient
        SexPartners = "FF"
    endif

Apart from the above reply about genders, SexLab has a function for this. SortActor() All animations in sexlab are setup as females followed by males, so passing this function an array of actors, will return your same array, only sorted to have the females in front.

 

Secondly, the setting SexPartners to MF or FF is uneccsarry. There is only one 2 person animation that is not MF, tribadism, so defining MF is kind of moot, and absolutely going to cause you grief in the next bit.

 

SexAnimationList = SexLab.GetAnimationsByTag(2, Variables.SexAct, SexPartners, tagSuppress = "Zaz")

Without knowing what you are storing in Variables.SexAct, I can't really say 100% why this isn't working, bad input there could easily break this whole animation selection down.

 

Also GetAnimationsByTag() defaults to requiring all tags. So for example, if you had GetAnimationsByTag(2, "Anal", "FF", tagSupress = "Zaz") that is obviously not going to return you any animations, there is no Anal FF animations (again, the only FF tagged animation is tribadism)

 

If you want to select specific animations arch types, drop the SexPartners tag, and make sure whatever you filling Variables.SexAct with actually exists.

 

 

Actor[] SexParticipant = new Actor[2]

;// ... Other Stuff ...

th.AddActor( SexParticipant[0])
th.AddActor( SexParticipant[1])

You aren't filling SexParticipant's anywhere here, you just initialize the array and leave it empty, you are essentially saying AddActor(None).

 

Form EquipPC = SexLab.StripActor(akPlayer)
Form EquipNPC = SexLab.StripActor(akClient)

;// ...

SexLab.UnstripActor(akPlayer, EquipPC)
SexLab.UnstripActor(akClient, EquipNPC)

Two things here as well.

 

StripActor() returns an array, Form[], you are trying to set it as a single form.

 

Secondly it's wholly unnecessary, you aren't passing any strip overrides, just telling it to strip the actor with the default strip settings, something SexLab will do on it's own after StartThread() is called, UnStripActor() is also called automatically by SexLab when the actor finishes.

 

You are essentially saying here to Strip before sex, and then put your clothes back on while having sex.

th.StartThread(SexParticipant, SexAnimationList)

StartThread() takes no arguments, you just call th.StartThread() and it goes, returning the sslThreadController instance of your scene, you are confusing it for StartSex() here, which you shouldn't be using if you are using NewThread() to create your scene.

SexLab.ApplyCum(akPlayer, CoverAreas) ; CoverAreas is an int which keeps track of the areas covered previously w/o cleaning herself

What you are attempting here is also rendered moot by SexLab 1.20, which should be coming out on Sunday, as it now tracks and stacks existing cum automatically.

 

 

 

What can you do with hooking into the SexLab anims? I have seen, you could send a Message Object, can you play mono/dialogues between the sex scenes? Or pause the change of scenery to do something else like playing your own scene?

 

You can do whatever you want to do, hooks are just points in time during a scene that you can be notified of, what you do once hooking into that notification is up to you.

 

 

Since I needed more stats which SexLab already tracks, but which aren't exposed public, I linked sslSystemResources into my script. I guess, as long as the underlying variables don't get their names changed in an update it is safe to use it. Or am I wrong with this assumption?

 

 

sslSystemResources no longer exists at all in SexLab 1.20, so I wouldn't count on it. The variable names themselves are unchanged, but where they are accessible from has changed completely. They are all in sslActorStats now, along with all the functions for registering custom stats and retrieving SexLabs own tracked stats.

 

 

Lastly. If you ever have issues with sexlab starting, or papyrus in general, always be sure to first check your debug log, chances are you will find your cause there. SexLab itself is good about being verbose in the debug log when it comes to rejecting an animation start.

Link to comment

Thank you for your time for answering my post. A few questions still boggles my mind :)

 

 

 

That's for normal papyrus, in the case of SexLab, it would be better to use SexLab.GetGender(akClient/akPlayer), as this will properly check if the actor is flagged as a hermaphrodite for SexLab by other mods, and thus should return the appropriate use gender.

 

Ahh yes, I wasn't thinking about hermaphrodites. Seems I have overlooked the function you provide.

 

Without knowing what you are storing in Variables.SexAct, I can't really say 100% why this isn't working, bad input there could easily break this whole animation selection down.

Yeah, I forgot to include it. Here is the snippet which defines Variables.SexAct

string _SexAct = "None"
 
string Property SexAct
    Function Set(string _Value)
        if(_Value == "Oral")
            _SexAct = _Value
            SexActToInt = 1
        elseif(_Value == "Vaginal")
            _SexAct = _Value
            SexActToInt = 2
        elseif(_Value == "Anal")
            _SexAct = _Value
            SexActToInt = 3
        else
            _SexAct = "None"
            SexActToInt = 0
        endif
    EndFunction
    string Function Get()
        return _SexAct
    EndFunction
EndProperty
 
int Property SexActToInt Auto Conditional

What it simple does is to hold the string for SexLab animation searching and filling a conditional to use it in dialogues.

So the whole stripping and dressing will still be handled by ThreadController? Good to know. And if I want to override it, I use the th.StripActor() function instead which will override the default stripping setting? Am I assume it right?
 

 

You can do whatever you want to do, hooks are just points in time during a scene that you can be notified of, what you do once hooking into that notification is up to you.

Ahh, that is cool. I will dig deeper into this to explore some possibilities and creating something nice :)
 

 

Secondly it's wholly unnecessary, you aren't passing any strip overrides, just telling it to strip the actor with the default strip settings, something SexLab will do on it's own after StartThread() is called, UnStripActor() is also called automatically by SexLab when the actor finishes.

 
So the new code should look like this?
 

    sslBaseAnimation[] SexAnimationList

    Actor[] SexParticipant = new Actor[2]
    SexParticipant[0] = akClient
    SexParticipant[1] = akPlayer
    SexParticipant = SexLab.SortActors(SexParticipant)

    SexAnimationList = SexLab.GetAnimationsByTag(2, Variables.SexAct, tagSuppress = "Zaz")

    sslThreadModel th = SexLab.NewThread()
    th.AddActor( SexParticipant[0])
    th.AddActor( SexParticipant[1])
    th.SetAnimations(SexAnimationList)
    th.DisableLeadIn(true)
    th.StartThread()

This just fires a question. I assume the easy function StartSex() will use the same thread as the script which runs it, resulting in blocking any code following after as long as the animations aren't finished. When I use the ThreadController, it will start a new thread and following code will be executed. If I assume it right, is there a way to put my script into a loop while the SexLab thread is running?

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use