Activities/Turtle Art/Under the hood: Difference between revisions

Modifying Turtle Art: updated instructions for modifying TA
 
(4 intermediate revisions by one other user not shown)
Line 18: Line 18:
# block number
# block number
# block name or [block name, block value]
# block name or [block name, block value]
# x position (depreciated)
# x position (deprecated)
# y position (depreciated)
# y position (deprecated)
# list of connections to other blocks
# list of connections to other blocks


Line 57: Line 57:
                       help_string=_('turns the turtle 180 degrees'))
                       help_string=_('turns the turtle 180 degrees'))


    # Next, you need to define what your block will do:
Next, you need to define what your block will do. def_prim takes 3 arguments: the primitive name, the number of arguments—0 in this case—and the function to call—in this case, the canvas.seth function to set the heading.
    # def_prim takes 3 arguments: the primitive name, the number of
 
    # of arguments, 0 in this case, and the function to call, in this
    # case, the canvas function to set the heading.
     self.tw.lc.def_prim('uturn', 0,
     self.tw.lc.def_prim('uturn', 0,
         lambda self: self.tw.canvas.seth(self.tw.canvas.heading + 180))
         lambda self: self.tw.canvas.seth(self.tw.canvas.heading + 180))
Line 72: Line 70:
that the icons should be the same size (55x55) as the others. (This is
that the icons should be the same size (55x55) as the others. (This is
the default icon size for Sugar toolbars.)
the default icon size for Sugar toolbars.)
=== How to write a plugin ===
In Spanish: http://valentinbasel.fedorapeople.org/pdfs/turtle_art.pdf