Haagaar Posted April 4, 2020 Share Posted April 4, 2020 (edited) [EDIT] : Sorry if that topic already exists, I didn't found one when I searched. Hello everyone, I am very new to scripting, not only for papyrus. I went through a number of pages in the CK official wiki, various forums, checked built-in scripts, and so on. I think I pretty much understand the very basics of it. However I'm struggling with something : I'm on a player house mod of my own. I want to add a script to a "DweButton01" form (meaning not the base reference obviously) that will enable a form that's initially disabled. I came out with several tries but can't understand why the compiler rejects them. This is what I have written : Scriptname AHVA_PortalButtonScript extends ObjectReference{Enable or disable a linked reference when the player presses the button}Bool Property isEnabled = false auto hiddenEvent OnActivate(ObjectReference akActivator) If(isEnabled == false) ; Is the door enabled ? If akActivator == Game.GetPlayer() isEnabled = true self.getLinkedRef().Enable(true) ; Enables the door. EndIf Else isEnabled = false self.getLinkedRef().Disable(true) ; Disables the door. EndIfEndEvent Could someone kindly provide me with an example script please ? That would be greatly appreciated, and I could figure out what's wrong with whatever I'm doing. Thank you !! Edited April 4, 2020 by Haagaar Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 4, 2020 Share Posted April 4, 2020 (edited) IsEnabled is already a function defined on the ObjectReference script. As a result the compiler does not understand what you are trying to do when using a property variable of the same name. Below is an example that should perform what you want. Please note that it has not been tested for compilation or function. Scriptname AHVA_PortalButtonScript extends ObjectReference {Enable or disable a linked reference when the player presses the button} Event OnActivate(ObjectReference akActivator) If akActivator == Game.GetPlayer() If Self.GetLinkedRerf.IsDisabled() ; Is the door disabled ? self.getLinkedRef().Enable(true) ; Enables the door. Else self.getLinkedRef().Disable(true) ; Disables the door. EndIf EndIf EndEvent Edited April 4, 2020 by IsharaMeradin Link to comment Share on other sites More sharing options...
Haagaar Posted April 4, 2020 Author Share Posted April 4, 2020 (edited) Thank you for the very quick answer ! As usual with "beginners", the solution is easy and right in front of my nose haha ! Sorry for that.I just renamed the bool property to isEnabled_01, because your script does not compile (compiler says that the "isEnabled" variable is undefined). Again, thanks for the help ! Edited April 4, 2020 by Haagaar Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 4, 2020 Share Posted April 4, 2020 You don't need that bool property. It isn't being used unless you need it elsewhere to do other things depending upon the state of the door. I simply forgot to delete those two lines. I'll edit the previous posted code. Link to comment Share on other sites More sharing options...
Haagaar Posted April 4, 2020 Author Share Posted April 4, 2020 Anyway, I tweaked the script a little to add sound fx, here it is, if anyone needs it : Scriptname AHVA_PortalButtonScript extends ObjectReference {Enable or disable a linked reference when the player presses the button, with FX} ObjectReference Property DoortoEnable auto Sound Property DoorAppearFX auto Sound Property DoorDisappearFX auto Sound Property DoorLoopFX auto Event OnActivate(ObjectReference akActivator) If akActivator == Game.GetPlayer() If DoortoEnable.isDisabled() ; Is the door enabled ? DoorAppearFX.Play(Self) DoortoEnable.Enable(true) ; Enables the door. Else DoortoEnable.Disable(true) ; Disables the door. DoorDisappearFX.Play(Self) EndIf EndIf While DoortoEnable.isEnabled() DoorLoopFX.PlayAndWait(DoortoEnable) EndWhile EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts