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

#1 2010-09-17 15:38:19

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Sprite saying things help

How do I make a sprite say something from Squeak. I'm making an easter egg where the sprite says stuff.

The say code is say:duration:elapsed:from:

What do I put for elapsed and from? Say is what they say, and duration is how long they say it.

Offline

 

#2 2010-09-17 17:40:52

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Sprite saying things help

Look in the method to find out.  wink


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#3 2010-09-17 18:30:50

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

MathWizz wrote:

Look in the method to find out.  wink

I did. Also, the blockspec doesn't give it anything to say, so when I put in nil, it didn't do anything.

Offline

 

#4 2010-09-17 19:18:58

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Sprite saying things help

Do this:

Code:

self say: 'Insert easter egg message here'.
Delay waitMSecs: 2000. "Just replace 2000 with the number of seconds you want the message to be up * 1000."
self sayNothing.

The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#5 2010-09-18 02:27:55

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Sprite saying things help

rubiks_cube_guy238 wrote:

Do this:

Code:

self say: 'Insert easter egg message here'.
Delay waitMSecs: 2000. "Just replace 2000 with the number of seconds you want the message to be up * 1000."
self sayNothing.

I really was about to suggest that  smile

Offline

 

#6 2010-09-18 07:43:38

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Sprite saying things help

LS97 wrote:

rubiks_cube_guy238 wrote:

Do this:

Code:

self say: 'Insert easter egg message here'.
Delay waitMSecs: 2000. "Just replace 2000 with the number of seconds you want the message to be up * 1000."
self sayNothing.

I really was about to suggest that  smile

Haha. I've had moments like that (about to post something that's already been said) before in the forums. It's time for me to get even  tongue


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#7 2010-09-18 13:33:39

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Sprite saying things help

Doesnt delay stop eveything?


You can now reach me on Twitter @johnnydean1_

Offline

 

#8 2010-09-18 17:02:26

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

There's a problem. It has an error that the primitive failed and doesn't react. I think that the reason is that it's a really long easter egg and it says multiple things.

Offline

 

#9 2010-09-21 06:55:13

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

bump

Offline

 

#10 2010-09-21 07:14:56

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

Re: Sprite saying things help

it's a timed block, which needs to be called from within a ScratchProcess. For your easter egg I'd recommend using just the plain form: #say:


Jens Mönig

Offline

 

#11 2010-09-21 15:13:47

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

Jens wrote:

it's a timed block, which needs to be called from within a ScratchProcess. For your easter egg I'd recommend using just the plain form: #say:

The problem is that it's really long and needs to do 'say:' multiple times.

Offline

 

#12 2010-09-21 15:25:09

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Sprite saying things help

I would have an array of pairs, like

#(
('Hello, there!' 2)
('I am Sprite1!' 2.5)
)

and go through them with a whileTrue loop, using duration:elapsed:from: with the timer.


nXIII

Offline

 

#13 2010-09-22 07:46:22

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

nXIII wrote:

I would have an array of pairs, like

#(
('Hello, there!' 2)
('I am Sprite1!' 2.5)
)

and go through them with a whileTrue loop, using duration:elapsed:from: with the timer.

How would I plug them in to the say part?

Offline

 

#14 2010-09-22 12:36:16

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Sprite saying things help

Billybob-Mario wrote:

nXIII wrote:

I would have an array of pairs, like

#(
('Hello, there!' 2)
('I am Sprite1!' 2.5)
)

and go through them with a whileTrue loop, using duration:elapsed:from: with the timer.

How would I plug them in to the say part?

I was suggesting that you code that part for yourself  smile


nXIII

Offline

 

#15 2010-09-22 18:43:04

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

nXIII wrote:

Billybob-Mario wrote:

nXIII wrote:

I would have an array of pairs, like

and go through them with a whileTrue loop, using duration:elapsed:from: with the timer.

How would I plug them in to the say part?

I was suggesting that you code that part for yourself  smile

I tried

Code:

easterEgg
| message|

message _  #(
    ('message part 1' 2) ('' .1) ('message part 2' 2) ('' .1)
    ).

[:v |
    self say: ((lyrics at: v) at: 1).
    Delay waitMSecs: (((lyrics at: v) at: 2) * 1000)
]

And it had no effect. What's wrong?

(Note: I changed the parts that would give it away, because it's a secret.)

Edit: I found a problem, and I fixed it in the code above, but it still doesn't work.

Last edited by Billybob-Mario (2010-09-22 19:01:45)

Offline

 

#16 2010-09-22 19:23:00

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Sprite saying things help

Billybob-Mario wrote:

nXIII wrote:

Billybob-Mario wrote:


How would I plug them in to the say part?

I was suggesting that you code that part for yourself  smile

I tried

Code:

easterEgg
| message|

message _  #(
    ('message part 1' 2) ('' .1) ('message part 2' 2) ('' .1)
    ).

[:v |
    self say: ((lyrics at: v) at: 1).
    Delay waitMSecs: (((lyrics at: v) at: 2) * 1000)
]

And it had no effect. What's wrong?

