Jump to content

Make ShowMessage only show once?


Thacker

Recommended Posts

I'm running into a problem with my current script. I have it showing a different message for each of 4 different states. Whenever a state changes it correctly shows the new, relevant message. Unfortunately, since the script runs every 2 seconds, the messages are showing up every 2 seconds. It's not game breaking, but it is annoying.

 

I tried making the messages show only once by doing a

If MsgToggle == 1
ShowMessage Message01
set MsgToggle to 0

 

But the problem I run into is resetting MsgToggle at the start of each state, thus resulting in MsgToggle always equally 1 and the message always showing.

 

I'm pretty sure there is a fairly simple way to do this. Sadly I cannot figure it out. Thus, help would be most appreciated.

 

Thanks!

Link to comment
Share on other sites

It isn't quite clear what you mean by a "state" here. Many scripts use the technique of setting a "DoOnce" variable successfully. For scripts such as quest scripts, the variables are persistent, which means that the value set at the end of one script execution is still there at the start of the next execution. I am not sure why you are finding variables "non persistent". Can you describe a little bit more about your script? If it is not huge, can you post it with [ code ] and/or [ spoiler ] tags so we can see?
Link to comment
Share on other sites

If you are tracking 4 states, you should add some code so that MSgToggles don't get reset until a state changes. Its hard to be more specific without seeing more of your script but maybe something like this will help:

 

short iCurrentState
short iPrevState

Begin GameMode

;=================
;Code here to determine what iCurrentState is


if iCurrentState == iPrevState
else	;do nothing if no change

	if iCurrentState == 1
		showmessage State1
	elsif iCurrentState == 2
		showmessage State2
	elseif iCurrentState == 3
		showmessage State3
	else
		showmessage State4
	endif

	set iPrevState to iCurrentState
	
endif

END

Link to comment
Share on other sites

It isn't quite clear what you mean by a "state" here. Many scripts use the technique of setting a "DoOnce" variable successfully. For scripts such as quest scripts, the variables are persistent, which means that the value set at the end of one script execution is still there at the start of the next execution. I am not sure why you are finding variables "non persistent". Can you describe a little bit more about your script? If it is not huge, can you post it with [ code ] and/or [ spoiler ] tags so we can see?

 

No prob. I guess I was being overly paranoid and trying not to tip my hand, since (far as I know) this mod hasn't been released for NV and I was hoping to get it out there as my debut :happy:

 

Begin Gamemode

If condition1
Showmessage message1

ElseIf condition2
Showmessage message2

ElseIf condition3
Showmessage message3

ElseIf condition4
Showmessage message4

EndIf
End

 

The code as written works for my purposes. The problem is this is a quest script that is running constantly. Thus, every time it is run, a message appears. I would prefer for the message to only appear the first time one of the conditions are met, and then when a new condition is met, for it's message to only display once, etc.

 

Hope that makes sense.

Link to comment
Share on other sites

Short DoOnce

Begin GameMode
  if (condition1) && ( DoOnce == 0)
      set DoOnce to 1
  Elseifs/Elses

  EndIf
End

 

Thats the simple way of making a script run only once. If you ever want it to run again, you just need to set DoOnce to 0 elsewhere... It really depends on what you're trying to achieve.

 

Note, if this is a quest script, you can change DoOnce from another script by calling

 

Set MyQuest.DoOnce to 0

 

The quest needs the specific script (with the DoOnce short) attached.

Edited by PaladinRider
Link to comment
Share on other sites

  • Recently Browsing   0 members

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