def visitOr(blockcontext):
    operand1 = visitGeneric(blockcontext, "OPERAND1")
    if operand1 is None:
        operand1 = False
    operand2 = visitGeneric(blockcontext, "OPERAND2")
    if operand2 is None:
        operand2 = False
    return ["|", operand1, operand2]
def visitRepeat(blockcontext):
    block = blockcontext.block
    times = visitGeneric(blockcontext, "TIMES")
    if times == []:
        times = block.inputs["TIMES"][1][1]
    substack = visitSubstack(blockcontext, "SUBSTACK")
    return ["doRepeat", times, substack]
Exemple #3
0
def visitSetvolumeto(blockcontext):
    block = blockcontext.block
    volume = visitGeneric(blockcontext, "VOLUME")
    if volume == []:
        volume = block.inputs['VOLUME'][1][1]
    return ["setVolumeTo:", volume]
Exemple #4
0
def visitPlayuntildone(blockcontext):
    sound = visitGeneric(blockcontext, 'SOUND_MENU')
    return ['doPlaySoundAndWait', sound]
Exemple #5
0
def visitSety(blockcontext):
    y = visitGeneric(blockcontext, "Y")
    return ["ypos:", y]
Exemple #6
0
def visitSetsizeto(blockcontext):
    size = visitGeneric(blockcontext, "SIZE")
    return ["setSizeTo:", size]
Exemple #7
0
def visitGlideto(blockcontext):
    secs = visitGeneric(blockcontext, "SECS")
    to = visitGeneric(blockcontext, "TO")
    log.warn("[Scratch3] block {} ({}) possibly not available in Scratch2".format(blockcontext.block.opcode, blockcontext.block.name))
    return ["glideTo:", secs, to] #TODO: not in scratch2?
Exemple #8
0
def visitChangexby(blockcontext):
    x = visitGeneric(blockcontext, "DX")
    return ["changeXposBy:", x]
Exemple #9
0
def visitAddtolist(blockcontext):
    block = blockcontext.block
    list = block.fields["LIST"][0]
    item = visitGeneric(blockcontext, "ITEM")
    return ["append:toList:", item, list]
Exemple #10
0
def visitSetPenHueToNumber(blockcontext):
    size = visitGeneric(blockcontext, "HUE")
    log.warn("[Scratch3] SetPenHue block possibly not available in Scratch2")
    return ["penHue:", size]
Exemple #11
0
def visitGoforwardbackwardlayers(blockcontext):
    block = blockcontext.block
    direction = block.fields["FORWARD_BACKWARD"][0]
    change = visitGeneric(blockcontext, "NUM")
    return ["goBackByLayers:", change]
Exemple #12
0
def visitChangevariableby(blockcontext):
    block = blockcontext.block
    variable = block.fields["VARIABLE"][0]
    value = visitGeneric(blockcontext, "VALUE")
    return ["changeVar:by:", variable, value]
Exemple #13
0
def visitSeteffectto(blockcontext):
    block = blockcontext.block
    effect = block.fields["EFFECT"][0]
    value = visitGeneric(blockcontext, "VALUE")
    return ["setGraphicEffect:to:", effect, value]
Exemple #14
0
def visitSayforsecs(blockcontext):
    message = visitGeneric(blockcontext, "MESSAGE")
    duration = visitGeneric(blockcontext, "SECS")
    return ["say:duration:elapsed:from:", message, duration]
Exemple #15
0
def visitChangeeffectby(blockcontext):
    block = blockcontext.block
    effect = block.fields["EFFECT"][0]
    change = visitGeneric(blockcontext, "CHANGE")
    return ["changeGraphicEffect:by:", effect, change]
Exemple #16
0
def visitChangePenSizeBy(blockcontext):
    sizechange = visitGeneric(blockcontext, "SIZE")
    return ["changePenSizeBy:", sizechange]
