Jump to content

How to get the tags from an active animation?


Recommended Posts

How would I go about getting the tags from an animation? I'm very new to Papyrus, and while I'm figuring out how to hook into SL events, I don't know how I could get the animation tags from those events. Is there an efficient way to do this? Any help would be appreciated.

Link to comment

The most straightforward solution would be to hook into an AnimationStart event that gets sent out when a sex animation starts. You create an event handler, and you can pluck the currently playing animation out of the animation thread.

 

In script form, it looks something like this:

Scriptname AnimationCheckScript extends Quest

;add Sexlab as a property, remember to fill it out in the script properties
SexLabFramework Property SexLab Auto

;event handlers need to be registered for the events they handle
Function RegisterForEvents()
	RegisterForModEvent( "AnimationStart", "OnAnimationStart" )
EndFunction

;will run when the quest is first started
;registering for events is recommended to be called each time a save game is loaded
;recommend attaching a script to an alias that contains the player that calls RegisterForEvents in an OnPlayerLoadGame event too
Event OnInit()
	RegisterForEvents()
EndEvent

;the event handler that is fired when the event we registered for is sent out by Sexlab
Event OnAnimationStart( Int ThreadID, Bool HasPlayer )
	;get the animation of the current thread only if the player is involved in it
	If HasPlayer
		sslBaseAnimation Anim = SexLab.HookAnimation( ThreadID )
		;show it in a notification in the top left corner
		Debug.Notification( "Animation tags: " + Anim.GetTags() )
	EndIf
EndEvent

 

It's a bit rough, but I think you get the idea.

 

Edited by Taki17
Link to comment

So far, everything seems to be working except the Anim.GetTags() function. The debug notification just says "Animation tags: []", even though there are definitely tags on the animation. Any ideas? Thanks for the help.

Link to comment
14 hours ago, chunga69 said:

The debug notification just says "Animation tags: []", even though there are definitely tags on the animation. Any ideas?

I may have overlooked that the GetTags function returns a string array. That's perfect if you want to process it further in scripts, but not so much if you want to display it. Easiest solution then would be to convert it into a string.

Event OnAnimationStart( Int ThreadID, Bool HasPlayer )
	;get the animation of the current thread only if the player is involved in it
	If HasPlayer
		sslBaseAnimation Anim = SexLab.HookAnimation( ThreadID )

		;get the number of tags on this animation
		Int TagsArrayLength = Anim.GetTags().Length
		
		;concatenate the elements into a string to be displayed
		String AnimTags = ""
		Int i = 0
		While i < TagsArrayLength
			AnimTags += ( Anim.GetTags()[i] + "," )
          		i += 1
		EndWhile

		;show it in a notification in the top left corner
		Debug.Notification( "Animation tags: " + AnimTags )
	EndIf
EndEvent
Edited by Taki17
Link to comment

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...

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