Complete Example Scripts: Difference between revisions

Jump to navigation Jump to search
m
→‎Creating a Simple Toggle: Optimized with bool hinge
imported>JustinOther
imported>JustinOther
m (→‎Creating a Simple Toggle: Optimized with bool hinge)
Line 18: Line 18:
===Creating a Simple Toggle===
===Creating a Simple Toggle===


<source lang="papyrus">
<source lang="papyrus">ScriptName SimpleToggle Extends ObjectReference
Scriptname SimpleToggle Extends ObjectReference


ObjectReference Property HouseProperty Auto
ObjectReference Property HouseProperty Auto
Int Toggle = 0 ; The toggle variable. Initial value is 0.
 
Bool bToggle ; The toggle variable. Initializes 'False'.


Event OnActivate(ObjectReference akActionRef)
Event OnActivate(ObjectReference akActionRef)
    If Toggle == 0 ;If Toggle is 0 (which it initially is) the...
bToggle = !bToggle ; Set Bool to whatever it's not
          HouseProperty.Enable() ;Enable your house!
If bToggle ; True
          Toggle = 1 ;Set Toggle to 1 to prevent miss-fires.
HouseProperty.Enable() ;Enable your house!
    Endif
Else ; False
    If Toggle == 1 ;If Toggle is 1 (which it gets set to after you activate it the first time) then...
HouseProperty.Disable() ;Disable your house!
          HouseProperty.Disable() ;Disable your house!
Endif
          Toggle = 0 ;Set Toggle to 0 to prevent miss-fires.
EndEvent</source>
    Endif
EndEvent
</source>


'''To make this script work''': Attach this script to an activator such as a button, lever, or container.
'''To make this script work''': Attach this script to an activator such as a button, lever, or container.


===A Quest item you can drop and pick up again and set or reset objectives and Stages.===
===A Quest item you can drop and pick up again and set or reset objectives and Stages.===
Anonymous user

Navigation menu