Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tabasics.py
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-08-09 09:17:55 (GMT)
committer Marion <marion.zepf@gmail.com>2013-08-09 09:17:55 (GMT)
commitceccfe5f3ff28e5d2c42fc1a56d80b43a680839a (patch)
tree81daf2a8040742483f1e3bdb5a4228da00b75dfa /TurtleArt/tabasics.py
parent753be7616e141d656ebaeaf84651cb53e3fe7383 (diff)
add Primitives for the 'if-then' and 'if-then-else' blocks
- Treat the list of all blocks attached to one 'flow' dock as one argument.
Diffstat (limited to 'TurtleArt/tabasics.py')
-rw-r--r--TurtleArt/tabasics.py24
1 files changed, 3 insertions, 21 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py
index 7a02074..d6bf1f4 100644
--- a/TurtleArt/tabasics.py
+++ b/TurtleArt/tabasics.py
@@ -841,7 +841,6 @@ number of seconds'))
})})}),
True)
- primitive_dictionary['if'] = self._prim_if
palette.add_block('if',
style='clamp-style-boolean',
label=[_('if'), _('then'), ''],
@@ -851,9 +850,8 @@ number of seconds'))
logo_command='if',
help_string=_('if-then operator that uses boolean \
operators from Numbers palette'))
- self.tw.lc.def_prim('if', 2, primitive_dictionary['if'], True)
+ self.tw.lc.def_prim('if', 2, Primitive(self.tw.lc.prim_if), True)
- primitive_dictionary['ifelse'] = self._prim_ifelse
palette.add_block('ifelse',
hidden=True, # Too big to fit palette
style='clamp-style-else',
@@ -864,7 +862,8 @@ operators from Numbers palette'))
special_name=_('if then else'),
help_string=_('if-then-else operator that uses \
boolean operators from Numbers palette'))
- self.tw.lc.def_prim('ifelse', 3, primitive_dictionary['ifelse'], True)
+ self.tw.lc.def_prim('ifelse', 3, Primitive(self.tw.lc.prim_ifelse),
+ True)
# macro
palette.add_block('ifthenelse',
@@ -1126,23 +1125,6 @@ variable'))
break
self.tw.lc.ireturn()
yield True
-
- def _prim_if(self, boolean, blklist):
- ''' If bool, do list '''
- if boolean:
- self.tw.lc.icall(self.tw.lc.evline, blklist[:])
- yield True
- self.tw.lc.ireturn()
- yield True
-
- def _prim_ifelse(self, boolean, list1, list2):
- ''' If bool, do list1, else do list2 '''
- if boolean:
- self.tw.lc.ijmp(self.tw.lc.evline, list1[:])
- yield True
- else:
- self.tw.lc.ijmp(self.tw.lc.evline, list2[:])
- yield True
def convert_value_for_move(self, value):
''' Perform type conversion and other preprocessing on the parameter,