Jump to content

Photo

How to make a trigger script activate once?

skyrim help script sck

  • Please log in to reply
5 replies to this topic

#1
wilwhitt56

wilwhitt56

    Fan

  • Members
  • PipPipPip
  • 304 posts

Made a script for a triggerbox that activates a message, but ran into a snag. The triggerbox works, but it spams the message until you get out of it. What script do I need to use to make it activate only once? 



#2
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 10,438 posts

You can use a bool variable to prevent a portion of the event from running again.

You can use states to completely avoid the event at subsequent times.

 

However, it would be best if we could see the script code in question along with the precise behavior you want.



#3
wilwhitt56

wilwhitt56

    Fan

  • Members
  • PipPipPip
  • 304 posts

Spoiler
 
Just wanting it so that when you walk through it a message pops up and activates just once, and that's it.

Edited by wilwhitt56, 24 January 2022 - 10:32 PM.


#4
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 10,438 posts

Use OnTriggerEnter as opposed to OnTrigger.  OnTrigger will keep spamming like crazy while the object that triggered it remains inside..  OnTriggerEnter will do it only when the trigger is entered.  But alone it will continue to trigger with each entry into the trigger.

 

If you do not need the trigger for anything else, you can have it disable itself.

 

See if the following works for you (please test re-entering the trigger area multiple times).  Also be sure to test on a new game or a game that has not seen this trigger at the very least.

Spoiler


#5
wilwhitt56

wilwhitt56

    Fan

  • Members
  • PipPipPip
  • 304 posts

Use OnTriggerEnter as opposed to OnTrigger.  OnTrigger will keep spamming like crazy while the object that triggered it remains inside..  OnTriggerEnter will do it only when the trigger is entered.  But alone it will continue to trigger with each entry into the trigger.

 

If you do not need the trigger for anything else, you can have it disable itself.

 

See if the following works for you (please test re-entering the trigger area multiple times).  Also be sure to test on a new game or a game that has not seen this trigger at the very least.

Spoiler

Yep it's working. I'm assuming self.disable() means it turns off the trigger when it's done, but what does Utility.Wait(0.25) do? 



#6
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 10,438 posts

It probably isn't needed.  But I didn't want to risk any possible issues with timing.  You could test without if you wish.







Also tagged with one or more of these keywords: skyrim, help, script, sck

IPB skins by Skinbox
Page loaded in: 1.102 seconds