minecraft房间加租金程序

来源:互联网 发布:淘宝总额今年双十一 编辑:程序博客网 时间:2024/04/28 06:06
# -*- coding: cp936 -*-import mcpi.minecraft as minecraftimport timemc = minecraft.Minecraft.create()rent=0#租金的初始值是0while 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):        rent+=1#如果判断到人物在这个区域,租金增加-rent值加1        mc.postToChat("%d"%rent)#并在聊天框显示总租金    elif(pos.x>=45 and pos.x<=49 and pos.z>=26 and pos.z<=29):        rent+=1        mc.postToChat("%d"%rent)    elif(pos.x>=45 and pos.x<=48 and pos.z==30):        rent+=1        mc.postToChat("%d"%rent)#因为是死循环,一旦开始运行,租金就从0开始,每5秒判断一次。#如果到第n个5秒时人物在房间里,租金就上涨1。#如果判断时人物在房间外,租金就不变化。