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

id: 184974

category: Help with Scripts

posts: 13

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.
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 LLCoolJC loading
You can test if touching a sprite easily like this:

<touching (join[Spritename][])?>
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 deck26 loading

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 Sunburn02 loading
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 Zizzle8383 loading

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
deck26 deck26 loading

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.
i know this is too late but instead of using ‘#’ use ‘0x’ for the hex code

hope it helps

Brabygg Brabygg loading

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.
FrederikQSI FrederikQSI loading
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 owenl081 loading

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] = [original value]>> then
if <touching [sprite v] ?> then
set [varaiable that changes on touch v] to [your value]
end
end
end