Tuesday, 24 January 2017

Your first explosive hack with minecraft and Python




The first place to start with python maybe hello chat/ world but the first really engaging one that people seem to enjoy is walking blocks. With the change of a block ID you can really alter the impact that block has in your world. The most obvious one that people always want to know is how to blow up TNT. Back in May I got bored and made this enjoy and go blow up some blocks.  

This video takes you through from start to .......... finish. 

Sunday, 22 January 2017

#Hackpack blog: MineGraph

How to create a real time graph using the sense hat emulator and Minecraft on Raspberry Pi


Firstly if you are just looking for the code: here it is https://raw.githubusercontent.com/ncscomputing/Hackpack/Volume-5/MinegraphSHEmuv1.py

Here is a straight copy of the code:

"""
Written by @ncscomputing v2 to work  with Pi Sense hat emulator on Pi not web based.
"""

import mcpi.minecraft as minecraft
import mcpi.block as block
import time
import random
from sense_emu import SenseHat

sense = SenseHat()

mc = minecraft.Minecraft.create()
orx,ory,orz = mc.player.getPos()

mc.postToChat("Start Graph")

blockTypeList=[35,45,3,4,5,6]
DataStreamList = []

DataStreamCount= 0

def BuildDataBlock():
    temp = int(sense.temp)
    DataStreamList.append(temp)
    orx,ory,orz = mc.player.getPos()
    block = random.choice(blockTypeList)

    for i in range (0,temp):
        x,y,z = mc.player.getPos()
        mc.setBlock(x,i,z,block)
    mc.player.setPos(orx,ory,orz+1)
    msg = "Temp currently is:",temp 
    print(msg)
        
while True:
    BuildDataBlock()
    time.sleep(4)




Here is a simple intro to how to get it to work:

  • It works with the sensehat emulator which is included by default on the Raspian OS. You can find it in Menu > Programming > Sense Emu.
  • Once that is loaded open Minecraft Pi which can be accessed Menu > Games > Minecraft
  • Create a new world and then using the space bar position the character up in the sky. If you press space down for about 5-6 seconds that should be high enough.
  • Open Python 3 Menu > Programming > Python3 and open the Python Code above and press F5
  • The code should then run.
  • It should start drawing bars as above. If you are not happy turn it off and retry. The temp is adjustable by the SenseHatEmu interface their is a temp slider adjust it up or down accordingly.
  • N.B. The code is not perfect but it does work last time I tested.
Enjoy :) Over

Chris Penn

Thursday, 19 January 2017

Eagle Labs Raspberry Jam



When I saw on twitter last June / July that Barclays were opening an Eagle Lab in Birmingham(Les Pounder's retweet was the reason that I saw it :). I then asked them if they would follow the Cambridge Lab by having a Raspberry Jam?  they seemed open minded to the idea..... well in August we had the 1st Eagle Labs Jam about 18/9 people turned out in what is a super plush building smack bang next to Aston Uni in Birmingham.

At the 1st event I had help from the very kind Martin O' Hanlon, Spencer Organ and Scott Turner who kindly gave talks.

For the second event we had about 19 people again and Martin returned to hack with breadboards and stuff like this http://www.stuffaboutcode.com/2017/01/raspberry-pi-4-digit-7-segment-display.html
with a very keen chap from Leamington.

a famous box....


A massive thank you to the chap who traveled for 4 hours to come to an event I have organised, this was very humbling.

Stewart Watkiss aka Penguin tutor came with neopixels galore and a big thank you for your continued support in 2 recent Jams in August in Coventry.
Spencer Organ kindly ran his Festive Minecraft Python coding session with his Pi Top Ceeds in his travel suitcase most impressive indeed that arrangement. (For the record 6 ceeds).

Lastly there was even a bit of Pi Zero Retro Pie gaming going on.....

A massive thanks for all the help from Spencer and Stewart and Martin.  Plus Tim from Code Club for coming to. 

Many thanks to Barclays Eagle Labs for proving a free community space in an awesome building. 

See you all again for Eagle Labs Jam 3 later this summer. 

Over :)

Chris Penn