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