if __name__ == "__main__" dosent do anything

133 views Asked by At

I made my code simpler here but I think I have also narrowed down my question. name dosent equal main when this is run by mcedit as a filter, so are you supposed to compare name to something else other than main that its called by another program, making main PlaceBlock instead still didnt work either?

from multiprocessing import Process
from pymclevel import alphaMaterials

displayName = "PlaceBlock"

def perform(level, box, options):

    x = box.minx
    z = box.minz

    def block(height):
         level.setBlockAt(x, height, z, 1)

    print(__name__)
    if __name__ == "__main__":
        print('Processing')
        p1 = Process(target=block, args=(1, ))
        p2 = Process(target=block, args=(2, ))

        p1.start()
        p2.start()

    p1.join()
    p2.join()

Also to answer a question in the comments, this a filter for a minecraft program called mcedit to edit worlds, filters are just programs that edit the worlds. So this program dosent actually do anything unless you have the program

2

There are 2 answers

1
T54 On

Your script will only function in MCEdit Unified.

pymclevel cannot be run outside of MCEdit.

You don't need to write a script to do this. If you hold alt down it will reveal the coordinates of your cube pointer. Go to the point in the world where you would like to place the block and use the fill and replace tool to make fill that coordinate with the block you want.

0
Magnificant Marshmellow On

After a lot of messing around it turns that it was not running the right file in the processes, it would run the main program which is why it opened a second version of the program, so I put in a execution file change to open python instead of the program and it works fine!