Jump to content

Bool property to show/do things once


antstubell

Recommended Posts

Rusty at scripting and I've forgot how to do this. Make the script below show the notification once using a bool property. I know I can use global variables but this seems wasteful for just one instance and I don't want a load of variables just for this purpose.

Thank you.

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

if akOldContainer && !akNewContainer
Debug.Notification("I’ve have been dropped and will disappear.")
Self.Delete()

EndIf
EndEvent

 

Link to comment
Share on other sites

This uses a local bool variable rather than a property, but can be changed to a property if needed.

 

Bool DoOnce = false

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
  If (DoOnce == false) && (akOldContainer && !akNewContainer)
    Debug.Notification("I’ve have been dropped and will disappear.")
    Self.Delete()
    DoOnce = true
  EndIf
EndEvent

 

 

If this were a more often ran event, you could use the state approach and change states such that nothing will be done when the event is triggered.

Link to comment
Share on other sites

Helps to know intent...

 

This should do what you want

 

 

Bool DoOnce = false

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
  If (akOldContainer && !akNewContainer)
    If (DoOnce == false)
      Debug.Notification("I’ve have been dropped and will disappear.")
      DoOnce = true
    EndIf
    Self.Delete()
  EndIf
EndEvent 

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...