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
MathWizz wrote:
Look in the method to find out.
![]()
I did. Also, the blockspec doesn't give it anything to say, so when I put in nil, it didn't do anything.
Offline
Do this:
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.
Offline
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
Offline
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
![]()
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
Offline
Doesnt delay stop eveything?
Offline
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
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
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
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
Offline
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
![]()
I tried
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
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
![]()
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: [...]"
Offline
nXIII wrote:
Billybob-Mario wrote:
nXIII wrote:
I was suggesting that you code that part for yourself![]()
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
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)
Offline
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?
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
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
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)
Offline
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
mesages do: [v: self say: 'something' ]
Because messages is an array of some sort, and they can't say things.
Offline
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)
Offline
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