# -*- coding: cp936 -*-
import mcpi.minecraft as minecraft
import time
mc = minecraft.Minecraft.create()
outtime=0
OUT_X=52#定义起点坐标常量
OUT_Y=10
OUT_Z=27
count=1#尝试次数刚开始是1
mc.postToChat("第%d次"%count)#显示第1次代表游戏开始
while True:
time.sleep(5)#每5秒记一次时
pos = mc.player.getTilePos()
#以下是房间的3个矩形区域
if(pos.x>=46 and pos.x<=49 and pos.z>=23 and pos.z<=25):
outtime+=1#计时加1
mc.postToChat("%d"%outtime)#在聊天框显示计时
elif(pos.x>=45 and pos.x<=49 and pos.z>=26 and pos.z<=29):
outtime+=1
mc.postToChat("%d"%outtime)
elif(pos.x>=45 and pos.x<=48 and pos.z==30):
outtime+=1
mc.postToChat("%d"%outtime)
if(outtime>=3):#当计时超过3
mc.player.setPos(OUT_X,OUT_Y,OUT_Z)#重新设定人物坐标
outtime=0#归零计时器
count+=1#尝试次数加1
mc.postToChat("第%d次"%count)#显示接下来是第count次
#但这个程序无法裁判玩家是否铺满了房间,也无法在玩家回到起点时消除掉刚才铺上的地板
还没有评论,来说两句吧...