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
|
#
# WARNING: If you're running RJM on a server, do NOT include this script server-side for security reasons.
#
#
# Code under the MIT license by Alexander Pruss
#
# This script only works on Raspberry Jam
#
import mcpi.minecraft as minecraft
import time
from math import *
from mcpi.block import *
import code
import sys
def quit():
sys.exit()
def inputLine(prompt):
mc.events.clearAll()
while True:
chats = mc.events.pollChatPosts()
for c in chats:
if c.entityId == playerId:
print c.message
if c.message == 'quit':
return 'quit()'
elif c.message == ' ':
return ''
elif "__" in c.message:
sys.exit();
else:
return c.message
time.sleep(0.2)
mc = minecraft.Minecraft()
playerPos = mc.player.getPos()
playerId = mc.getPlayerId()
mc.postToChat("Enter python code into chat, type 'quit' to quit.")
i = code.interact(banner="Minecraft Python ready", readfunc=inputLine, local=locals())
|