Exemple #17
0
def visitInsertatlist(blockcontext):
    block = blockcontext.block
    list = block.fields["LIST"][0]
    item = visitGeneric(blockcontext, "ITEM")
    index = visitGeneric(blockcontext, "INDEX")
    return ["insert:at:ofList:", item, index, list]
Exemple #18
0
def visitSetPenShadeToNumber(blockcontext):
    size = visitGeneric(blockcontext, "SHADE")
    return ["penShade:", size]
Exemple #19
0
def visitReplaceitemoflist(blockcontext):
    block = blockcontext.block
    list = block.fields["LIST"][0]
    item = visitGeneric(blockcontext, "ITEM")
    index = visitGeneric(blockcontext, "INDEX")
    return ["setLine:ofList:to:", index, list, item]
Exemple #20
0
def visitGoto(blockcontext):
    to = visitGeneric(blockcontext, "TO")
    return ["gotoSpriteOrMouse:", to]
Exemple #21
0
def visitSetvariableto(blockcontext):
    block = blockcontext.block
    variable = block.fields["VARIABLE"][0]
    value = visitGeneric(blockcontext, "VALUE")
    return ["setVar:to:", variable, value]
Exemple #22
0
def visitPointindirection(blockcontext):
    direction = visitGeneric(blockcontext, "DIRECTION")
    return ["heading:", direction]
Exemple #23
0
def visitWhengreaterthan(blockcontext):
    block = blockcontext.block
    sensor = block.fields["WHENGREATERTHANMENU"][0].lower()
    value = visitGeneric(blockcontext, "VALUE")
    return ["whenSensorGreaterThan", sensor, value]
Exemple #24
0
def visitSetx(blockcontext):
    x = visitGeneric(blockcontext, "X")
    return ["xpos:", x]
Exemple #25
0
def visitBroadcastandwait(blockcontext):
    message = visitGeneric(blockcontext, "BROADCAST_INPUT")
    return ["doBroadcastAndWait", message]
Exemple #26
0
def visitItemoflist(blockcontext):
    block = blockcontext.block
    list = block.fields["LIST"][0]
    index = visitGeneric(blockcontext, "INDEX")
    return ["getLine:ofList:", index, list]
Exemple #27
0
def visitChangesizeby(blockcontext):
    size = visitGeneric(blockcontext, "CHANGE")
    return ["changeSizeBy:", size]
Exemple #28
0
def visitBroadcast(blockcontext):
    message = visitGeneric(blockcontext, "BROADCAST_INPUT")
    return ["broadcast:", message]
Exemple #29
0
def visitItemnumoflist(blockcontext):
    block = blockcontext.block
    list = block.fields["LIST"][0]
    item = visitGeneric(blockcontext, "ITEM")
    log.warn("[Scratch3] block {} ({}) possibly not available in Scratch2".format(block.opcode, block.name))
    return ["itemNum:ofList:", list, item] #TODO: not in scratch2
Exemple #30
0
def visitChangevolumeby(blockcontext):
    block = blockcontext.block
    volume = visitGeneric(blockcontext, "VOLUME")
    if volume == []:
        volume = block.inputs['VOLUME'][1][1]
    return ["changeVolumeBy:", volume]
Exemple #31
0
def visitListcontainsitem(blockcontext):
    block = blockcontext.block
    list = block.fields["LIST"][0]
    item = visitGeneric(blockcontext, "ITEM")
    return ["list:contains:", list, item]
Exemple #32
0
def visitPlay(blockcontext):
    sound = visitGeneric(blockcontext, 'SOUND_MENU')
    return ['playSound:', sound]
Exemple #33
0
def visitSwitchcostumeto(blockcontext):
    costume = visitGeneric(blockcontext, "COSTUME")
    return ["lookLike:", costume]
Exemple #34
0
def visitSetPenColorToColor(blockcontext):
    color = visitGeneric(blockcontext, "COLOR")
    return ["penColor:", color]
