D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] python - minecraft pi

 

It looks to me to be due to the way you're passing the blocktype.

STONE is defined in blocks.py (Block(1)) when you use import block.

Have you tried forcing str.upper on blockname?

On 16 May 2013 11:58, "Paul Sutton" <zleap@xxxxxxxxx> wrote:
Hi

I am playing around with python and the minecraft pi api

the following code should produce a line of stone blocks

import minecraft
import block

#Initialise
mc = minecraft.Minecraft.create()

#Produce a line of blocks
for x in xrange(0, 10):
    mc.setBlock(x, 15, 0, block.STONE)

I can change STONE to something else in the code.

I am trying to create a modification so a user can specify a block to
produce by the script

import minecraft
import block

#Initialise
mc = minecraft.Minecraft.create()

#list of blocks can be found here http://www.piprogramming.org
#/wiki/index.php?title=Minecraft_Block_Types_List

#Ask what block is required
blockname = raw_input("block type ? ")

#Produce a line of blocks
for x in xrange(0, 10):
    mc.setBlock(x, 15, 0, block.blockname)

so take input and store as block name the pass this on to
stone.blockname so it comes up with the required set of blocks,

this doesn't seem to be working properly though

any ideas as to where I am going wrong, it should be simple enough to
pass user input to something.

I am probably just missing something simple

thanks

Paul




--




--
http://www.zleap.net

http://www.linkedin.com/pub/paul-sutton/36/595/911

I am committed to safeguarding children, young people and vulnerable groups and expect any school or establishment I am involved with to share this commitment.


--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq
-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq