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

#1 2012-02-16 16:53:44

horsenkat
Scratcher
Registered: 2010-09-25
Posts: 23

A Quick Picoboard question

I'm trying to program something that uses the picoboard in a very certain way:
if the picoboard slider goes from value 0 to value 100, increase tameness.
In short, if you slide the picoboard from one side to the other, do something.
Even though this seems relavitely simple, I can't seem to figure out how to do it. I've tried the following scripts:
[scratchblocks]
when gf clicked
forever
  if <(slider-sensor-value)> = [0]
    if <(slider-sensor-value)> = [100]
      change <(tameness)> by [10]
   if <(slider-sensor-value)> = [100]
    if <(slider-sensor-value)> = [0]
      change <(tameness)> by [10]
end
[/scratchblocks
[scratchblocks]
when gf clicked
forever
   if <(slider-sensor-value)> = [0]
      wait until <(slider-sensor-value)> = [100]
      if <(slider-sensor-value)> = [100]
         change <(tameness)> by [10]
   if <(slider-sensor-value)> = [100]
      wait until <(slider-sensor-value)> = [0]
      if <(slider-sensor-value)> = [0]
         change <(tameness)> by [10]
end
[/scratchblocks
postblocks. Somethings wrong with the scratch blocks... more then just the way they appear? What is it?
but none of them are working! Any suggestions?

Last edited by horsenkat (2012-02-16 17:06:26)


http://29.media.tumblr.com/tumblr_l8ewen1qwk1qzo7k7o1_500.gif

Offline

 

#2 2012-02-16 20:40:22

Lightnin
Scratch Team
Registered: 2008-11-03
Posts: 1000+

Re: A Quick Picoboard question

You need to close the scratchblocks tag with ] at the end of the [/scratchblocks

I think the trouble you are running into is that your embedded ifs only check once, for a single instance- they don't wait until they are true.

Try something like this:

when gf clicked
forever
  if <<(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>>
      wait until <not <(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>>
      wait until <<(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>>
      change <(tameness)> by [10]
Actually, this will register a change even if one moves from 0 to 1 and back to 0. But you may need to use a variable to toggle the state.


Help Scratchers make the leap to 2.0!
http://img818.imageshack.us/img818/6844/transitionteam.jpg

Offline

 

#3 2012-02-16 21:00:29

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: A Quick Picoboard question

Lightnin wrote:

when gf clicked
forever
  if <<(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>>
      wait until <not < <(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]> > >
      wait until <<(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>>
      change [tameness v] by [10]

Fixed your script.

This script could also be useful if you wanted to make some kind of game where you have to slide it back and forth as fast as possible.

Last edited by Lucario621 (2012-02-16 21:01:31)


http://i.imgur.com/WBkM2QQ.png

Offline

 

#4 2012-02-17 00:34:34

abee
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: A Quick Picoboard question

I tested this script with a real PicoBoard.
It seems a little bit change required as follows.

when gf clicked
forever
wait until < < (slider-sensor-value) < [1]> or <(slider-sensor-value) > [99]> >
wait until < not < <(slider-sensor-value) < [1]> or <(slider-sensor-value) > [99]> > >
change [tameness v] by [10]
end
The sensor values are not stable at the microscopic level. The monitor reflects rounded values. So equal operator is not suitable for comparing sensor value with other value.

Last edited by abee (2012-02-17 00:52:03)

Offline

 

Board footer