This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-05-21 03:43:16

lestrade3333
Scratcher
Registered: 2008-05-21
Posts: 18

One time message - actions

The problem is thus:

I have a background sprite which, when touch by the player's one, broadcasts a message. when the message is received, a sprite (a dialogue box for storyline) appears. The problem is, there are indefinite times which the player sprite may touch the background sprite, depending on the player's own decision and control. However, I only want the storyline box to appear on the first time the message is received. Is there a way to do this?

If not, the dialogue box appears all over again, which disrupts the storyline and annoys the player.

Thanks very much. I am really stuck at the moment. Any advise is appreciated.

Offline

 

#2 2008-05-21 04:46:31

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: One time message - actions

Hi lestrade3333,

looks like you might want to try experimenting with a variable. How about a local variable that remembers if the dialog box has been shown? You could name it something like "shown", initialize with one value (like  0), and set it to something else (like 1) the first time it is displayed. Then you could either check that variable before broadcasting the message, or let your dialog box sprite appear only if the variable is still in its initial state.

I hope I didn't make this explanation too complicated, please feel free to ask again if I didn't make myself clear.


Jens Mönig

Offline

 

#3 2008-05-21 10:25:18

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: One time message - actions

One method would be usign a "wait until" script.

On green flag
Wait until touching (other sprite)
   Broadcast "Show Message Box"

That way, it will only appear the 1st time.

You might want to put in a short delay before the "wait until" part, to make sure it doesn't trigger straight away if the previous game was interupted with the player sprite touching the background sprite in question.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#4 2008-05-21 10:51:12

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: One time message - actions

I answered in the other thread:^http://scratch.mit.edu/forums/viewtopic.php?id=5603

Please; one thread is enough...


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#5 2008-05-27 23:25:48

lestrade3333
Scratcher
Registered: 2008-05-21
Posts: 18

Re: One time message - actions

Thanks folks, it worked. However, it still feels slightly redundunt to make a new variable every time...

Offline

 

#6 2008-05-28 05:01:37

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: One time message - actions

lestrade3333 wrote:

Thanks folks, it worked. However, it still feels slightly redundunt to make a new variable every time...

Mayhem's method (described above) using the Wait Until block would not require any variables and would only fire once.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer