@@ -54,6 +54,7 @@ void SensingBlocks::registerBlocks(IEngine *engine)
5454 engine->addCompileFunction (this , " sensing_loudness" , &compileLoudness);
5555 engine->addCompileFunction (this , " sensing_loud" , &compileLoud);
5656 engine->addCompileFunction (this , " sensing_timer" , &compileTimer);
57+ engine->addCompileFunction (this , " sensing_resettimer" , &compileResetTimer);
5758}
5859
5960void SensingBlocks::onInit (IEngine *engine)
@@ -234,6 +235,14 @@ CompilerValue *SensingBlocks::compileTimer(Compiler *compiler)
234235 return compiler->addFunctionCall (" sensing_timer" , Compiler::StaticType::Number, { Compiler::StaticType::Pointer }, { timerPtr });
235236}
236237
238+ CompilerValue *SensingBlocks::compileResetTimer (Compiler *compiler)
239+ {
240+ ITimer *timer = compiler->engine ()->timer ();
241+ CompilerValue *timerPtr = compiler->addConstValue (timer);
242+ compiler->addFunctionCall (" sensing_resettimer" , Compiler::StaticType::Void, { Compiler::StaticType::Pointer }, { timerPtr });
243+ return nullptr ;
244+ }
245+
237246void SensingBlocks::onAnswer (const std::string &answer)
238247{
239248 // https://github.com/scratchfoundation/scratch-vm/blob/6055823f203a696165084b873e661713806583ec/src/blocks/scratch3_sensing.js#L99-L115
@@ -429,3 +438,8 @@ extern "C" double sensing_timer(ITimer *timer)
429438{
430439 return timer->value ();
431440}
441+
442+ extern " C" void sensing_resettimer (ITimer *timer)
443+ {
444+ timer->reset ();
445+ }
0 commit comments