Skip to content

Commit

Permalink
Fixed compatibility with new pen color blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
RexScratch committed Mar 9, 2019
1 parent a13a7ea commit b07ed98
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sb3tosb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,15 @@ def pen_setPenColorParamTo(self, block, blocks):
param = self.converter.inputVal('COLOR_PARAM', block, blocks)
value = self.converter.inputVal('VALUE', block, blocks)
if param == 'color':
if type(value) == str:
try:
value = float(value)
except:
pass
if type(value) == float or type(value) == int:
value *= 2
else:
value = ['*', 2, value]
output = ['setPenHueTo:']
output.append(value)
return output
Expand All @@ -414,6 +423,15 @@ def pen_changePenColorParamBy(self, block, blocks):
param = self.converter.inputVal('COLOR_PARAM', block, blocks)
value = self.converter.inputVal('VALUE', block, blocks)
if param == 'color':
if type(value) == str:
try:
value = float(value)
except:
pass
if type(value) == float or type(value) == int:
value *= 2
else:
value = ['*', 2, value]
output = ['changePenHueBy:']
output.append(value)
return output
Expand Down

0 comments on commit b07ed98

Please sign in to comment.