Beispiel #1
0
    def __init__(self, project):
        super(Sprite, self).__init__(project=project)

        # "@" attributes
        self.name = "No name"
        self.idx = -1

        self.variables.add(data.Variable("@x", data.Literal(0)))
        self.variables.add(data.Variable("@y", data.Literal(0)))
        self.variables.add(data.Variable("@heading", data.Literal(90)))
        self.variables.add(data.Variable("@scale", data.Literal(1)))

        self.rotation = 1
        self.draggable = False
        self.costume = 0
        self.color = "80,80,80"
        self.pen = "tip"
        self.id = -1

        # children specific to sprite
        self.nest = None  # optional child

        # Not serialized
        self.speech_message = ""
        self.speech_is_thought = False  # False == though, True == speech
        self.speech_image = None
        self.create_new_speech_message = False
Beispiel #2
0
    def run(self, target, parent_script, params):
        """Runs the defined block, and returns a value afterwards"""

        script = self.script.parallel_copy()
        script.parent_script = parent_script
        # set input parameters
        for index, parameter in enumerate(params):
            name = self.parameter_names[index]
            script.variables.add(data.Variable(name, parameter))
        # initial_vars = str(script.variables)
        result = script.run(target)
        # print "Done %s: %s (%s) -> %s (%s)" % (debug_name_for_object(script),
        #                                  self.function_name, initial_vars,
        #                                  result, script.variables)
        return result
Beispiel #3
0
 def exitListVariable(self, ctx:NodeTemplateParser.ListVariableContext):
     self.listElement[self.listCount] = data.Variable()
     self.listElement[self.listCount].name = ctx.NAME().getText()
     self.listCount += 1
Beispiel #4
0
 def enterEcuVariable(self, ctx:NodeTemplateParser.EcuVariableContext):
     self.variable = data.Variable()
Beispiel #5
0
 def exitNetVariable(self, ctx:NodeTemplateParser.NetVariableContext):
     self.variable.on = data.Variable()
     self.variable.on.name = ctx.NAME().getText()
     self.variable.on.type = data.CAN
Beispiel #6
0
 def exitDiffVar(self, ctx:NodeTemplateParser.DiffVarContext):
     var = data.Variable()
     var.name = ctx.NAME().getText();
     self.variable.diff.append(var)
Beispiel #7
0
def doDeclareVariables(target_actor, parent_script, args):
    list_of_vars = args[0]
    for var_name in list_of_vars.list:
        parent_script.variables.add(data.Variable(var_name.as_string()))