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

#1 2012-10-21 13:01:51

Steven_E
New Scratcher
Registered: 2012-10-21
Posts: 2

using variables in operators

Hi guys,

I am in some dire straits here and hope that some of you can help me.

In order to work around my issue with the () OR () blocks (I would need to ask 15 cases), I wanted to use a variable and do 15 IF-Blocks instead (not a good workaround but one I read about earlier).

To test my theory and not do the work for the 15 cases, I used a very simple test-example with just good old Scratch as a sprite:

 
WHEN green flag clicked
set [test] to [0]
FOREVER IF < [test] < [5] >
SAY [hello]
 
when [space v] key pressed
CHANGE [test] by [1]
For some reason the cat never says hello, no matter how often I press space. I can see the counter move up, but it just doesn't seem to do the trick. Is there some kind of trick / definition I have to do? Or is it just not possible to work Scratch this way?

Thanks in advance and greetings from Germany,
Steven

Offline

 

#2 2012-10-21 13:06:31

Seil
Scratcher
Registered: 2011-09-02
Posts: 100+

Re: using variables in operators

Erm, you did click the green flag in the top right corner, right? This starts the script under the "when flag clicked" hat block.


http://legacy-cdn.smosh.com/smosh-pit/022011/spongebob-gif-lol.gif

Offline

 

#3 2012-10-21 13:09:28

LordAwesome123
Scratcher
Registered: 2011-01-18
Posts: 100+

Re: using variables in operators

Did you write "test" as text in the op? Or did you connect the orange variable piece to the rectangle slot?

I tried the script myself, seems to work fine.

Last edited by LordAwesome123 (2012-10-21 13:10:28)


http://i672.photobucket.com/albums/vv82/coke457/cooltext538978807.png
When life gives you lemons... take them... free stuff is cool  smile

Offline

 

#4 2012-10-21 13:16:23

Seil
Scratcher
Registered: 2011-09-02
Posts: 100+

Re: using variables in operators

LordAwesome123 wrote:

Did you write "test" as text in the op? Or did you connect the orange variable piece to the oval slot?

That's what I was thinking at first but then I falsely realized that you can't put text in an inequality operator block. (You actually can)
So that could be a possibility.

Steven_E, I'm starting to look at your scratchblocks exactly as you wrote them. If you have the string "test" in an equality operator block it won't work. Make sure you have the variable "test" rounded block into the left side of the operator block, like what LordAwesome123 is saying.


http://legacy-cdn.smosh.com/smosh-pit/022011/spongebob-gif-lol.gif

Offline

 

#5 2012-10-21 15:27:25

Steven_E
New Scratcher
Registered: 2012-10-21
Posts: 2

Re: using variables in operators

Thanks!

I was indeed too impatient and was unable to figure out how to use the variable!

Thanks and cheers!

Offline

 

#6 2012-10-21 16:10:36

milabulic
New Scratcher
Registered: 2012-10-19
Posts: 2

Re: using variables in operators

when gf clicked
show
switch to costume [dialogue1]
play sound [recording1]
wait [5] secs
there are 10 dialogue costumes and 10 recordings. Initially, I wanted to use a statement that would increment the switch to costume AND its associated recording  via a mouseclick, but I could not get that to work properly... instead what I have is a loooooooong and ugly bit of code that waits, switches, and plays until the final costume/music change.

I'm not sure how I can do this the way I'd like--any ideas?
thanks.

Offline

 

#7 2012-10-21 18:01:27

awesomeness321
Scratcher
Registered: 2012-08-10
Posts: 100+

Re: using variables in operators

milabulic wrote:

when gf clicked
show
switch to costume [dialogue1]
play sound [recording1]
wait [5] secs
there are 10 dialogue costumes and 10 recordings. Initially, I wanted to use a statement that would increment the switch to costume AND its associated recording  via a mouseclick, but I could not get that to work properly... instead what I have is a loooooooong and ugly bit of code that waits, switches, and plays until the final costume/music change.

I'm not sure how I can do this the way I'd like--any ideas?
thanks.

This doesn't seem related to the topic.... why don't you make your own topic?


My newest project:http://blocks.scratchr.org/API.php?user=awesomeness321&amp;action=projects&amp;type=newest&amp;return=image&amp;num=1Color:#30F9A5 I am currently http://blocks.scratchr.org/API.php?user=awesomeness321&amp;action=onlineStatus&amp;type=text

Offline

 

Board footer