Jump to content

Have a script run only once


bad biscut

Recommended Posts

It is a simple showmessage script activated by a trigger but whenever I walk into the trigger the message plays again. How do I get it to only show once?

If you need to keep the trigger the simpler way is to use a quest script variable, it is able to keep values between sessions, actually it works like a global variable for your mod.

 

Any quest in your mod can do the trick, you can use one already there or create a dummy one just to host the script. That quest does not even need to be active, you can just terminate it immediately.

 

To access the variable you need to prefix it with the quest name, like: set MyQuest.MyQuestVar to 1. Where the MyQuestVar is the variable defined inside the quest script.

 

To clarify, that variable can be accessed for read and write from any script inside your mod and is persistent, the value is not lost between game sessions.

Link to comment
Share on other sites

There's no need to use a global or remote variable for this - just use a local one. Here's my post from the other thread thread (this thread was double-posted):

Add a variable to store whether or not the message has been shown, and use a conditional statement to prevent it from being shown again:
int bDoOnce

Begin OnTriggerEnter player

if bDoOnce == 0
	set bDoOnce to 1
	ShowMessage MyMessage
endif

End

Cipscis

Link to comment
Share on other sites

There's no need to use a global or remote variable for this - just use a local one. Here's my post from the other thread thread (this thread was double-posted):
Add a variable to store whether or not the message has been shown, and use a conditional statement to prevent it from being shown again:
int bDoOnce

Begin OnTriggerEnter player

if bDoOnce == 0
	set bDoOnce to 1
	ShowMessage MyMessage
endif

End

Cipscis

are you sure? local variables loses the values between sessions and that may be what is happening to the OP.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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