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

#1 2012-11-19 08:41:43

arvidabystrom
New Scratcher
Registered: 2012-11-18
Posts: 9

variables

i made a variable called "settings" and when settings = 1 when mouse-pointer is over sprite1 it gives one sound, when setting = 2  when mouse-pointer is over sprite1 it should give sound2.
right now sound2 does work in setting = 2 but sound1 still sounds in setting = 2 which i don't want it to.
what to do?

thnxxx

Offline

 

#2 2012-11-19 08:55:57

BurritoSM
Scratcher
Registered: 2012-11-11
Posts: 33

Re: variables

Could you post the script?

Offline

 

#3 2012-11-19 09:18:51

arvidabystrom
New Scratcher
Registered: 2012-11-18
Posts: 9

Re: variables

sprite1:
when space key pressed
if settings = 1
forever if touching mouse-pointer
play sound sound1 until done

when i recive yes
if settings = 2
forever if touching mouse-pointer
play sound sound2 until done

sprite2:
when space key pressed
forever set settings to 1

when sprite2 clicked
broadcast yes
forever
set settings to 2
set settings to settings mod 2 + 1



also, what does the mod thing actually do? i got help with that one, just great to know why it's there

Offline

 

#4 2012-11-19 19:45:48

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: variables

arvidabystrom wrote:

sprite1:

when [space v] key pressed
if <(settings) = (1)>
forever if <touching [mouse-pointer v]?>
play sound [sound1 v] until done

when i receive [yes v]
if <(settings) = (2)>
forever if <touching [mouse-pointer v]?>
play sound [sound2 v] until done
sprite2:
when [space v] key pressed
set [settings v] to (1)

when [sprite2] clicked
broadcast [yes v]
set [settings v] to (2)
set [settings v] to ((settings) mod ((2) + (1)))
also, what does the mod thing actually do? i got help with that one, just great to know why it's there

Fixed scratchblocks.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#5 2012-11-19 20:18:59

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: variables

arvidabystrom wrote:

sprite1:
when space key pressed
if settings = 1
forever if touching mouse-pointer
play sound sound1 until done

when i recive yes
if settings = 2
forever if touching mouse-pointer
play sound sound2 until done

sprite2:
when space key pressed
forever set settings to 1

when sprite2 clicked
broadcast yes
forever
set settings to 2
set settings to settings mod 2 + 1



also, what does the mod thing actually do? i got help with that one, just great to know why it's there

The mod operator divides the first number by the second number and gives you the remainder. For example:

(4) mod (4) = 0

(7) mod (4) = 3

I hope that this answers your second question!


http://i46.tinypic.com/35ismmc.png

Offline

 

#6 2012-11-22 10:50:25

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: variables

Is this what it is supposed to be?

Offline

 

#7 2012-11-25 10:35:38

mathfreak231
Scratcher
Registered: 2012-10-24
Posts: 80

Re: variables

jontmy00 wrote:

arvidabystrom wrote:

sprite1:

when [space v] key pressed
if <(settings) = (1)>
forever if <touching [mouse-pointer v]?>
play sound [sound1 v] until done

when i receive [yes v]
if <(settings) = (2)>
forever if <touching [mouse-pointer v]?>
play sound [sound2 v] until done
sprite2:
when [space v] key pressed
set [settings v] to (1)

when [sprite2] clicked
broadcast [yes v]
set [settings v] to (2)
set [settings v] to ((settings) mod ((2) + (1)))
also, what does the mod thing actually do? i got help with that one, just great to know why it's there

Fixed scratchblocks.

"Set [settings v] to ((settings) mod (3))"?
What that for?


~This sig is false~
I'm on teh wiki!

Offline

 

Board footer