Exemple #35
0
def visitSwitchbackdropto(blockcontext):
    backdrop = visitGeneric(blockcontext, "BACKDROP")
    return ["startScene", backdrop]
Exemple #36
0
def visitSetPenSizeTo(blockcontext):
    size = visitGeneric(blockcontext, "SIZE")
    return ["penSize:", size]
Exemple #37
0
def visitChangesizeby(blockcontext):
    size = visitGeneric(blockcontext, "CHANGE")
    return ["changeSizeBy:", size]
Exemple #38
0
def visitChangePenShadeByNumber(blockcontext):
    size = visitGeneric(blockcontext, "SHADE")
    return ["changePenShadeBy:", size]
Exemple #39
0
def visitSetsizeto(blockcontext):
    size = visitGeneric(blockcontext, "SIZE")
    return ["setSizeTo:", size]
Exemple #40
0
def visitTurnleft(blockcontext):
    degrees = visitGeneric(blockcontext, "DEGREES")
    return ["turnLeft:", degrees]
Exemple #41
0
def visitChangeeffectby(blockcontext):
    block = blockcontext.block
    effect = block.fields["EFFECT"][0]
    change = visitGeneric(blockcontext, "CHANGE")
    return ["changeGraphicEffect:by:", effect, change]
Exemple #42
0
def visitGotoxy(blockcontext):
    x = visitGeneric(blockcontext, "X")
    y = visitGeneric(blockcontext, "Y")
    return ["gotoX:y:", x, y]
Exemple #43
0
def visitSayforsecs(blockcontext):
    message = visitGeneric(blockcontext, "MESSAGE")
    duration = visitGeneric(blockcontext, "SECS")
    return ["say:duration:elapsed:from:", message, duration]
Exemple #44
0
def visitGlidesecstoxy(blockcontext):
    secs = visitGeneric(blockcontext, "SECS")
    x = visitGeneric(blockcontext, "X")
    y = visitGeneric(blockcontext, "Y")
    return ["glideSecs:toX:y:elapsed:from:", secs, x, y]
Exemple #45
0
def visitSeteffectto(blockcontext):
    block = blockcontext.block
    effect = block.fields["EFFECT"][0]
    value = visitGeneric(blockcontext, "VALUE")
    return ["setGraphicEffect:to:", effect, value]
Exemple #46
0
def visitPointtowards(blockcontext):
    towards = visitGeneric(blockcontext, "TOWARDS")
    return ["pointTowards:", towards]
Exemple #47
0
def visitGoforwardbackwardlayers(blockcontext):
    block = blockcontext.block
    direction = block.fields["FORWARD_BACKWARD"][0]
    change = visitGeneric(blockcontext, "NUM")
    return ["goBackByLayers:", change]
Exemple #48
0
def visitMovesteps(blockcontext):
    steps = visitGeneric(blockcontext, "STEPS")
    return ["forward:", steps]
Exemple #49
0
def visitBroadcastandwait(blockcontext):
    message = visitGeneric(blockcontext, "BROADCAST_INPUT")
    return ["doBroadcastAndWait", message]
Exemple #50
0
def visitChangeyby(blockcontext):
    y = visitGeneric(blockcontext, "DY")
    return ["changeYposBy:", y]
Exemple #51
0
def visitWhengreaterthan(blockcontext):
    block = blockcontext.block
    sensor = block.fields["WHENGREATERTHANMENU"][0].lower()
    value = visitGeneric(blockcontext, "VALUE")
    return ["whenSensorGreaterThan", sensor, value]
Exemple #52
0
def visitTurnright(blockcontext):
    degrees = visitGeneric(blockcontext, "DEGREES")
    return ["turnRight:", degrees]
Exemple #53
0
def visitBroadcast(blockcontext):
    message = visitGeneric(blockcontext, "BROADCAST_INPUT")
    return ["broadcast:", message]