Search This Blog

Thursday, August 25, 2016

The first day of PyCraft

After signing up for the lessons over at homeschoolhackers and making the paypal payment, you are granted full access to both the PyCraft server (survival) and the PyCraft (creative) servers.
The servers are white listed and monitored for activity that is not appropriate. Haven't had any issues yet but if there ate then we email the parent of the offender.

Lesson 1 is given to you to review and try a quick positioning script. It is an easy script but often there are errors (spelling, capitols, signs) that I explain to the student in a return email. The script is still added to the server for the student to use. It tells you the exact position on the MC game board.
The coordinates, I find are a hard thing to grasp at 8 years old so we go through it in a detailed format.



X = side to side
Y = up and down
Z = front to back

It takes practice. There is no other way around it but practice. If you dig into the ground the Y coordinate goes negative. So you need to think in terms of positive and negatives. If you set your current position and work from that, you can go -x or +x depending on the direction you move.
Like I said it literally takes practice to get good at it. We will get into terms of relative and actual in more advanced lessons.

Lesson 2 so far (and all these lessons are subject to be modified if I start getting feedback on them)
is moving from one spot to another using your python script from lesson 1. We can learn how easy it is to teleport to any area on the board (game). In fact we have a very popular script called /py jump that teleports you to the very top of the MC world. I have it set where you do not die if you fall. But the reason we do this so often is the elytras. We have a command block that gives them out and the players all fly around the world with /py jump.
The lesson ends with a mc.setBlock() function that spawns any block on the block list located here.

Lesson 3 is still in production. So far it is a two part lesson as I have assigned software that links to the PyCraft server so students can write and debug their scripts in real time. For instance they open up the pycraftscript and write a line of code to spawn a block of stone. So at the bottom of the script they write mc.setBlock(pos,1) hit f5 (assuming they are using an ide like IDLE) and the block appears around the user.
This is a survival server. Health and food are in play so being able to spawn food like a melon (mc.setBlock(pos,103)) comes in handy quickly.

I also start teaching the basics of laying down more than one block at a time with the mc.setBlocks() function. For instance, if I wanted to build a pillar of stone that is 5 blocks high. I could build it with 5 lines of mc.setBlock() or one line of mc.setBlocks(). I would have a starting point and an ending point for my Y coordinate. Something like this:

lets set variables for the xyz:
x,y,z = mc.player.getTilePos()
now lets build the pillar:
mc.setBlocks(x,y,z,x,y+5,z,1)

notice how the first set of x,y,z has no numbers next to it. We are starting from the exact point we are standing. Y is up and down and we are starting at 0 going up to 5. the number 1 is the id for stone.

When we run this it will push us out of the way as no two entities can occupy the same space.

If I wanted to lay 5 blocks out on the ground I would use the x, or z, coordinates with y at 0

I realize it seems confusing. The more you write it and change the numbers the better of an understanding you will gather.

I encourage the students to  work on a house script. I tell them that they will progress through the color system we have by displaying the homes they work on. Some kids who have finished the second lesson work on their homes and the scripts get well over a 100 lines of code. the mc.setBlocks() method can cut all that work down to less than half.
Just a quick example for a floor is.

mc.setBlocks(x-5,y-1,z-5,z+5,y-1,z+5,BLOCKid)

this is about 100 lines of code with mc.setBlock()

As the lessons materialize (i do lessons based on the student feed back from the prior lesson,, always a work in progress to update them. I will update this page.

-spohnz





No comments:

Post a Comment