Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- displayName = "Hanging blocks"
- inputs = (
- ("Replace", "blocktype"),
- ("With", "blocktype"),
- ("Frequency %", (50, 0, 100)),
- ("Length %", (50, 0, 100)),
- ("Check above", False),
- )
- def perform(level, box, options):
- mat1 = options["Replace"]
- mat2 = options["With"]
- frequency = options["Frequency %"]
- length = options["Length %"]
- mode = options["Check above"]
- blockAbove = False
- if mode:
- first = True
- for x in xrange(box.minx, box.maxx):
- for z in xrange(box.minz, box.maxz):
- for y in reversed(xrange(box.miny, box.maxy)):
- if level.blockAt(x, y, z) == mat1.ID:
- if first:
- if randomGen() <= frequency and blockAbove:
- level.setBlockAt(x, y, z, mat2.ID)
- first = False
- else:
- blockAbove = False
- else:
- if randomGen() <= length and blockAbove:
- level.setBlockAt(x, y, z, mat2.ID)
- else:
- blockAbove = False
- else:
- blockAbove = True
- blockAbove = False
- first = True
- level.markDirtyBox(box)
- else:
- first = True
- for x in xrange(box.minx, box.maxx):
- for z in xrange(box.minz, box.maxz):
- for y in reversed(xrange(box.miny, box.maxy)):
- if level.blockAt(x, y, z) == mat1.ID:
- if first:
- if randomGen() <= frequency:
- level.setBlockAt(x, y, z, mat2.ID)
- first = False
- else:
- break
- else:
- if randomGen() <= length:
- level.setBlockAt(x, y, z, mat2.ID)
- else:
- break
- first = True
- level.markDirtyBox(box)
- def randomGen():
- return int(random.random() * 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement