azzieg / mindstorms-inventor

Advanced Python programming for Lego Mindstorms Robot Inventor.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Register on condition

cscovino opened this issue · comments

I'm working with Spike Prime and I was trying to register a task when a condition is met but I couldn't figure out what I have to pass as the third parameter. Do you know how this method works?

vm.register_on_condition('condition_met', displaysomething, ?)

I found the solution:

def conditionDistance(vm, stack):
    return distance.get_distance_percentage() != None and distance.get_distance_percentage() < 10

...

vm.register_on_condition("on_condition", displaysomething, conditionDistance)
commented

Nice find, note that you can now see decoded word blocks on our reference sheet: https://github.com/azzieg/mindstorms-inventor/tree/main/word_blocks