(Note: I changed the parts that would give it away, because it's a secret.)

Edit: I found a problem, and I fixed it in the code above, but it still doesn't work.

You have an empty block; try using "messages do: [...]"


nXIII

Offline

 

#17 2010-09-23 14:42:23

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

nXIII wrote:

Billybob-Mario wrote:

nXIII wrote:


I was suggesting that you code that part for yourself  smile

I tried

Code:

easterEgg
| message|

message _  #(
    ('message part 1' 2) ('' .1) ('message part 2' 2) ('' .1)
    ).

[:v |
    self say: ((lyrics at: v) at: 1).
    Delay waitMSecs: (((lyrics at: v) at: 2) * 1000)
]

And it had no effect. What's wrong?

(Note: I changed the parts that would give it away, because it's a secret.)

Edit: I found a problem, and I fixed it in the code above, but it still doesn't work.

You have an empty block; try using "messages do: [...]"

I don't know what that means, but I found and fixed another problem. I needed to add an ifAbsent: [^ self] to each at:. It still doesn't work.

Offline

 

#18 2010-09-23 15:58:39

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Sprite saying things help

Billybob-Mario wrote:

nXIII wrote:

Billybob-Mario wrote:

I tried

Code:

easterEgg
| message|

message _  #(
    ('message part 1' 2) ('' .1) ('message part 2' 2) ('' .1)
    ).

[:v |
    self say: ((lyrics at: v) at: 1).
    Delay waitMSecs: (((lyrics at: v) at: 2) * 1000)
]

And it had no effect. What's wrong?

(Note: I changed the parts that would give it away, because it's a secret.)

Edit: I found a problem, and I fixed it in the code above, but it still doesn't work.

You have an empty block; try using "messages do: [...]"

I don't know what that means, but I found and fixed another problem. I needed to add an ifAbsent: [^ self] to each at:. It still doesn't work.

This:

[:v |
    self say: ((lyrics at: v) at: 1).
    Delay waitMSecs: (((lyrics at: v) at: 2) * 1000)
]

is an unused block. (sorry, that's what I meant)
I was suggesting you use this:

messages do: [:v |
    ...
]

Last edited by nXIII (2010-09-23 15:59:57)


nXIII

Offline

 

#19 2010-09-23 17:41:16

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

nXIII wrote:

This:

[:v |
    self say: ((lyrics at: v) at: 1).
    Delay waitMSecs: (((lyrics at: v) at: 2) * 1000)
]

is an unused block. (sorry, that's what I meant)
I was suggesting you use this:

messages do: [:v |
    ...
]

Do you mean like this?

Code:

message do: [:v |
    self say: ((message at: v) at: 1).
    Delay waitMSecs: (((message at: v) at: 2) * 1000)
]

There's a problem with that: the sprite needs to say the message.

Last edited by Billybob-Mario (2010-09-23 17:59:59)

Offline

 

#20 2010-09-23 18:06:57

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Sprite saying things help

Billybob-Mario wrote:

There's a problem with that: the sprite needs to say the message.

What are you talking about?


nXIII

Offline

 

#21 2010-09-23 19:39:48

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

nXIII wrote:

Billybob-Mario wrote:

There's a problem with that: the sprite needs to say the message.

What are you talking about?

An array can't say the message. Only sprites can 'say' things. How can I plug in messages do: [v:...
to self say:?

Offline

 

#22 2010-09-23 20:45:17

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Sprite saying things help

Billybob-Mario wrote:

nXIII wrote:

Billybob-Mario wrote:

There's a problem with that: the sprite needs to say the message.

What are you talking about?

An array can't say the message. Only sprites can 'say' things. How can I plug in messages do: [v:...
to self say:?

....what? self is a sprite in that context if it's a ScratchSpriteMorph message....

Last edited by nXIII (2010-09-23 20:45:49)


nXIII

Offline

 

#23 2010-09-24 06:52:54

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

nXIII wrote:

Billybob-Mario wrote:

nXIII wrote:


What are you talking about?

An array can't say the message. Only sprites can 'say' things. How can I plug in messages do: [v:...
to self say:?

....what? self is a sprite in that context if it's a ScratchSpriteMorph message....

You can't do

Code:

mesages do: [v:
self say: 'something'
]

Because messages is an array of some sort, and they can't say things.

Offline

 

#24 2010-09-25 15:34:15

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Sprite saying things help

Billybob-Mario wrote:

nXIII wrote:

Billybob-Mario wrote:

An array can't say the message. Only sprites can 'say' things. How can I plug in messages do: [v:...
to self say:?

....what? self is a sprite in that context if it's a ScratchSpriteMorph message....

You can't do

Code:

mesages do: [v:
self say: 'something'
]

Because messages is an array of some sort, and they can't say things.

self is not the block; blocks don't modify the context to include themselves as "self"
self still refers to the sprite

Last edited by nXIII (2010-09-25 15:34:24)


nXIII

Offline

 

#25 2010-09-26 13:33:21

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Sprite saying things help

nXIII wrote:

Billybob-Mario wrote:

nXIII wrote:


....what? self is a sprite in that context if it's a ScratchSpriteMorph message....

You can't do

Code:

mesages do: [v:
self say: 'something'
]

Because messages is an array of some sort, and they can't say things.

self is not the block; blocks don't modify the context to include themselves as "self"
self still refers to the sprite

I fixed a few things, and it said that a pirimitave failed and stopped responding.

Offline

 

Board footer