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