iamzip Posted July 24, 2020 Posted July 24, 2020 I'm working on a mod that as one of my options tracks some very basic sex data, specifically the number of "people" and the number of "creatures" the player has encounters with. On its face it seems like it should be really easy but I can't seem to get any variation of scripting to work. I started referencing the SexLabFramework script using Hook animation events and getcontroller, which looks like this: Spoiler RegisterForModEvent("HookAnimationEnd", "OnSexLabEnd") ;;; elsewhere Event OnSexLabEnd(Int tid, Bool HasPlayer) Int actorcount Int creaturecount Int peoplecount sslThreadController Thread = SexLab.GetController(tid) Actor[] Positions = Thread.Positions actorcount= Positions.Length as Int Debug.Notification("number of actors: " + actorcount) creaturecount = SexLab.CreatureCount(Positions) as Int Debug.Notification("number of creatures: " + creaturecount) peoplecount = Positions.Length - creaturecount - 1 ;; so player doesn't count towards total If(peoplecount < 0) peoplecount = 0 EndIf TotalPeople += peoplecount TotalCreatures += creaturecount EndEvent However at the end of any event it triggers but the number is always 0 for numActors and creaturecount. I even tried copying other people's script segments that used the deprecated code, which looked like this: Spoiler RegisterForModEvent("HookAnimationEnd", "OnSexLabEnd") ;;;; elsewhere Event OnSexLabEnd(Int tid, Bool HasPlayer) Int actorcount Int creaturecount Int peoplecount sslThreadController Thread = SexLab.GetController(tid) Actor[] Positions = Thread.Positions actorcount= Positions.Length as Int Debug.Notification("number of actors: " + actorcount) creaturecount = SexLab.CreatureCount(Positions) as Int Debug.Notification("number of creatures: " + creaturecount) peoplecount = Positions.Length - creaturecount - 1 ;; so player doesn't count towards total If(peoplecount < 0) peoplecount = 0 EndIf TotalPeople += peoplecount TotalCreatures += creaturecount EndEvent But this still doesn't result in anything but 0s in the output. Could somebody point me to what I'm missing? Barring this for some reason, is there a basic stat in SexLab that I could poll instead of tracking it myself? Thank you for any help.
Guest Posted July 24, 2020 Posted July 24, 2020 Probably because the SexLab thread controller is cleaned before your code runs. You can cache that data at HookAnimationStart and apply it at HookAnimationEnd, if for whatever reason, you don't want to apply it at AnimationStart. Also make sure to check for HasPlayer if this is supposed to be for the player only. RegisterForModEvent("HookAnimationStart", "OnSexLabStart") RegisterForModEvent("HookAnimationEnd", "OnSexLabEnd") int _TotalPeople int _TotalCreatures Event OnSexLabStart(int tid, bool HasPlayer) if !HasPlayer return endif sslThreadController slThread = SexLab.GetController(tid) if slThread != none _TotalPeople = slThread.Males + slThread.Females _TotalCreatures = slThread.Creatures if SexLab.GetGender(PlayerRef) >= 2 _TotalCreatures -= 1 else _TotalPeople -= 1 endif else _TotalPeople = 0 _TotalCreatures = 0 endif EndEvent Event OnSexLabEnd(int tid, bool HasPlayer) if !HasPlayer return endif TotalPeople += _TotalPeople TotalCreatures += _TotalCreatures EndEvent Or, if you are okay with using SexLab stats: RegisterForModEvent("HookAnimationEnd", "OnSexLabEnd") Event OnSexLabEnd(int tid, bool HasPlayer) if HasPlayer RegisterForSingleUpdate(5.0) ; Give it some time before we query stats. endif EndEvent Event OnUpdate() TotalPeople = SexLab.GetSkill(PlayerRef, "Males") + SexLab.GetSkill(PlayerRef, "Females") TotalCreatures = SexLab.GetSkill(PlayerRef, "Creatures") EndEvent P.S. Why are you casting ints into... ints?
iamzip Posted July 24, 2020 Author Posted July 24, 2020 That explains it, I was under the impression the data would be available at any of the animation events, didn't occur to me to try earlier hooks. Thank you. And for the logic, looks like some of my functions were entirely wrong. 42 minutes ago, Hawk9969 said: P.S. Why are you casting ints into... ints? Frustration
Recommended Posts
Archived
This topic is now archived and is closed to further replies.