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

#26 2010-09-26 14:21:50

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

Re: Sprite saying things help

Billybob-Mario wrote:

nXIII wrote:

Billybob-Mario wrote:

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.

What's the context?
Which primitive failed?
What are the values of the temp variables?


nXIII

Offline

 

#27 2010-09-26 18:01:28

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Sprite saying things help

[^ self say: 'lala']
delay waitMseconds: ()*1000
self sayNothing.
[^self say: 'part 2'
delay waitMseconds: ()*1000
self sayNothing.

That is what I would try.  big_smile


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#28 2010-09-26 18:34:53

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

Re: Sprite saying things help

nXIII wrote:

Billybob-Mario wrote:

nXIII wrote:


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.

What's the context?
Which primitive failed?
What are the values of the temp variables?

I think that the primitive is primSignal:atMilliseconds:. It's primitive 136.
I don't know the others, because it isn't responding.

Offline

 

#29 2010-09-26 20:19:34

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

Re: Sprite saying things help

Billybob-Mario wrote:

nXIII wrote:

Billybob-Mario wrote:

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

What's the context?
Which primitive failed?
What are the values of the temp variables?

I think that the primitive is primSignal:atMilliseconds:. It's primitive 136.
I don't know the others, because it isn't responding.

I would think you should do something like this:

| messages sum start ci cumL |
messages _ #(('Foo' 2) ('' 0.2) ('Bar' 3) ('Baz' 1)).
sum _ messages inject: 0 into: [:s :pair | s + pair second].
start _ Time millisecondClockValue.
ci _ 1.
cumL _ 0.
[start + sum > Time millisecondClockValue] whileTrue: [
    start + cumL + (messages at: ci) second > Time millisecondClockValue ifTrue: [
        self say: (messages at: ci) first.
    ] ifFalse: [
        cumL _ cumL + (messages at: ci) first.
        ci _ ci + 1.
    ].
].

instead of using delays.

Last edited by nXIII (2010-09-26 20:20:09)


nXIII

Offline

 

#30 2010-09-27 07:22:44

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

Re: Sprite saying things help

nXIII wrote:

Billybob-Mario wrote:

nXIII wrote:


What's the context?
Which primitive failed?
What are the values of the temp variables?

I think that the primitive is primSignal:atMilliseconds:. It's primitive 136.
I don't know the others, because it isn't responding.

I would think you should do something like this:

| messages sum start ci cumL |
messages _ #(('Foo' 2) ('' 0.2) ('Bar' 3) ('Baz' 1)).
sum _ messages inject: 0 into: [:s :pair | s + pair second].
start _ Time millisecondClockValue.
ci _ 1.
cumL _ 0.
[start + sum > Time millisecondClockValue] whileTrue: [
    start + cumL + (messages at: ci) second > Time millisecondClockValue ifTrue: [
        self say: (messages at: ci) first.
    ] ifFalse: [
        cumL _ cumL + (messages at: ci) first.
        ci _ ci + 1.
    ].
].

instead of using delays.

It just says the first one.

Offline

 

#31 2010-09-27 14:45:11

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

Re: Sprite saying things help

Billybob-Mario wrote:

It just says the first one.

SO GO DEBUG IT FOR YOURSELF! OH MY GOSH!
Seriously...


nXIII

Offline

 

#32 2010-09-27 18:00:52

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

Re: Sprite saying things help

nXIII wrote:

Billybob-Mario wrote:

It just says the first one.

SO GO DEBUG IT FOR YOURSELF! OH MY GOSH!
Seriously...

Pretty much every old person ever wrote:

If you don't have anything nice to say, don't say anything at all.

Offline

 

#33 2010-09-28 11:49:48

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Sprite saying things help

Yes, but debug it yourself. It can't be that hard.


/* No comment */

Offline

 

#34 2010-09-28 11:59:41

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

Re: Sprite saying things help

Ill have a go


You can now reach me on Twitter @johnnydean1_

Offline

 

#35 2010-09-28 12:43:13

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

Re: Sprite saying things help

Here:

| tosay waitTime time1 time2 time3 timeto length index say timee |
tosay := {'hi'.'hello'} as: OrderedCollection.
waitTime := {'1'.'2'} as: OrderedCollection.
length_ tosay size.
waitTime size < length
ifTrue: [
length_ waitTime size.
].
length _ length asNumber.

index_ 0.
index_ index asNumber.
length timesRepeat: [
index_ index + 1.

say_ tosay at: index.
say_ say asString.
timee_ waitTime at: index.
timee_ timee asNumber.

self say: say.

time3_ 0.
time1_ self timer.
timeto_ time1 + timee.
[ time1 < timeto ]
whileTrue: [
time2_ self timer.
time2 < time1
ifTrue: [
time3_ time1.
].
time1_ time3 + time2.

].
].

self say: ''.

tosay := {'hi'.'hello'} as: OrderedCollection.
waitTime := {'1'.'2'} as: OrderedCollection.
They are you say things.

Last edited by johnnydean1 (2010-09-28 12:43:35)


You can now reach me on Twitter @johnnydean1_

Offline

 

#36 2010-09-28 17:06:38

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

Re: Sprite saying things help

johnnydean1 wrote:

Here:

| tosay waitTime time1 time2 time3 timeto length index say timee |
tosay := {'hi'.'hello'} as: OrderedCollection.
waitTime := {'1'.'2'} as: OrderedCollection.
length_ tosay size.
waitTime size < length
ifTrue: [
length_ waitTime size.
].
length _ length asNumber.

index_ 0.
index_ index asNumber.
length timesRepeat: [
index_ index + 1.

say_ tosay at: index.
say_ say asString.
timee_ waitTime at: index.
timee_ timee asNumber.

self say: say.

time3_ 0.
time1_ self timer.
timeto_ time1 + timee.
[ time1 < timeto ]
whileTrue: [
time2_ self timer.
time2 < time1
ifTrue: [
time3_ time1.
].
time1_ time3 + time2.

].
].

self say: ''.

tosay := {'hi'.'hello'} as: OrderedCollection.
waitTime := {'1'.'2'} as: OrderedCollection.
They are you say things.

It works! Thank you.

Offline

 

Board footer