learning python through minecraft on the raspberry pi - worksheets

4
Task 1 is tesng your file handling & typing skills on RaspPi. Step1/ open IDLE. Step2/ Try to copy the code without making any mistakes. Step3/ Save it in /home/pi/mcpi/api/python/mcpi as task1.py Step4/ Go to /home/pi/mcpi/ & start MC Step5/ Build a house like normal Step6/ When you are ready for a challenge—run the game (F5) Task 2 is about Looping, Sleeping & Moving the player with Python. Step1/ Create a new python script or change your old one! Step2/ Save it in /home/pi/mcpi/api/python/mcpi as task2.py Step3/ Type in the code so that the script repeatedly - Waits for a bit. THEN Teleports You! Step4/ Press F5 & return to MC to play with it.

Upload: manchesterbudo

Post on 09-Jun-2015

482 views

Category:

Education


0 download

DESCRIPTION

Learning Python through Minecraft on the Raspberry Pi - Worksheets

TRANSCRIPT

Page 1: Learning Python through Minecraft on the Raspberry Pi - Worksheets

Task 1 is testing your file handling

& typing skills on RaspPi.

Step1/ open IDLE.

Step2/ Try to copy the code without

making any mistakes.

Step3/ Save it in

/home/pi/mcpi/api/python/mcpi

as task1.py

Step4/ Go to

/home/pi/mcpi/

& start MC

Step5/ Build a house like normal

Step6/ When you are ready for a

challenge—run the game (F5)

Task 2 is about Looping, Sleeping &

Moving the player with Python.

Step1/ Create a new python script

or change your old one!

Step2/ Save it in

/home/pi/mcpi/api/python/mcpi

as task2.py

Step3/ Type in the code so that the

script repeatedly -

Waits for a bit.

THEN

Teleports You!

Step4/ Press F5 & return to MC to

play with it.

Page 2: Learning Python through Minecraft on the Raspberry Pi - Worksheets

Task 3 is practising your looping &

introducing 3D cords, vars & if.

Step1/ copy the code.

Step2/ Test the script by digging.

Step3/ How deep do u have 2 dig?

Change it.

Step4/ How high RU teleported?

Change it.

Step5/ Try to create a Wormhole.

Step6/ Attempt the extension task.

Tip: change xyz.y

to xyz.x

Find the xyz of your

minecraft home.

Task 4 is about using the minecraft

chat window to show python vars.

Step1/ copy the code.

Step2/ Test the script by moving

around on minecraft.

Step3/ What are all the numbers?

(Ext—Can you “format” them?)

Step4/ remember the if statement?

if xyz.y>some_number:

Step5/ Use the postToChat method

to send a funny message.

Tip: If height is greater than

50 then

say “Ha ha”

Page 3: Learning Python through Minecraft on the Raspberry Pi - Worksheets

Task 5 builds things next to where

the player is currently standing

Step1/ copy the code.

Step2/ it may be easier to

understand the code if you press

enter after each comma.

Step3/ setBlock needs 2 things-

An xyz position to build at

&

A type of block to build.

Change where the blocks appear.

Change the colour of the blocks.

Task 6 introduces us to “for” loops.

Step1/ copy the code.

Step2/ Make the Tower taller then

shorter.

Ext—Make the tower multicoloured

Step3/ Use a “nested” for loop to

build a wall.

Tip:

for column in range(0,10):

for row in range(0,10):

Build(row,column,10,WOOL)

Ext—Build a Rainbow (hard!)

Page 4: Learning Python through Minecraft on the Raspberry Pi - Worksheets

Task 7 gets you building out

of different materials

Step1/ Read the code.

Step2/ Try to explain to the

person next to you what the

code does.

Step3/ What is “red” doing?

Change this variable name as

you type the code in.

Step4/ What is countUp

doing?

Change this var to countAlong

Step5/

Change the Torch to a Train.

Try to add wheels, windows…

Task 8 gets minecraft talking to

python & python talking back

Step1/ Read the code but wait!

Step2/ Do you understand what

the first two lines are doing?

Type them up without looking at

the sheet.

Step3/ Why does the code say y-1

How could we change it to find

out which block is in front of us?

Step4/ What does the + do in line

5? Change it to comma.

What does the str do?

Try it without str.

Step5/ Make sure you try the EXT