1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#
# Code under the MIT license by Alexander Pruss
#
from mc import *
import sys
import time
from NeuroPy.NeuroPy import NeuroPy
mc = Minecraft()
#
# the True argument is needed for a BrainFlex unit hacked to work
# at 57600 using
# http://www.instructables.com/id/Mindflex-EEG-with-raw-data-over-Bluetooth/
#
eeg = NeuroPy("COM11",57600,True)
meditation = len(sys.argv) > 1 and sys.argv[1].startswith("m")
up = 60
down = 40
def callback(a):
mc.postToChat(a)
if a > up:
pos = mc.player.getPos()
pos.y = pos.y + 1
if mc.getBlock(pos.x,pos.y,pos.z) == AIR.id:
mc.player.setPos(pos)
elif a < down:
pos = mc.player.getPos()
pos.y = pos.y - 1
if mc.getBlock(pos.x,pos.y,pos.z) == AIR.id:
mc.player.setPos(pos)
if meditation:
eeg.setCallBack("meditation", callback)
else:
eeg.setCallBack("attention", callback)
mc.postToChat("Connecting to EEG")
eeg.start()
if meditation:
mc.postToChat("To fly up, be meditative")
else:
mc.postToChat("To fly up, be attentive")
while True:
time.sleep(10)
|