Discuss Scratch

Dale_Mahalko
New to Scratch
68 posts

Variables in "Touching" and "Touching Color" ??

How do you use variables with the Touching sense? I am using Scratch 2.0 standalone.

<touching (N) ?>

<touching color (N) ?>

There is no way to “Set variable to color” in the editor by clicking on objects on the stage, to set a color…. (Let's see what the website does with this..)

set (N) to [#ff0088]

If I try typing the name of a sprite into a variable, it does not detect the sprite. Putting the sprite name in quotes in the variable doesn't help.


I am trying to iterate through a list of sprites to scan for objects it is touching.

Last edited by Dale_Mahalko (Feb. 24, 2016 01:55:19)

Dale_Mahalko
New to Scratch
68 posts

Variables in "Touching" and "Touching Color" ??

Whoops, got the “touching Sprite N” with a named sprite to work…. found a typo.

Though still no way to set a variable to a color, apparently.
LLCoolJC
Scratcher
70 posts

Variables in "Touching" and "Touching Color" ??

You can test if touching a sprite easily like this:

<touching (join[Spritename][])?>

Dale_Mahalko
New to Scratch
68 posts

Variables in "Touching" and "Touching Color" ??

Yes, but the question remains why “Touching Color” allows a variable to be dropped into the color selection box, if you cannot actually store colors in variables. Looks like a bug or undocumented feature to me.
deck26
Scratcher
1000+ posts

Variables in "Touching" and "Touching Color" ??

Dale_Mahalko wrote:

Yes, but the question remains why “Touching Color” allows a variable to be dropped into the color selection box, if you cannot actually store colors in variables. Looks like a bug or undocumented feature to me.
You can represent colours using RGB codes - see the bottom half of http://wiki.scratch.mit.edu/wiki/Set_Pen_Color_to_%28%29
Sunburn02
Scratcher
1 post

Variables in "Touching" and "Touching Color" ??

Has anyone found a fix to this? I want a drawing to stop once it touches another drawing and putting the variable i assigned to color does nothing for the touching color block. Any work arounds?
Zizzle8383
Scratcher
100+ posts

Variables in "Touching" and "Touching Color" ??

Sunburn02 wrote:

Has anyone found a fix to this? I want a drawing to stop once it touches another drawing and putting the variable i assigned to color does nothing for the touching color block. Any work arounds?
dont necropost

Hyperbowls will live on!

It's Selltick, PPA.
Zizzle8383
Scratcher
100+ posts

Variables in "Touching" and "Touching Color" ??

(deleted)

Last edited by Zizzle8383 (Oct. 23, 2019 01:07:01)


Hyperbowls will live on!

It's Selltick, PPA.
deck26
Scratcher
1000+ posts

Variables in "Touching" and "Touching Color" ??

Sunburn02 wrote:

Has anyone found a fix to this? I want a drawing to stop once it touches another drawing and putting the variable i assigned to color does nothing for the touching color block. Any work arounds?
Instead of necroposting create your own new topic and share the project.
advantage666
Scratcher
1 post

Variables in "Touching" and "Touching Color" ??

i know this is too late but instead of using ‘#’ use ‘0x’ for the hex code

hope it helps

Last edited by advantage666 (March 3, 2022 09:57:24)

Brabygg
Scratcher
50 posts

Variables in "Touching" and "Touching Color" ??

advantage666 wrote:

i know this is too late but instead of using ‘#’ use ‘0x’ for the hex code

hope it helps

You are indeed way, way too late. This is necroposting to the extreme.

I hope the post above enlightened you to a higher purpose and inspired you to achieve your dreams.

Also, check out my shooter that's probably not gonna be done for the next ten years.
FrederikQSI
Scratcher
1 post

Variables in "Touching" and "Touching Color" ??

I need to detect if an object is touching another object and then change a varialbe because of that, but that loops and changes the variable infintly. Does anyone have a fix for this?
owenl081
Scratcher
1 post

Variables in "Touching" and "Touching Color" ??

FrederikQSI wrote:

I need to detect if an object is touching another object and then change a varialbe because of that, but that loops and changes the variable infintly. Does anyone have a fix for this?
Here is something that might help you
when green flag clicked
forever
if <not <[variable that changes on touch v] = [original value]>> then
if <touching [sprite v] ?> then
set [varaiable that changes on touch v] to [your value (that isnt the original value)]
end
end
end

Last edited by owenl081 (April 10, 2024 22:32:57)

Brunuchol
Scratcher
24 posts

Variables in "Touching" and "Touching Color" ??

There's way to avoid it (if color touched)! All you need is just one hacked block. Best project with this block is Hello3409's Hacked blocks. The block we need is in “Fun” sprite. Drag from left to right, and it will be in When timer > (color block) block. Then make something like this:
set [color v] to [#7fff00]
when green flag clicked
forever
if <touching color (color) ?> then
say [Try it! It works!]
end
end

Powered by DjangoBB