Tuesday, 13 June 2017

EduBlocks blog 4: The Liverpool Makefest Minecraft Pixel Art twitter bot

Over the last few weeks I have been developing the EduBlocks Minecraft Pixel art Twitter bot that you can use if you are attending Liverpool Makefest on 24/06/17. 

I will be updating this blog over the coming weeks with a full write up of how to create your own version.  I have used the following Raspberry Pi tutorials as part of this build:

Here is what I want it to do........

1. Provide a quickish way(5mins approx) of people being able to create some Minecraft Pixelart without being able to forced to sit and code for 20 mins. 

2. Furthermore share their creation with the world via Twitter. Ideally use a Microbit to trigger the tweet. (This is still hit and miss)

Current review: It does one and two is still in the mixer. 

Here is version one which worked perfectly:

Here is version 2, which doesn't work so reliably when it comes to the Microbit part. 
Version 3: the lid is back on and microbit now working :)

With an internet connection, currently over wi-fi the twitter part works :) 

here are three examples of some of my trials:

I'll keep you posted with more when it gets updated.

Over :)

for micro:bit taken from RPi tutorial :
while True:
    if pin0.is_touched():
        display.scroll("say cheese!")
Code for Twitter bot:

from gpiozero import Button
from time import sleep
from signal import pause

from datetime import datetime

import subprocess
#from mcpi.minecraft import Minecraft
from mcpi import minecraft as minecraft
from time import sleep, time
import sys

from twython import Twython
#once you have created your own Twitter app put in your info below

consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
mc = minecraft.Minecraft.create()

api = Twython(consumer_key,consumer_secret,access_token,access_token_secret)
def Tweet(handle):
    timestamp = datetime.now().isoformat()
    msg = "#LivMF17 Pixelart bot! look what "+handle+" created at "+timestamp 
    a=subprocess.check_output('./raspi2png -d 3 -p "myscreenshot.png"',shell=True)
    photo = open('myscreenshot.png', 'rb')
    api.update_status_with_media(status=msg, media=photo)
button = Button(4,pull_up = False)
while True:
    handle = input("please type in your twitter handle")

here is the link for the Block ids sheet I've borrowed them from and Raspberry Pi spy this is sourced in the document:


No comments:

Post a Comment