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

#1 2012-06-18 14:37:42

Flashing
New Scratcher
Registered: 2012-06-11
Posts: 66

How come this script doesn't work?

Hi. I'm making a game, and how come this script doesn't work?:

when gf clicked
forever
switch to costume (item [1] of [off/on sensors v])
if <<mouse down?> and <touching [mouse pointer v]>>
if <(item [1] of [off/on sensors v])= (1)]>
replace item (1) of [off/on sensor v] with [2]
end
if <<mouse down?> and <touching [mouse pointer v]>>
if <(item [1] of [off/on sensors v])= (2)]>
replace item (1) of [off/on sensor v] with [1]
end
end

Offline

 

#2 2012-06-18 14:41:01

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: How come this script doesn't work?

Flashing wrote:

Hi. I'm making a game, and how come this script doesn't work?:

when gf clicked
forever
switch to costume (item [1] of [off/on sensors v])
wait until <<not <mouse down?>> or <not <touching [mouse pointer v]?>>>
if <<mouse down?> and <touching [mouse pointer v]?>>
if <(item (1) of [off/on sensors v]) = (1)>
replace item (1) of [off/on sensor v] with [2]
else
replace item (1) of [off/on sensor v] with [1]
end

Fixed.  wink

Or, for something MUCH SIMPLER:

forever
 wait until <not <<mouse down?> and <touching [mouse pointer v]?>>>
 wait until <<mouse down?> and <touching [mouse pointer v]?>>
 if <(costume #) = [1]>
 switch to costume [costume2 v]
 else
 switch to costume [costume1 v]
end
Or:

forever
 wait until <not <<mouse down?> and <touching [mouse pointer v]?>>>
 wait until <<mouse down?> and <touching [mouse pointer v]?>>
 next costume

Last edited by SciTecCf (2012-06-18 14:49:43)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#3 2012-06-18 14:44:19

Flashing
New Scratcher
Registered: 2012-06-11
Posts: 66

Re: How come this script doesn't work?

When you click it, it's supposed to turn off/on. But it only turns on, when you click it. Help!

Offline

 

#4 2012-06-18 14:46:00

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: How come this script doesn't work?

Try it now, I edited my post.


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#5 2012-06-18 14:51:42

Flashing
New Scratcher
Registered: 2012-06-11
Posts: 66

Re: How come this script doesn't work?

SciTecCf wrote:

Try it now, I edited my post.

Give me the other one you posted.

Offline

 

#6 2012-06-18 14:55:15

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: How come this script doesn't work?

Flashing wrote:

SciTecCf wrote:

Try it now, I edited my post.

Give me the other one you posted.

Here are your possible solutions:

when gf clicked
forever
switch to costume (item [1] of [off/on sensors v])
wait until <<not <mouse down?>> or <not <touching [mouse pointer v]?>>>
if <<mouse down?> and <touching [mouse pointer v]?>>
if <(item (1) of [off/on sensors v]) = (1)>
replace item (1) of [off/on sensor v] with [2]
else
replace item (1) of [off/on sensor v] with [1]
end
OR

forever
 wait until <not <<mouse down?> and <touching [mouse pointer v]?>>>
 wait until <<mouse down?> and <touching [mouse pointer v]?>>
 if <(costume #) = [1]>
 switch to costume [costume2 v]
 else
 switch to costume [costume1 v]
end
OR

forever
 wait until <not <<mouse down?> and <touching [mouse pointer v]?>>>
 wait until <<mouse down?> and <touching [mouse pointer v]?>>
 next costume
I would recommend the second one.


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

Board footer