TheWanderer001 Posted February 25, 2019 Share Posted February 25, 2019 I know OnActivate() detects when say a workbench is used but...How can I detect when they've stop using it ? I'm looking to add a temporary effect while they as still using the workbench... which is removed when they stop using it. Link to comment Share on other sites More sharing options...
xWilburCobbx Posted February 25, 2019 Share Posted February 25, 2019 I once provided you with a script that did something very similar to this, did you try GetSitState()? I believe it's general for all furniture, I could be wrong though. Link to comment Share on other sites More sharing options...
TheWanderer001 Posted February 25, 2019 Author Share Posted February 25, 2019 Thanks... didn't think of standing at a work bench as sitting :D The problem now is how can I use that to detect they've stopped using the bench.The onactive() triggers so do I put a loop to test for it inside that event ? Link to comment Share on other sites More sharing options...
TheWanderer001 Posted February 25, 2019 Author Share Posted February 25, 2019 Okay I think I have it working... Event OnActivate(ObjectReference akActionRef)Debug.notification("You feel a small tingle...");do extra stuff here...while (PlayerRef.GetSitState() != 0);Just sit here until they stop using the benchutility.wait(1)EndWhileDebug.notification("The tingling stops...");Stop doing extra stuffEndEvent Link to comment Share on other sites More sharing options...
Evangela Posted February 25, 2019 Share Posted February 25, 2019 Another way is this: https://www.creationkit.com/index.php?title=OnGetUp_-_Actor It'd have to be on the actor or alias though. Link to comment Share on other sites More sharing options...
TheWanderer001 Posted February 25, 2019 Author Share Posted February 25, 2019 Interesting but it's not on the actor it's on the workbench :( Link to comment Share on other sites More sharing options...
xWilburCobbx Posted February 26, 2019 Share Posted February 26, 2019 (edited) You always want to avoid latent functions with while loops, try something more like this: Scriptname WC_FurnitureCleanup extends ObjectReference {Constantly makes sure the furniture is in use before deleting itself. Written by Wilbur Cobb / smashballsx88} Actor property PlayerRef auto {Assign this to (any) cell, PlayerRef. This is faster then Game.GetPlayer(), it will be good for looping scripts.} Event OnInit() RegisterForSingleUpdate(4) ;It will begin the check loop in 4 seconds, this makes sure the player finishes entering the furniture before checking. EndEvent Event OnUpdate() if PlayerRef.GetSitState() != 3 ;Checks if the player is still using the furniture. (3 = Sitting) self.delete() else RegisterForSingleUpdate(4) ;Runs the loop every 4 seconds, you can increase this as you see fit. endif endEvent I gave you this before, you can change around what it does. RegisterForSingleUpdate() Isn't latent, it doesn't hold the script in the memory, it just fires the OnUpdate() event when the timer finishes. Edited February 26, 2019 by smashballsx88 Link to comment Share on other sites More sharing options...
TheWanderer001 Posted February 26, 2019 Author Share Posted February 26, 2019 (edited) Hmm.... you keep saying you gave me a script before...sorry I have no recollection of such a script ??? So anyway from what you show, to do what I'm after is this correct ? Scriptname TWEnchantTable extends ObjectReference Actor Property PlayerRef AutoEvent OnActivate(ObjectReference akActionRef) Debug.notification("You feel a tingle while using the enchanter...");Do my extra stuff here RegisterForSingleUpdate(4) ;It will begin the check loop in 4 seconds, this makes sure the player finishes entering the furniture before checking. EndEventEvent OnUpdate() if PlayerRef.GetSitState() != 3 ;Checks if the player is still using the furniture. (3 = Sitting) Debug.notification("The tingling stops...") ;Stop doing extra stuff else RegisterForSingleUpdate(2) ;Runs the loop every 2 seconds, you can increase this as you see fit. endifendEvent Okay test this and it works... thanks :) Edited February 26, 2019 by The-Wanderer Link to comment Share on other sites More sharing options...
Recommended Posts