Indenting Question - Raspberry Pi Forums


hi. found python program online minecraft pi edition unfortunately not indented @ did best fix since new python didn't work fix me please!!??! :)

code: select all

import minecraft.minecraft minecraft #import minecraft block module import minecraft.block block #import time, delays can used import time #import threading, threads can used import threading  class explodingblock(threading.thread):     def __init__(self, pos, fuseinsecs, blastradius):         threading.thread.__init__(self)         self.pos = pos         self.fuseinsecs = fuseinsecs         self.blastradius = blastradius  def run(self):     mc = minecraft.minecraft.create()  #get values     pos = self.pos     blastradius = self.blastradius  #explode block!  # block type     blocktype = mc.getblock(pos.x, pos.y, pos.z)  # flash block fuse in range(0, self.fuseinsecs):     mc.setblock(pos.x, pos.y, pos.z, block.air)     time.sleep(0.5)     mc.setblock(pos.x, pos.y, pos.z, blocktype)     time.sleep(0.5)     x in range(blastradius*-1,blastradius):     y in range(blastradius*-1, blastradius):     z in range(blastradius*-1,blastradius):     if x**2 + y**2 + z**2 < blastradius**2:     mc.setblock(pos.x + x, pos.y + y, pos.z + z, block.air)      if __name__ == "__main__":          time.sleep(5)  #connect minecraft creating minecraft object  # - minecraft needs running , in game  mc = minecraft.minecraft.create()  #post message minecraft chat window  mc.posttochat("minecraft bombs, hit (right click) block, www.stuffaboutcode.com")  #loop until ctrl c  try:      while true:          blockhits = mc.events.pollblockhits()          if blockhits:              blockhit in blockhits:                  explodingblock = explodingblock(blockhit.pos, 3, 3)                  explodingblock.daemon                  explodingblock.start()                  time.sleep(0.1)                  except keyboardinterrupt:                      print("stopped") 

no promises perfect, pretty sure it's closer:

code: select all

import minecraft.minecraft minecraft #import minecraft block module import minecraft.block block #import time, delays can used import time #import threading, threads can used import threading  class explodingblock(threading.thread):     def __init__(self, pos, fuseinsecs, blastradius):         threading.thread.__init__(self)         self.pos = pos         self.fuseinsecs = fuseinsecs         self.blastradius = blastradius      def run(self):         mc = minecraft.minecraft.create()          #get values         pos = self.pos         blastradius = self.blastradius          #explode block!         # block type         blocktype = mc.getblock(pos.x, pos.y, pos.z)         # flash block         fuse in range(0, self.fuseinsecs):             mc.setblock(pos.x, pos.y, pos.z, block.air)             time.sleep(0.5)          mc.setblock(pos.x, pos.y, pos.z, blocktype)         time.sleep(0.5)         x in range(blastradius*-1,blastradius):         y in range(blastradius*-1, blastradius):         z in range(blastradius*-1,blastradius):         if x**2 + y**2 + z**2 < blastradius**2:             mc.setblock(pos.x + x, pos.y + y, pos.z + z, block.air)  if __name__ == "__main__":     time.sleep(5)      #connect minecraft creating minecraft object     # - minecraft needs running , in game     mc = minecraft.minecraft.create()      #post message minecraft chat window     mc.posttochat("minecraft bombs, hit (right click) block, www.stuffaboutcode.com")      #loop until ctrl c     try:         while true:             blockhits = mc.events.pollblockhits()             if blockhits:                 blockhit in blockhits:                     explodingblock = explodingblock(blockhit.pos, 3, 3)                     explodingblock.daemon                     explodingblock.start()                     time.sleep(0.1)     except keyboardinterrupt:     print("stopped")


raspberrypi



Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support