Difference between revisions of "Activities/Butialo"

From Sugar Labs
Jump to navigation Jump to search
Line 24: Line 24:
 
Can also be programmed with events. The previous program is equivalent to the following:
 
Can also be programmed with events. The previous program is equivalent to the following:
  
  local function adelante()
+
  local function adelante()   -- adelante is Spanish for forward or proceed
 
   Motores.setvel2mtr( 1, 500, 1, 500 )
 
   Motores.setvel2mtr( 1, 500, 1, 500 )
 
  end
 
  end
  local function esperar()
+
  local function esperar()   -- esperar is Spanish for wait
 
   Motores.setvel2mtr( 1, 0, 1, 0 )
 
   Motores.setvel2mtr( 1, 0, 1, 0 )
 
   wait( 1 )
 
   wait( 1 )

Revision as of 19:52, 30 September 2012

Butialo is a user-friendly environment that allows programming of the Butiá in the Lua language. Lua is a simple imperative scripting language but can create sophisticated programs. It is a dynamic language with automatic memory management and is extremely fast. Butialo is a derivative of the Pippy IDE (Python environment provided with the XO), which simplifies the creation of programs for the presence of components connected to the Butiá and offering snippets of code to access them.

The authoritative documentation is in the Spanish language at [1]

Installation

Download the Activity at [2]

Simple example

Move forward until there is an obstacle.

Motores.setvel2mtr( 1, 500, 1, 500 )
while true do
  local dist = Dist.getDistancia()
  if dist<700 then
     Motores.setvel2mtr( 1, 0, 1, 0 )
     repeat
        wait(1)
        dist = Dist.getDistancia()
     until dist > 700
     Motores.setvel2mtr( 1, 500, 1, 500 )
  end
end

Can also be programmed with events. The previous program is equivalent to the following:

local function adelante()   -- adelante is Spanish for forward or proceed
 Motores.setvel2mtr( 1, 500, 1, 500 )
end
local function esperar()    -- esperar is Spanish for wait
 Motores.setvel2mtr( 1, 0, 1, 0 )
 wait( 1 )
end

events.add( Dist.getDistancia, '<', 700, esperar )
events.add( Dist.getDistancia, '>', 700, adelante )
events.go()

Continue reading in Spanish

[3]