@@ -62,6 +62,7 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
6262 except ZeroDivisionError :
6363 raise ZeroDivisionError (_ ("zero-division-error" ))
6464 return self .value
65+
6566 elif self .opcode == "operator_random" : # pick random from () to ()
6667 decimals1 = len (str (math .modf (float (self .getInputValue ("from" ))))) - 2
6768 decimals2 = len (str (math .modf (float (self .getInputValue ("to" ))))) - 2
@@ -71,6 +72,7 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
7172 decimals = decimals2
7273 self .value = random .randint (int (self .getInputValue ("from" )) * 10 ** decimals , int (self .getInputValue ("to" )) * 10 ** decimals ) / 10 ** decimals
7374 return self .value
75+
7476 elif self .opcode == "operator_equals" : # () = ()
7577 self .value = self .getInputValue ("operand1" ) == self .getInputValue ("operand2" )
7678 return self .value
@@ -80,12 +82,14 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
8082 elif self .opcode == "operator_gt" : # () > ()
8183 self .value = self .getInputValue ("operand1" ) > self .getInputValue ("operand2" )
8284 return self .value
85+
8386 elif self .opcode == "motion_xposition" : # x position
8487 self .value = self .target .x
8588 return self .value
8689 elif self .opcode == "motion_xposition" : # y position
8790 self .value = self .target .y
8891 return self .value
92+
8993 elif self .opcode == "sensing_mousex" : # mouse x
9094 newX , newY = pygame .mouse .get_pos ()
9195 newX = newX - config .screenWidth // 2
@@ -96,14 +100,22 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
96100 newY = newY - config .screenWidth // 2
97101 self .value = newY
98102 return self .value
103+
99104 elif self .opcode == "sensing_keypressed" : # key pressed?
100105 self .value = KEY_MAPPING [self .getMenuValue ("key_option" )] in eventContainer .keys
101106 return self .value
107+ elif self .opcode == "sensing_mousedown" : # mouse down?
108+ self .value = pygame .mouse .get_pressed ()[0 ]
109+ return self .value
110+
102111 elif self .opcode == "operator_not" : # not <>
103112 self .value = not self .target .blocks [self .getBlockInputValue ("operand" )].evaluateBlockValue (eventContainer )
104113 return self .value
105- elif self .opcode == "sensing_mousedown" : # mouse down?
106- self .value = pygame .mouse .get_pressed ()[0 ]
114+ elif self .opcode == "operator_and" : # <> and <>
115+ self .value = self .target .blocks [self .getBlockInputValue ("operand1" )].evaluateBlockValue (eventContainer ) and self .target .blocks [self .getBlockInputValue ("operand2" )].evaluateBlockValue (eventContainer )
116+ return self .value
117+ elif self .opcode == "operator_or" : # <> or <>
118+ self .value = self .target .blocks [self .getBlockInputValue ("operand1" )].evaluateBlockValue (eventContainer ) or self .target .blocks [self .getBlockInputValue ("operand2" )].evaluateBlockValue (eventContainer )
107119 return self .value
108120
109121 # Returns block input value
0 commit comments