How to use the mcpi.settings.isPE function in mcpi

To help you get started, we’ve selected a few mcpi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github arpruss / raspberryjammod-minetest / raspberryjammod / mcpipy / sierpinski3d.py View on Github external
for p in bottom:
        yield (level+1,height/2.,average(apex,p))

def sierpinski(height, x,y,z, level):
    tetrahedra = [(0,height,(x,y,z))]
    for i in range(level):
        out = []
        for tet in tetrahedra:
            out += transform(tet)
        tetrahedra = out
    return tetrahedra

mc = Minecraft()
d = drawing.Drawing(mc)
pos = mc.player.getPos()
height = 240 if not settings.isPE else 128
levels = 7
mc.player.setPos(tetrahedronBottom(height,(pos.x,pos.y+height,pos.z))[0])
tetrahedra = sierpinski(height,pos.x,pos.y+height,pos.z,levels)
mc.postToChat("Drawing")
if len(argv) >= 2 and '__' not in argv[1]:
    specifiedBlock = parseBlock(argv[1])
    block = lambda level : specifiedBlock
else:
    block = lambda level : RAINBOW[level % len(RAINBOW)]
for tet in tetrahedra:
    drawTetrahedron(tet[1],tet[2],block(tet[0]))
github arpruss / raspberryjam-pe / p3 / scripts / lsystem.py View on Github external
#
# A more complex example with
# rules based on http://www.geekyblogger.com/2008/04/tree-and-l-system.html
#
    rules = {'A': '^f[^^f>>>>>>A]>>>[^^f>>>>>>A]>>>>>[^^f>>>>>>A]'}

#randomized version:
#    rules = {'A': [(0.75,'^f[^^f>>>>>>A]>>>[^^f>>>>>>A]>>>>>[^^f>>>>>>A]'),
#          (0.25,'^f>>[^^f>>>>>>A]>>>[^^f>>>>>>A]')]}

    axiom = 'fA'
    angle = 15
    thickness = 8
    length = 10 if mcpi.settings.isPE else 15;
    material = WOOD
    t.penwidth(thickness)
    t.penblock(material)

    stack = []
    def push():
        global length
        global thickness
        stack.append((length,thickness))
        t.push()
        thickness = thickness * 0.6
        length = length * 0.75
        if thickness < 1:
            thickness = 1
        if length <= 1:
            t.penblock(LEAVES_OAK_PERMANENT)
github arpruss / raspberryjam-pe / p2 / scripts / render.py View on Github external
self.controlFileLines.append("swapyz 0\n")
                self.controlFileLines.append("#credits Mesh by ..., copyright (c) ...\n")
                self.controlFileLines.append("yaw 0\n")
                self.controlFileLines.append("pitch 0\n")
                self.controlFileLines.append("roll 0\n")
                self.controlFileLines.append("size " + str(self.size) + "\n")
                self.controlFileLines.append("default STONE\n")
                self.controlFileLines.append("#order material position\n")
                self.controlFileLines.append("materials\n")
                self.haveMaterialArea = True
                self.endLineIndex = len(self.controlFileLines)
                self.controlFileLines.append("end\n\n")
                self.controlFileLines.append("[Insert any detailed licensing information here]")
                for line in self.controlFileLines:
                    f.write(line)
         if settings.isPE:
             self.size /= 2
github arpruss / raspberryjam-pe / p3 / scripts / mandelbulb.py View on Github external
#
#
# mandelbulb.py [size [power [half]]]
#
# Options for half: south, north, east, west, up, down

from mc import *
import mcpi.settings as settings
import cmath
import time
import sys
from random import uniform

# setting this to 0 makes for more isolated blocks because the connecting filigree was
# missed; increasing slows down rendering
AVOID_ISOLATES = 12 if not settings.isPE else 0

ESCAPE = 250
if len(sys.argv) < 2:
    size = 100
else:
    size = int(sys.argv[1])

if len(sys.argv) < 3:
    power = 8
else:
    power = int(sys.argv[2])

if power == 8:
    fractalSize = 2.16
else:
    fractalSize = 4.
github arpruss / raspberryjam-pe / p2 / scripts / mandelbrot.py View on Github external
#
# Code by Alexander Pruss and under the MIT license
#

from mine import *
import mcpi.settings
import cmath
import time
import sys

ESCAPE = 256
if len(sys.argv) < 2:
    SIZE = 640 if not mcpi.settings.isPE else 400
else:
    SIZE = int(sys.argv[1])

if len(sys.argv) < 3:
    formula = lambda z,c : z * z + c
else:
    formula = eval('lambda z,c : '+sys.argv[2])

black = block.WOOL_BLACK
#palette = ( block.WOOL_WHITE, block.WOOL_ORANGE, block.WOOL_MAGENTA, block.WOOL_LIGHT_BLUE,
#            block.WOOL_YELLOW, block.WOOL_LIME, block.WOOL_PINK, block.WOOL_GRAY, block.WOOL_LIGHT_GRAY,
#            block.WOOL_CYAN, block.WOOL_PURPLE, block.WOOL_BLUE, block.WOOL_BROWN, block.WOOL_GREEN,
#            block.WOOL_RED, 152 )


