From f5b030edcaabfd0d964adfb1dec5bcc93ed24f29 Mon Sep 17 00:00:00 2001 From: Technoboy10 Date: Wed, 6 Aug 2014 11:31:21 -0400 Subject: Update tutorial.rst Started updating stuff to blockext 0.2 --- doc/tutorial.rst | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'doc') diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 2a67371..5167a87 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -18,29 +18,26 @@ Example ------- Blockext is a Python module that makes writing extensions for these block-based -programming languages much, much easier. It probably couldn't get any easier. +programming languages fairly easy. Here's a quick example:: from blockext import * - - light = False - - @command("press light switch %n times") - def toggle_light(times=1): - global light - for i in range(times): - light = not light - - @predicate("light is on?") - def is_light_on(): - return light - - menu("city", ["Barcelona", "Boston", "Brighton"]) - - @reporter("weather forecast for %m.city") - def forecast(city="Boston"): - import random - return random.choice(["windy", "snowy", "sunny"]) + + class Extension: + def __init__(self): + light = False + + def toggle_light(times=1): + global light + for i in range(times): + light = not light + + def is_light_on(): + return light + + def forecast(city="Boston"): + import random + return random.choice(["windy", "snowy", "sunny"]) run("Tutorial Example", "example", 5000) -- cgit v1.3.1