Jump to content

(Solved) Help with Sexlab scripting and hooks


Recommended Posts

Posted (edited)

Hi, i need some help with Sexlab scripting.
When i try, lets say to display a message after a sexlab scene, the message triggers at the start of the scene. So im trying to find a solution to delay the next actions of the script after the scene ends. So i looked on hooks.
Here is an example script.

 


;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 2
Scriptname TIF__02001845sexlabtestthreadhook Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_1
Function Fragment_1(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
sslThreadModel thread = SexLab.NewThread()

thread.AddActor(Game.GetPlayer())
thread.AddActor(akSpeaker)
Thread.SetHook("MyHook")
RegisterForModEvent("HookAnimationEnd_MyHook", "myAnimEndEventHandler")

sslBaseAnimation[] anims
anims = new sslBaseAnimation[1]
anims[0] = SexLab.AnimSlots.GetbyRegistrar("LeitoKissing")
thread.SetAnimations(anims)

bool[] nullMask = new bool[33]
nullMask[0] = true
thread.SetStrip(Game.GetPlayer(), nullMask)
thread.SetStrip(akSpeaker, nullMask)

thread.DisableLeadIn()

thread.StartThread()
;EVERYTHING COMPILES AND WORKS FINE UNTIL HERE!!!


;HERE IS THE PROBLEMATIC PART!!!!
Event myAnimEndEventHandler(int tid, bool HasPlayer)
utility.Wait(1.00000)
debug.messagebox("Hi,scene ended.")
EndEvent
;UNTIL HERE!!!!!

;END CODE
EndFunction

;IF I PUT THE EVENT HERE IT COMPILES BUT IT STILL DOESNT WORK!!!!

;END FRAGMENT
;END FRAGMENT CODE - Do not edit anything between this and the begin comment
SexLabFramework Property SexLab auto
 

I cant put the event in the "End:Papyrus Fragment" little square (inside the function).
If i put the event after the EndFunction in the "\script name\edit source" of the topic info window it compiles. 
On the Topic info window after i have to press cancel and close it, otherwise the text in the End:Papyrus Fragment window will replace the "edit source" Script. 
But even if i do that it still doesnt work in game.

Does anyone know what i need to do?

Edited by shadowman2777
Posted

It's been a while since I touched Papyrus but I'd say doing this in a fragment script is the wrong way to go about it. The way I did it with SLAF is that I have a start game enabled Quest with a script "SLAF_Controller_Script" attached to it. In the Dialogue End Fragment, I have a Property "SLAF_Controller_Script Property Controller Auto" and call a function on that "Controller.DialogueSex(akSpeakerRef as Actor)". The DialogueSex function then actually starts the scene through a SL Thread and in your case subscribes to the Event and would also react to it. I don't think fragments are supposed to have as much of a lifetime as you need.

Posted (edited)

Hi, thanks for the feedback. I took a look at your mod and i tried to figure it out but its quite out of my league >_<

So i created a script, in the end of the quest tab, like in my previous post as such

 

 


Scriptname ABCD_TEST_TEST extends Quest  

Function ABCDTEST(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
sslThreadModel thread = SexLab.NewThread()

thread.AddActor(Game.GetPlayer())
thread.AddActor(akSpeaker)
Thread.SetHook("MyHook")
RegisterForModEvent("HookAnimationEnd_MyHook", "myAnimEndEventHandler")

sslBaseAnimation[] anims
anims = new sslBaseAnimation[1]
anims[0] = SexLab.AnimSlots.GetbyRegistrar("LeitoKissing")
thread.SetAnimations(anims)

thread.StartThread()

EndFunction


Event myAnimEndEventHandler(int tid, bool HasPlayer)
utility.Wait(1.00000)
debug.messagebox("Hi,scene ended.")
EndEvent

SexLabFramework Property SexLab auto
 

 

 

It compiled successfully. Now how do i call it from a dialogue fragment? 

I tried 

 

controller.abdctest(akSpeakerRef as Actor)

 

but i got errors

 

variable controller is undefined
none is not a known user-defined type

 

And how do i call for the event too in the fragment?

Edited by shadowman2777
Posted

Hey there, you'd call the ABCDTEST() function the same way you called SexLab functions in your original fragment.

In your fragment, create a property of type ABCD_TEST_TEST and link it to the Quest ABCD_TEST_TEST is attached to in the property manager.

ABCD_TEST_TEST Property Controller Auto

Then you can call functions of Controller.

Controller.ABCDTEST(akSpeakerRef)

 

21 hours ago, shadowman2777 said:

And how do i call for the event too in the fragment?

I'm not sure what you mean with this, but you register and react to the AnimationEnd event in your ABCD_TEST_TEST script already, no need to do anything other than call ABCDTEST() and pass the ObjectReference to it.

Posted

One more problem 

When i try to replace

 

anims[0] = SexLab.AnimSlots.GetbyRegistrar("LeitoKissing")

with

anims[0] = SexLab.GetAnimationsByTag(2, "Cowgirl, Missionary, doggy", RequireAll=False, tagSuppress="Forced")

 

it doesnt compile, what is wrong there?

 

Edit: It turned out i had to make the second line

anims = SexLab.GetAnimationsByTag(2, "Cowgirl, Missionary, doggy", RequireAll=False, tagSuppress="Forced")

 

I think im all done, Thanks again!

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
  • Recently Browsing   0 members

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