# palette generated by solving traveling salesman problems in RGB space
github arpruss / raspberryjam-pe / p2 / scripts / mandelbulb.py View on Github external
#
#
# mandelbulb.py [size [power [half]]]
#
# Options for half: south, north, east, west, up, down

from mine import *
import mcpi.settings as settings
import cmath
import time
import sys
from random import uniform

# setting this to 0 makes for more isolated blocks because the connecting filigree was
# missed; increasing slows down rendering
AVOID_ISOLATES = 12 if not settings.isPE else 0

ESCAPE = 250
if len(sys.argv) < 2:
    size = 100
else:
    size = int(sys.argv[1])

if len(sys.argv) < 3:
    power = 8
else:
    power = int(sys.argv[2])

if power == 8:
    fractalSize = 2.16
else:
    fractalSize = 4.
github arpruss / raspberryjam-pe / p2 / scripts / mengersponge.py View on Github external
else:
                        mc.setBlocks(posX,posY,posZ,
                                 posX+length-1,posY+length-1,posZ+length-1,block.AIR)
                else:
                    deleteCubes(posX,posY,posZ,length,nextColorIndex)

def slice(x0,y0,z0,length):
    for x in range(0,length):
        for y in range(0,length):
            for z in range(0,length):
                if x+y+z >= 1.5*length:
                    mc.setBlock(x0+x,y0+y,z0+z,block.AIR)

mc = Minecraft()
playerPos = mc.player.getPos()
if settings.isPE:
    length = 3*3*3
else:
    length = 3*3*3*3
if len(sys.argv) > 1:
    length = 3**int(sys.argv[1])
colorIndex = None
if len(sys.argv) > 2:
    colorIndex = 0 if 'c' in sys.argv[2] else None
mc.setBlocks(playerPos.x,playerPos.y,playerPos.z,
             playerPos.x+length-1,playerPos.y+length-1,playerPos.z+length-1,block.WOOL_PURPLE)
deleteCubes(playerPos.x,playerPos.y,playerPos.z,length,colorIndex=colorIndex)
if len(sys.argv)>2 and 's' in sys.argv[2]:
    mc.postToChat("Slicing")
    slice(playerPos.x,playerPos.y,playerPos.z,length)
github arpruss / raspberryjam-pe / p2 / scripts / lsystem.py View on Github external
#
# A more complex example with
# rules based on http://www.geekyblogger.com/2008/04/tree-and-l-system.html
#
    rules = {'A': '^f[^^f>>>>>>A]>>>[^^f>>>>>>A]>>>>>[^^f>>>>>>A]'}

#randomized version:
#    rules = {'A': [(0.75,'^f[^^f>>>>>>A]>>>[^^f>>>>>>A]>>>>>[^^f>>>>>>A]'),
#          (0.25,'^f>>[^^f>>>>>>A]>>>[^^f>>>>>>A]')]}

    axiom = 'fA'
    angle = 15
    thickness = 8
    length = 10 if mcpi.settings.isPE else 15;
    material = block.WOOD
    t.penwidth(thickness)
    t.penblock(material)

    stack = []
    def push():
        global length
        global thickness
        stack.append((length,thickness))
        t.push()
        thickness = thickness * 0.6
        length = length * 0.75
        if thickness < 1:
            thickness = 1
        if length <= 1:
            t.penblock(block.LEAVES_OAK_PERMANENT)
github arpruss / raspberryjam-pe / p2 / scripts / sierpinski3d.py View on Github external
for p in bottom:
        yield (level+1,height/2.,average(apex,p))

def sierpinski(height, x,y,z, level):
    tetrahedra = [(0,height,(x,y,z))]
    for i in range(level):
        out = []
        for tet in tetrahedra:
            out += transform(tet)
        tetrahedra = out
    return tetrahedra

mc = Minecraft()
d = drawing.Drawing(mc)
pos = mc.player.getPos()
height = 240 if not settings.isPE else 128
levels = 7
mc.player.setPos(tetrahedronBottom(height,(pos.x,pos.y+height,pos.z))[0])
tetrahedra = sierpinski(height,pos.x,pos.y+height,pos.z,levels)
mc.postToChat("Drawing")
if len(argv) >= 2:
    specifiedBlock = Block.byName(argv[1])
    b = lambda level : specifiedBlock
else:
    b = lambda level : RAINBOW[level % len(RAINBOW)]
for tet in tetrahedra:
    drawTetrahedron(tet[1],tet[2],b(tet[0]))
github arpruss / raspberryjam-pe / p3 / scripts / render.py View on Github external
self.controlFileLines.append("swapyz 0\n")
                self.controlFileLines.append("#credits Mesh by ..., copyright (c) ...\n")
                self.controlFileLines.append("yaw 0\n")
                self.controlFileLines.append("pitch 0\n")
                self.controlFileLines.append("roll 0\n")
                self.controlFileLines.append("size "+str(self.size)+"\n")
                self.controlFileLines.append("default STONE\n")
                self.controlFileLines.append("#order material position\n")
                self.controlFileLines.append("materials\n")
                self.haveMaterialArea = True
                self.endLineIndex = len(self.controlFileLines)
                self.controlFileLines.append("end\n\n")
                self.controlFileLines.append("[Insert any detailed licensing information here]")
                for line in self.controlFileLines:
                    f.write(line)
         if settings.isPE:
             self.size /= 2