Minecraft: Pi Edition- How to Use Python @Raspberry_pi #piday #raspberrypi
This tutorial from MakerSpace UK is a great intro into using python and your Raspberry Pi with Minecraft:
First, we have to do a bit of setting up. To keep our code separate to the original code in the MCPI folder, we will make a new directory to keep all of our code in. In LXTerminal, type mkdir python This will make a directory called python. To use the MCPI API we will have to copy that folder over to our new directory. Make sure that you are in your new directory (cd python) and then type the following command: cp -r ~mcpi/api/python/* . Include the full-stop one space after the *!
Finally, we are ready to start coding. By default, the API only uses Python 2. x but you can change this to allow Python3 use as well by following this link, however, I will not be going in to that today, for now, we will stick with Python 2. I will also be using the command line text editor nano but you can use other text editors if you wish.
Our first task is to make the file that we will run. Make sure that you are in your new directory, then type cd mcpi followed by sudo nano block_placer.py This should open up an empty file in nano. The first two lines of code are import minecraft and then import block underneath it. Next, we have to connect to our Minecraft world which we do by typing mc = minecraft.Minecraft.create() This first example will simply place a block at a set of co-ordinates, so first, we will define three variables, one under the other, called x, y and z.
Each Friday is PiDay here at Adafruit! Be sure to check out our posts, tutorials and new Raspberry Pi related products. Adafruit has the largest and best selection of Raspberry Pi accessories and all the code & tutorials to get you up and running in no time!
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, or even use Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for MakeCode, CircuitPython, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.
Python for Microcontrollers — Python snakes its way on the SparkFun SAMD21 Mini, Hackaday.io, 10k thanks, and Tim’s magazine #Python #Adafruit #CircuitPython @circuitpython @micropython @ThePSF @Adafruit
Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !