Sargrifal Posted December 26, 2021 Share Posted December 26, 2021 (edited) Hello everyone, I trying to start writing scripts, and still newbie, so have trouble with it)Tried to make script which make NPC or Player playing animations when they are equipe Item until then it was unequipped, but I failed at compile, can someone help with right looking script? Scriptname FluidAnims extends ObjectReference ObjectReference Property fluid AutoActor Property PlayerRef Auto Event OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference)If akBaseObject == EFfluidSendAnimationEvent(PlayerRef, "EFFstop")EndIfUtility.Wait(20) PlayerRef.PlayIdle(IdleStop_Loose) EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)If akBaseObject == EFfluidSendAnimationEvent(PlayerRef, "EFF")EndIfUtility.Wait(20) PlayerRef.PlayIdle(IdleStop_Loose) EndEvent And compile failed because: Starting 1 compile threads for 1 files...Compiling "FluidAnims"...D:\Skyrim SE\Data\Source\Scripts\temp\FluidAnims.psc(8,0): SendAnimationEvent is not a function or does not existD:\Skyrim SE\Data\Source\Scripts\temp\FluidAnims.psc(11,19): variable IdleStop_Loose is undefinedD:\Skyrim SE\Data\Source\Scripts\temp\FluidAnims.psc(16,0): SendAnimationEvent is not a function or does not existD:\Skyrim SE\Data\Source\Scripts\temp\FluidAnims.psc(19,19): variable IdleStop_Loose is undefinedNo output generated for FluidAnims, compilation failed. Edited December 26, 2021 by colourtemp3000 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 26, 2021 Share Posted December 26, 2021 Unless a script that contains a desired function is imported in the empty state, it needs to have the host script called so that papyrus knows where to look for the desired function You can use one of the following: Import Debug ;goes in the empty state where properties are definedor Debug.SendAnimationEvent(SomeObjectRef,"SomeAnimation") ;goes inside a function or event Link to comment Share on other sites More sharing options...
Sargrifal Posted December 27, 2021 Author Share Posted December 27, 2021 T Hello everyone, I trying to start writing scripts, and still newbie, so have trouble with it)Tried to make script which make NPC or Player playing animations when they are equipe Item until then it was unequipped, but I failed at compile, can someone help with right looking script? Scriptname FluidAnims extends ObjectReference ObjectReference Property fluid AutoActor Property PlayerRef Auto Event OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference)If akBaseObject == EFfluidSendAnimationEvent(PlayerRef, "EFFstop")EndIfUtility.Wait(20) PlayerRef.PlayIdle(IdleStop_Loose) EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)If akBaseObject == EFfluidSendAnimationEvent(PlayerRef, "EFF")EndIfUtility.Wait(20) PlayerRef.PlayIdle(IdleStop_Loose) EndEvent And compile failed because: Starting 1 compile threads for 1 files...Compiling "FluidAnims"...D:\Skyrim SE\Data\Source\Scripts\temp\FluidAnims.psc(8,0): SendAnimationEvent is not a function or does not existD:\Skyrim SE\Data\Source\Scripts\temp\FluidAnims.psc(11,19): variable IdleStop_Loose is undefinedD:\Skyrim SE\Data\Source\Scripts\temp\FluidAnims.psc(16,0): SendAnimationEvent is not a function or does not existD:\Skyrim SE\Data\Source\Scripts\temp\FluidAnims.psc(19,19): variable IdleStop_Loose is undefinedNo output generated for FluidAnims, compilation failed. Thank you, but "variable IdleStop_Loose is undefined" still here and script wont work, can you tell me why it can happened? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 27, 2021 Share Posted December 27, 2021 From the Creation Kit wiki notes on SendAnimationEvent: SendAnimationEvent uses "Anim Events" under the Idle Manager, not the IDs. For example, to make an actor play the animation of attacking left, you must use "AttackStartLeftHand", not "LeftHandAttack" (its ID). What this means is that you need to access the Idle Manager in the Creation Kit and find the correct animation. The editor ID of IdleStop_Loose will not work. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 28, 2021 Share Posted December 28, 2021 (edited) You should accept some papyrus rules. (1) your property name ObjectReference Property fluid Autodoes not match with next condition code If akBaseObject == EFfluid(2) using of next property Actor Property PlayerRef Autodoes not really make sense with your event codes, for example Event OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) If akBaseObject == EFfluid SendAnimationEvent(PlayerRef, "EFFstop") EndIf Utility.Wait(20) PlayerRef.PlayIdle(IdleStop_Loose) EndEvent You forget the actor check. By running your script code the player makes the animation always (regardeless which actor is wearing the special item) . (3) a long wait (here 20 seconds ingame time) within an OnObjectUnEquipped() or/and OnObjectEquipped() event is really bad Utility.Wait(20)Please avoid such waitings! (4) you cannot compare an OjectReference property with a BaseObject, it does not work! If akBaseObject == EFfluid(5) I changed your posted code sample as follow. Keep in mind: "Use a better unique scriptname to avoid any trouble with scripts from other mods!"colo_FluidAnimationScript ;Scriptname colo_FluidAnimationScript extends ObjectReference Scriptname colo_FluidAnimationScript extends Actor ; (7) added 2022-01-31 ; https://forums.nexusmods.com/index.php?/topic/10877768-help-with-scripting/ ObjectReference PROPERTY EFfluidRef auto ; the object we are looking for Idle PROPERTY IdleStop_Loose auto ; (6) added 2022-01-31, missing in older post ; -- EVENTs -- ;EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) ; (7) this event does not work for actor type ; IF (akNewContainer == Game.GetPlayer() as ObjectReference) ; gotoState("Waiting") ; ### STATE ### player got the item, observe equip now ; ELSE ; UnRegisterForUpdate() ; just in case ; gotoState("") ; ### STATE ### ; ENDIF ;ENDEVENT EVENT OnUpdate() Game.GetPlayer().PlayIdle(IdleStop_Loose) ; after 20 sec the item is wearing play vanilla stop animation Utility.Wait(0.1) ENDEVENT EVENT OnObjectEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject == EFfluidRef.GetBaseObject()) gotoState("WearItem") ; ### STATE ### myF_Action(1) RegisterForSingleUpdate(20.0) ; wait for 20 sec ENDIF ENDEVENT ;=================================== State WearItem ;============= EVENT OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject == EFfluidRef.GetBaseObject()) UnRegisterForUpdate() gotoState("") ; ### STATE ### myF_Action(0) ENDIF ENDEVENT ;======= endState ; -- FUNCTION -- ;------------------------- FUNCTION myF_Action(Int i) ;------------------------- IF ( i ) ; i == 1 Debug.SendAnimationEvent(Game.GetPlayer(), "EFF") ; if item equipped play special animation ELSE ; i == 0 Debug.SendAnimationEvent(Game.GetPlayer(), "EFFstop") ; if item will be un-equipped play special stop animation ENDIF ENDFUNCTION (6) Idle property was missing as well Idle PROPERTY IdleStop_Loose auto ; added 2022-01-31, missing in older post(7) scriptname was wrong type extending Scriptname colo_FluidAnimationScript extends Actor ; changed 2022-01-31 Edited January 31, 2022 by ReDragon2013 Link to comment Share on other sites More sharing options...
Sargrifal Posted January 16, 2022 Author Share Posted January 16, 2022 You should accept some papyrus rules. (1) your property name ObjectReference Property fluid Autodoes not match with next condition code If akBaseObject == EFfluid(2) using of next property Actor Property PlayerRef Autodoes not really make sense with your event codes, for example Event OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) If akBaseObject == EFfluid SendAnimationEvent(PlayerRef, "EFFstop") EndIf Utility.Wait(20) PlayerRef.PlayIdle(IdleStop_Loose) EndEvent You forget the actor check. By running your script code the player makes the animation always (regardeless which actor is wearing the special item) . (3) a long wait (here 20 seconds ingame time) within an OnObjectUnEquipped() or/and OnObjectEquipped() event is really bad Utility.Wait(20)Please avoid such waitings! (4) you cannot compare an OjectReference property with a BaseObject, it does not work! If akBaseObject == EFfluid(5) I changed your posted code sample as follow. Keep in mind: "Use a better unique scriptname to avoid any trouble with scripts from other mods!"colo_FluidAnimationScript Scriptname colo_FluidAnimationScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/10877768-help-with-scripting/ ObjectReference PROPERTY EFfluidRef auto ; the object we are looking for ; -- EVENTs -- EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) IF (akNewContainer == Game.GetPlayer() as ObjectReference) gotoState("Waiting") ; ### STATE ### player got the item, observe equip now ELSE UnRegisterForUpdate() ; just in case gotoState("") ; ### STATE ### ENDIF ENDEVENT EVENT OnUpdate() Game.GetPlayer().PlayIdle(IdleStop_Loose) ; after 20 sec the item is wearing play vanilla stop animation Utility.Wait(0.1) ENDEVENT ;=================================== State Waiting ;============ EVENT OnObjectEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject == EFfluidRef.GetBaseObject()) gotoState("WearItem") ; ### STATE ### myF_Action(1) RegisterForSingleUpdate(20.0) ; wait for 20 sec ENDIF ENDEVENT ;======= endState ;=================================== State WearItem ;============= EVENT OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject == EFfluidRef.GetBaseObject()) UnRegisterForUpdate() gotoState("Waiting") ; ### STATE ### myF_Action(0) ENDIF ENDEVENT ;======= endState ; -- FUNCTION -- ;------------------------- FUNCTION myF_Action(Int i) ;------------------------- IF ( i ) ; i == 1 Debug.SendAnimationEvent(Game.GetPlayer(), "EFF") ; if item equipped play special animation ELSE ; i == 0 Debug.SendAnimationEvent(Game.GetPlayer(), "EFFstop") ; if item will be un-equipped play special stop animation ENDIF ENDFUNCTION Thank you very much, Ill try it soon, just backed from another country Link to comment Share on other sites More sharing options...
Sargrifal Posted January 31, 2022 Author Share Posted January 31, 2022 (edited) . Edited January 31, 2022 by colourtemp3000 Link to comment Share on other sites More sharing options...
Sargrifal Posted January 31, 2022 Author Share Posted January 31, 2022 (edited) You should accept some papyrus rules. (1) your property name ObjectReference Property fluid Autodoes not match with next condition code If akBaseObject == EFfluid(2) using of next property Actor Property PlayerRef Autodoes not really make sense with your event codes, for example Event OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) If akBaseObject == EFfluid SendAnimationEvent(PlayerRef, "EFFstop") EndIf Utility.Wait(20) PlayerRef.PlayIdle(IdleStop_Loose) EndEvent You forget the actor check. By running your script code the player makes the animation always (regardeless which actor is wearing the special item) . (3) a long wait (here 20 seconds ingame time) within an OnObjectUnEquipped() or/and OnObjectEquipped() event is really bad Utility.Wait(20)Please avoid such waitings! (4) you cannot compare an OjectReference property with a BaseObject, it does not work! If akBaseObject == EFfluid(5) I changed your posted code sample as follow. Keep in mind: "Use a better unique scriptname to avoid any trouble with scripts from other mods!"colo_FluidAnimationScript Scriptname colo_FluidAnimationScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/10877768-help-with-scripting/ ObjectReference PROPERTY EFfluidRef auto ; the object we are looking for Idle PROPERTY IdleStop_Loose auto ; added 2022-01-31, missing in older post ; -- EVENTs -- EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) IF (akNewContainer == Game.GetPlayer() as ObjectReference) gotoState("Waiting") ; ### STATE ### player got the item, observe equip now ELSE UnRegisterForUpdate() ; just in case gotoState("") ; ### STATE ### ENDIF ENDEVENT EVENT OnUpdate() Game.GetPlayer().PlayIdle(IdleStop_Loose) ; after 20 sec the item is wearing play vanilla stop animation Utility.Wait(0.1) ENDEVENT ;=================================== State Waiting ;============ EVENT OnObjectEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject == EFfluidRef.GetBaseObject()) gotoState("WearItem") ; ### STATE ### myF_Action(1) RegisterForSingleUpdate(20.0) ; wait for 20 sec ENDIF ENDEVENT ;======= endState ;=================================== State WearItem ;============= EVENT OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference) IF (akBaseObject == EFfluidRef.GetBaseObject()) UnRegisterForUpdate() gotoState("Waiting") ; ### STATE ### myF_Action(0) ENDIF ENDEVENT ;======= endState ; -- FUNCTION -- ;------------------------- FUNCTION myF_Action(Int i) ;------------------------- IF ( i ) ; i == 1 Debug.SendAnimationEvent(Game.GetPlayer(), "EFF") ; if item equipped play special animation ELSE ; i == 0 Debug.SendAnimationEvent(Game.GetPlayer(), "EFFstop") ; if item will be un-equipped play special stop animation ENDIF ENDFUNCTION (6) Idle property was missing as well Idle PROPERTY IdleStop_Loose auto ; added 2022-01-31, missing in older post@ReDragon2013 Thank your for PM answer, I already fixed "variable IdleStop_Loose is undefined", just before I send PM to you, I cant understand that D:\Skyrim SE\Data\Source\Scripts\temp\scriptname.psc(28,4): function onobjectequipped cannot be defined in state waiting without also being defined in the empty stateD:\Skyrim SE\Data\Source\Scripts\temp\scriptname.psc(42,4): function onobjectunequipped cannot be defined in state wearitem without also being defined in the empty state May be it is unnecessary to fix that, I dont know(and about script name I use "scriptname.psc" just like example, not exist name) Edited January 31, 2022 by colourtemp3000 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted January 31, 2022 Share Posted January 31, 2022 (edited) Hmm.. to get them work you have to change the script from extending objectReference into actor (I edited my previous posting)!But that is out of "good coding practice" for the player or any other unique vanilla actor.https://www.creationkit.com/index.php?title=OnObjectEquipped_-_Actor So we have to change the whole script as follow.https://www.creationkit.com/index.php?title=OnEquipped_-_ObjectReference colo_FluidAnimationScript v2 Scriptname colo_FluidAnimationScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/10877768-help-with-scripting/ ; version 2 Idle PROPERTY IdleStop_Loose auto ; added 2022-01-31, missing in older post ; -- EVENTs -- 2 + "Waiting" + "WearItem" EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) IF (akNewContainer == Game.GetPlayer() as ObjectReference) gotoState("Waiting") ; ### STATE ### player got the item, observe equip now ELSE UnRegisterForUpdate() ; just in case gotoState("") ; ### STATE ### ENDIF ENDEVENT EVENT OnUpdate() Game.GetPlayer().PlayIdle(IdleStop_Loose) ; after 20 sec the item is wearing, play vanilla stop animation Utility.Wait(0.1) ENDEVENT ;=================================== State Waiting ;============ EVENT OnEquipped(Actor akActor) gotoState("WearItem") ; ### STATE ### myF_Action(1) RegisterForSingleUpdate(20.0) ; wait for 20 sec ENDEVENT ;======= endState ;=================================== State WearItem ;============= EVENT OnUnEquipped(Actor akActor) UnRegisterForUpdate() gotoState("Waiting") ; ### STATE ### myF_Action(0) ENDEVENT ;======= endState ; -- FUNCTION -- ;------------------------- FUNCTION myF_Action(Int i) ;------------------------- IF ( i ) ; i == 1 Debug.SendAnimationEvent(Game.GetPlayer(), "EFF") ; if item equipped play special animation ELSE ; i == 0 Debug.SendAnimationEvent(Game.GetPlayer(), "EFFstop") ; if item will be un-equipped play special stop animation ENDIF ENDFUNCTION Edited January 31, 2022 by ReDragon2013 Link to comment Share on other sites More sharing options...
Sargrifal Posted January 31, 2022 Author Share Posted January 31, 2022 (edited) Hmm.. to get them work you have to change the script from extending objectReference into actor (I edited my previous posting)!But that is out of "good coding practice" for the player or any other unique vanilla actor.https://www.creationkit.com/index.php?title=OnObjectEquipped_-_Actor So we have to change the whole script as follow.https://www.creationkit.com/index.php?title=OnEquipped_-_ObjectReference colo_FluidAnimationScript v2 Scriptname colo_FluidAnimationScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/10877768-help-with-scripting/ ; version 2 Idle PROPERTY IdleStop_Loose auto ; added 2022-01-31, missing in older post ; -- EVENTs -- 2 + "Waiting" + "WearItem" EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) IF (akNewContainer == Game.GetPlayer() as ObjectReference) gotoState("Waiting") ; ### STATE ### player got the item, observe equip now ELSE UnRegisterForUpdate() ; just in case gotoState("") ; ### STATE ### ENDIF ENDEVENT EVENT OnUpdate() Game.GetPlayer().PlayIdle(IdleStop_Loose) ; after 20 sec the item is wearing, play vanilla stop animation Utility.Wait(0.1) ENDEVENT ;=================================== State Waiting ;============ EVENT OnEquipped(Actor akActor) gotoState("WearItem") ; ### STATE ### myF_Action(1) RegisterForSingleUpdate(20.0) ; wait for 20 sec ENDEVENT ;======= endState ;=================================== State WearItem ;============= EVENT OnUnEquipped(Actor akActor) UnRegisterForUpdate() gotoState("Waiting") ; ### STATE ### myF_Action(0) ENDEVENT ;======= endState ; -- FUNCTION -- ;------------------------- FUNCTION myF_Action(Int i) ;------------------------- IF ( i ) ; i == 1 Debug.SendAnimationEvent(Game.GetPlayer(), "EFF") ; if item equipped play special animation ELSE ; i == 0 Debug.SendAnimationEvent(Game.GetPlayer(), "EFFstop") ; if item will be un-equipped play special stop animation ENDIF ENDFUNCTION So, now script is compiled, thank you, BUT, it doesn't work)I made the test circlet and attach script to it, then equipped it on follower and PC, wait some time and nothing happens, mb I ,must not use vanilla animations like "idleWounded03", or mb I done smth wrong at another step, like error ar attaching script? Here is script which I used Scriptname CTP_objectAnims extends ObjectReference Idle PROPERTY IdleStop_Loose auto ; -- EVENTs -- 2 + "Waiting" + "WearItem" EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)IF (akNewContainer == Game.GetPlayer() as ObjectReference)gotoState("Waiting") ; ### STATE ### player got the item, observe equip nowELSEUnRegisterForUpdate() ; just in casegotoState("") ; ### STATE ###ENDIFENDEVENT EVENT OnUpdate()Game.GetPlayer().PlayIdle(IdleStop_Loose) ; after 20 sec the item is wearing, play vanilla stop animationUtility.Wait(0.1)ENDEVENT ;===================================State Waiting;============EVENT OnEquipped(Actor akActor)gotoState("WearItem") ; ### STATE ###myF_Action(1)RegisterForSingleUpdate(1.0) ; wait for 1 secENDEVENT;=======endState ;===================================State WearItem;=============EVENT OnUnEquipped(Actor akActor)UnRegisterForUpdate()gotoState("Waiting") ; ### STATE ###myF_Action(0)ENDEVENT;=======endState ; -- FUNCTION -- ;-------------------------FUNCTION myF_Action(Int i);-------------------------IF ( i ) ; i == 1Debug.SendAnimationEvent(Game.GetPlayer(), "IdleWounded03enterinstant") ; if item equipped play special animationELSE ; i == 0Debug.SendAnimationEvent(Game.GetPlayer(), "IdleWounded03Exit") ; if item will be un-equipped play special stop animationENDIFENDFUNCTION Edited January 31, 2022 by colourtemp3000 Link to comment Share on other sites More sharing options...
Recommended Posts