Tactical Computer Action (for beginners and their support team)

Month: June, 2013

Creating a Desktop Shortcut for Minecraft Pi


So you’re using Minecraft Pi on your Raspberry Pi. You enjoy the game, but starting it from the terminal just isn’t your thing. You wish there was an easier way to run it. You’re in luck. In this tutorial I’ll show you how to create a desktop short-cut for Minecraft on your Raspberry Pi.

Note: for all these instructions I assume your main mcpi directory is in the pi directory. If it isn’t you will need to change these instructions to match your setup.

1. Make Minecraft Pi Executable

In your main mcpi directory you need to make the Minecraft file executable. To do this open a terminal, navigate to the main mcpi directory and make Minecraft executable the following commands:

cd ~/mcpi
chmod +x minecraft-pi

2. Find an Icon

Next thing we need is an icon for our desktop shortcut. You can make your own or search for one online. Personally, I just use the logo for Minecraft Pocket edition, which can be found here.

Save the file into the main mcpi directory and call it logo.png (or whatever other extension you’re using e.g. logo.jpg).

3. Create a File on the Desktop

Navigate to the Desktop directory within the pi directory using the terminal and create a new file called “minecraft.desktop” with the nano text editor:

cd ~/Desktop
nano minecraft.desktop

Now right click and paste the following code into the file:

[Desktop Entry]
Name=Minecraft Pi
Comment=Creative Block Game

Save and exit the file. You should now have a Minecraft Pi shortcut on your desktop. When you double click it the game should launch. If the icon doesn’t show up immediately try restarting the desktop or rebooting the Pi.

Have fun with Minecraft Pi. If you want to learn more about Minecraft Pi, check out my API tutorials. I have also written a free book for learning Python programming with the Minecraft Pi API that is available here.

Minecraft Pi API: Setting Up


Minecraft Pi Edition can be a very fun and engaging way to learn programming.

For beginners getting started can be the biggest hurdle. There are a number of brilliant sources that demonstrate some really cool examples of what can be achieved – check out Martin O’Hanlon’s Stuff About Code. However, it can be a bit overwhelming for most beginners to break apart the code to find out how it works and use the Minecraft Pi API for their own ideas.

In this series of posts I’ll cover the basics of using the Minecraft Pi API. This post will concentrate on setting up the API for use with Python and creating a basic program to teleport the player. Following posts will explain different components with simple examples.

First things first. We will be using the Python programming language. No idea what that is or where to learn about it? Programs are a way of giving a computer instructions. Python is one programming language that we can use to write these instructions. You will be able to follow the explanations in this series without knowledge of Python, however I’d recommend you check out for excellent (and free) Python tutorials.

Setting Up

First off we need to install Minecraft Pi Edition on our Raspberry Pi. Follow the instructions on

Alert: the last instruction for installation is slightly wrong. You need to run this code instead to open the game:


After you’ve installed Minecraft and have familiarised yourself with the game, we can start start writing programs to interact with it.

Create a new directory to store your programs. Copy the mcpi directory located inside Python API directory into the directory you’ve just created. To achieve this in a terminal type in the following command after navigating to the directory you’ve just created:

cp -r ~/mcpi/api/python/* .

Alternatively to do this with a file browser, navigate to the above directory, copy the mcpi folder and paste it into the folder you just created. We are now ready to start programming.

Teleporting the Player

Open IDLE on your Raspberry Pi, create a new file and save it as in the folder the folder you just created. We will write your first program in this file.

Every program that interacts with the Minecraft Pi API has the same two lines at the start. These lines connect our program to the game. Copy these two lines into your program:

import mcpi.minecraft as minecraft
mc = minecraft.Minecraft.create()

In the same file we’re going to write some code to teleport the player to a new location. Copy this code into your program after the first two lines:

x = 1
y = 24
z = 1

In IDLE click on the Run menu, then Run Module. Your character should now teleport to the coordinates (1, 24, 1). If this doesn’t work make sure you are in a Minecraft Pi game world. If you get a black screen, you’ve just teleported inside of a block – change the numbers next to x, y and z and rerun your program to fix this.

How this works: In our program we have created 3 variables x, y and z. A variable stores a piece of data, in this case a number. We then give these numbers to the setTilePos() function, which connects to your Minecraft game and tells it to move your player to the coordinates you have set as numbers in x, y and z.

Try playing around with different number values of x, y and z. Use negative numbers. See what happens if you teleport off the map (hint: you’ll either die or your game will crash). If you’ve built several amazing things in Minecraft and want a quick way to travel to them copy the code into a different a file for each and change the coordinates to match the building.

Have fun and check back in the future for more Minecraft Pi API tutorials.

If you are interested in learning more about Python programming with Minecraft Pi or using it in a classroom/club, check out my free book that is available here.

Python Programming with Minecraft Pi: Early Draft


When I first heard that Minecraft would be released for the Raspberry Pi I punched the air. The nice people at Mojang had just given me the perfect platform to teach students programming: a creative platform. One where students are encouraged to explore ideas in a familiar environment, while seeing the tangible results of their efforts.

Minecraft Pi uses an application programmer interface (API for short) that allows programmers to interact with a Minecraft game world. Students can combine the API into their own Python programs to do things like place blocks, teleport the player or access hidden features like chat. For example they can create a castle with code in a few seconds, instead of building it by hand (which takes ages). Using Minecraft Pi to help students learn programming has the potential to be very engaging and effective.

That is why I have developed a book of resources to teach Python programming with Minecraft Pi.

The Book

The book consists of a series of exercises and documentation developed to test a student’s understanding of Python and also develop their problem solving skills. Each chapter uses differentiation, challenging students with more complex exercises as they progress and offers a number of extension tasks for every exercise. The content was developed to be used alongside Codecademy’s Python track and has documentation for each concept introduced.

Codecademy is my favorite resource for learning to program. Instead of rewriting the wheel, I decided that students should complete a Codecademy lesson and then attempt the corresponding exercises in the book. The exercises draw from the same Python concepts introduced at Codecademy, yet require the students to develop stronger problem solving skills.

The book is free to use and is open source. This means you can share it with whoever you want without giving me any money. The source of the book will be available in the near future if you want to modify it. A teacher’s answer book and an API reference sheet are also included.

Right now the book is incomplete, especially in the later chapters. The vast majority of content is there, some bits are missing, and a lot of it needs polishing. I am just about to start teacher training and won’t be able to dedicate any time to the book for the next few months. After previewing the book to a number of people at the York Raspberry Jam, the demand was so great that I decided to release it as soon as possible so that people had access to these resources. I do plan to finish the book, I’m just not sure when I will have the time. If you are interested in helping to further develop these resources please get in touch.

Any constructive feedback is very appreciated. Please let me know if you decide to use the resources in the classroom or in a club as I would love to hear about it. Feel free to adapt the resources to your own needs and please share them with others.


The files are really small despite the number of pages. Small enough to fit on a floppy disc. I’d recommend copying the main book onto each student’s Raspberry Pi, keep the teacher notes to yourself (which contain all the answers) and print a copy of the cheat sheet for each student.

Student Exercise and Reference Book
Teacher Notes

API cheat sheet

Other Minecraft Pi Resources

Martin O’Hanlon’s Minecraft Pi Programs

David Whale’s Minecraft Pi Flashcards

MCPIPY – Python Programs

Just to note, I am not affiliated with the Raspberry Pi foundation, Mojang/Minecraft or Codecademy. They probably don’t endorse these resources.

The Value of Raspberry Jam

“Wow, that makes learning to program really accessible. I’ll finally have my household of robotic servants in a few years thanks to this device and the army of young techno-geniuses it creates” is the usual response when I tell someone about the Raspberry Pi. Since discovering the Raspberry Pi I have been a strong believer in the foundation’s mission to inspire a new generation of makers and computer programmers. The hardware cuts the cost barrier for children who want their own computer, around the price of a Christmas present from Grandma. The default operating system and software also remove the ridiculously steep learning curve of installing a powerful Linux operating system and using it to learn to program. In other words, they’ve got the hardware and software sorted.

The major challenge that faces the Raspberry is the access and visibility of teaching and learning resources. Without access to resources many people will have no guidance or starting point for learning to program. Guidance and support is essential when starting on the road of programming. Starting is the biggest and hardest step in the journey and without a helping prod in the right direction, the sad fact is many beginners will give up and let their Raspberry Pi gather dust. Saying that, luckily there are some amazing resources out there, the only problem is finding them and knowing where to start. That’s where Raspberry Jams come in.

Due to the magical powers of their founder, Alan O’Donohue, Raspberry Jams have been around longer than time itself. In essence Raspberry Jams are gatherings of Raspberry Pi enthusiasts and beginners from all walks of life. They’re held worldwide and during the Jam a series of presentations, workshops and informal chats give attendants the opportunity to share their ideas, resources and enthusiasm.

Raspberry Jams are therefore an amazing place for beginners to start their journey with the Raspberry Pi. By the end of any workshop, participants, young and old, are guaranteed to learn new skills. Through networking (in the business buzz-word sense, not in the wires, internet and magic sense) like-minded people meet and share ideas. Some walk away with solutions to their problems, many are inspired to try something new and others join forces to collaborate and develop resources that others can use.

At Raspberry Jams, amazing people come together and do amazing things. The community that surrounds the Raspberry Pi is just as essential as the device itself. What often evades our gaze is that, as with any technology, the Raspberry Pi is not about circuits and bits, it’s about people. They are the people on the ground sharing their knowledge, skills, and enthusiasm so that the Raspberry Pi can achieve its mission. They provide the spark that ignites the imagination of young ladies and men, who in a matter of years will achieve things that far surpass our dreams of robotic servants.

Of course Raspberry Jams are just one piece of the puzzle. Over the life of this blog I will focus on making learning to program accessible. Look out for my upcoming blogs on  free resources for learning to program on the Raspberry Pi. I’ll also recount my experience at my first Raspberry Jam in another post where I’ll give you concrete examples of the value of Raspberry Jams.

Ninja-IDE on the Raspberry Pi


Ninja-IDE is an integrated development environment (IDE) designed for Python. I’ve been using it for a couple of weeks and it’s already my favorite IDE. It has a number of features that really set it out from the crowd:

  • It identifies how to make your Python 2.7 compatible with Python 3
  • Extensions are easy to find and install using the menu, including support for git and other repositories
  • Designed specifically for Python so it only includes the features you need (it’s mostly written in Python as well)
  • Cross-platform compatibility means you can run it on different operating systems with a familiar interface
  • Clear and logical layout
  • Free and Open-source
  • It looks really cool and has a cool name…

I’ve been running Ninja-IDE 2.0 on my Raspberry Pi and it runs surprisingly well. There are no problems with performance on either of my Model B, however I my Model A had a slight performance problem when using the Projects feature.

Update: Ninja-IDE is now available on the Raspbian repository. At the moment the program crashes when I launch it after installing it from the repository. I will try to find out if the problem exists on my end. If you want to test it out for yourself and see if it works on your Raspberry Pi, install Ninja-IDE using apt-get by running the following commands in a terminal:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install ninja-ide

If installing from the repository doesn’t work for you, you can install Ninja-IDE from source using the following instructions (I have used this approach and it works perfectly for me):

1. Install Dependencies
Ninja-IDE requires several other packages in order to run on your Raspberry Pi. To get these packages open up a terminal and input the following code:

sudo apt-get update && sudo apt-get upgrade

sudo apt-get install python-qt4 libjs-jquery pyflakes

2. Download Ninja-IDE from GitHub
Still in the terminal, we’re going to download Ninja-IDE from GitHub. In the terminal move to the directory that you want to install Ninja-IDE and input the following code:

git clone git://

3. Run It
Assuming everything’s worked properly you should now be able to run Ninja-IDE on your Raspberry Pi. Terminal yourself into the newly created ninja-ide folder and open the IDE with the following code:

cd ninja-ide

4. Make it Executable (Optional)
Now you’re running Ninja-IDE on Raspberry Pi, you may get impatient having to open a terminal every time you want to use it. It’s also annoying that closing the terminal window also closes the IDE.

Surely there’s a better way? There is. We’ll make Ninja-IDE executable, meaning you can open it from the file browser or from the terminal without the preceding python command. While in the ninja-ide directory run the following to make the IDE executable:

chmod +x

5. Desktop Shortcut (Optional)
What’s even easier that opening the program from a file browser? Running it from the desktop. After you’ve completed all of the above steps you can create a shortcut on the desktop. Move to the Desktop directory with the following command in the terminal:

cd ~/Desktop

Now we need to create a file in this directory to run Ninja-IDE. Run the following in your terminal to open the nano text editor with a new file called ninja.desktop:

nano ninja.desktop

Now paste the following into the text editor:

[Desktop Entry]
Name=Ninja IDE
Comment=Integrated DeveLopment Environment for Python

Save the file and exit. The most important lines in this file are Exec=… and Icon=… make sure the directories match up to the ninja-ide directory. If you placed this in the pi directory you won’t need to change the file.

Brilliant. You should now be able to use Ninja-IDE. Check out the developer’s website and show them some love on Twitter @ninja-ide.