[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
Yeah, that should work, you'd want to specify int() on the input though.
Then you could replace block.blockname with block.Block(x) where x is your input variable.
Or maybe find a way of looping through the constants defined in blocks.py to match your original string input to its block number?
On 16/05/13 12:12, Adam wrote:
>
> 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?
>
hmm not yet
I know I can replace BLOCK with anything i want, e.g STONE, TNT etc, I
just thought this could be represented with a variable.
when it asks, I am typing TNT or STONE, or other block name, am I doing
the right thing here or should i be looking at 2nd of the 2 columns for
the purpose of the program.
STONE = Block(1)
So rather than entering STONE should i look to capture Block(1) as the
input?
Paul
> On 16 May 2013 11:58, "Paul Sutton" <zleap@xxxxxxxxx
> <mailto: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
>
>
>
--
--
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