@@ -32,6 +32,7 @@ void SensingBlocks::registerBlocks(IEngine *engine)
3232 // Blocks
3333 engine->addCompileFunction (this , " sensing_touchingobject" , &compileTouchingObject);
3434 engine->addCompileFunction (this , " sensing_touchingcolor" , &compileTouchingColor);
35+ engine->addCompileFunction (this , " sensing_coloristouchingcolor" , &compileColorIsTouchingColor);
3536 engine->addCompileFunction (this , " sensing_distanceto" , &compileDistanceTo);
3637 engine->addCompileFunction (this , " sensing_askandwait" , &compileAskAndWait);
3738 engine->addCompileFunction (this , " sensing_answer" , &compileAnswer);
@@ -60,6 +61,7 @@ void SensingBlocks::registerBlocks(IEngine *engine)
6061 // Inputs
6162 engine->addInput (this , " TOUCHINGOBJECTMENU" , TOUCHINGOBJECTMENU);
6263 engine->addInput (this , " COLOR" , COLOR);
64+ engine->addInput (this , " COLOR2" , COLOR2);
6365 engine->addInput (this , " DISTANCETOMENU" , DISTANCETOMENU);
6466 engine->addInput (this , " QUESTION" , QUESTION);
6567 engine->addInput (this , " KEY_OPTION" , KEY_OPTION);
@@ -139,6 +141,13 @@ void SensingBlocks::compileTouchingColor(Compiler *compiler)
139141 compiler->addFunctionCall (&touchingColor);
140142}
141143
144+ void SensingBlocks::compileColorIsTouchingColor (Compiler *compiler)
145+ {
146+ compiler->addInput (COLOR2); // target color
147+ compiler->addInput (COLOR); // mask color
148+ compiler->addFunctionCall (&colorIsTouchingColor);
149+ }
150+
142151void SensingBlocks::compileDistanceTo (Compiler *compiler)
143152{
144153 Input *input = compiler->input (DISTANCETOMENU);
@@ -525,6 +534,12 @@ unsigned int SensingBlocks::touchingColor(VirtualMachine *vm)
525534 return 0 ;
526535}
527536
537+ unsigned int SensingBlocks::colorIsTouchingColor (VirtualMachine *vm)
538+ {
539+ vm->replaceReturnValue (vm->target ()->touchingColor (*vm->getInput (0 , 2 ), *vm->getInput (1 , 2 )), 2 );
540+ return 1 ;
541+ }
542+
528543unsigned int SensingBlocks::keyPressed (VirtualMachine *vm)
529544{
530545 vm->replaceReturnValue (vm->engine ()->keyPressed (vm->getInput (0 , 1 )->toString ()), 1 );
0 commit comments