Hi Everyone!

Dr. Guthals here again today and I want to show you a project that one of our high school volunteers, Christian, made without any assistance! He made this project by working through LearnToMod and knowing a bit about Redstone (which there are lot’s of videos and books on it if you haven’t learned it yet).

I wanted to give you all an example of the amazing problem solving and computer science-y projects that your students could work on! I especially like the idea of having students write a report (like this one) up to describe their process. Communication is a big part of coding – if you can’t communicate what you have done, how will anyone know? 🙂

I’ll let him describe:

Finished Product : http://mod.learntomod.com/program_profiles/297590

Background:

I’ve personally always loved working with redstone, I loved the logic and challenge behind it, you can always make a circuit smaller, faster, and quieter, so it makes sense that the first thing I’ve made in LTM is a replication of one of my favorite redstone machines, a number display.  With redstone, the physical aspect of it always made this machine quite large, the need for inverters, gates, and repeaters always made it quite slow, and the piston logic I use in my adders and flip flops make it loud. However, with Blockly, you can make a displayer as small as the display, as fast as the server can handle, and silent.

Screen Shot 2015-07-20 at 9.27.19 AM

The Goal:

My goal for this project was simple.  Take a number (less than 100) said in the Minecraft chat and display it on a screen, through blocks.  I separated this goal up into three distinct parts:Screen Shot 2015-07-20 at 9.28.25 AM

  1. Turning the number in chat into two numbers, the tens and ones digit.
  2. Take the tens and ones digit and turn them from numbers into a picture.
  3. Draw the numbers onto a screen.

Part 1: Distinguishing the Digits

Given a two digit number, I have to break it up into the digits in my program.  In order to find the tens digit, I divide the number by 10 and then round it down.  For example, the number 58 would turn into 5.8, and then 5 after I round it, giving me the 10s place.  In order to find the ones digit, I found the remainder of the number divided by 10.  For example, the number 58 over 10 is 5 remainder 8, which is the 1s place.

Screen Shot 2015-07-20 at 9.29.38 AM

Part 2: Picturing the Numbers

If you’ve ever made a redstone display, you know that part of the machine with the bunch of torches that converts an integer into the sections of a number.  This is that part.  If you haven’t, which I expect, I have another, more clear way of explaining it.

Screen Shot 2015-07-20 at 9.30.48 AM

Everyone (I hope) has seen an older digital clock, you know the ones with the faint 8s with the sections that light up in order to display different numbers? The logic inside of the clock tells it, if you want to display 1, turn on the two right vertical lights and leave the rest off.

If you want to display 0, turn everything on except for the middle band.  This is exactly what I try to do in my program,

First, each display in a clock has 7 sections, two standing up on the left, two standing up on the right, and three horizontal in the middle, so I create a list with 1 repeated 7 times.  In this case, each entry in the list represents one light, the first one represents the middle light, the second represents the top left vertical light, the third represents the top, and it continues this way clockwise around the clock.  In my list, 1 represents ON and 0 represents OFF, so by creating this list that looks like [1,1,1,1,1,1,1], I turn all of the lights on, making an 8.

Thing is, I don’t want to display an 8 all the time!  If the number is a 0, I want to turn off the middle light, or the first number in the list.  Therefore, I set the first number in the list to 0, making the list look like [0,1,1,1,1,1,1].  If the number is a 1, I want to turn off the horizontal lights and the left lights, so I make the list look like [0,0,0,1,1,0,0].

Screen Shot 2015-07-20 at 9.31.24 AM

Step 3: Drawing the Pictures

Just like you’d draw a picture with a drone, in my program I have to draw the numbers.  However, I have to draw the numbers with the ‘lights’ in mind, the list of which lights are on and off should determine what the number looks like.

In my program, I make the display really small, just one block per lamp.  When displaying the ones digit, the drone starts at the middle of the entire display.  First, I move it to the middle of the ones number, two right.  Then, I ask if the first digit in the list is 1.  If it is, I destroy the block, and if not I don’t.  Then I move to the second light, one up and one left, ask if the second digit in the list is 1, rinse and repeat until I complete the whole display.  After checking all of the lights, I return the drone to its spot in the middle of the display.

Screen Shot 2015-07-20 at 9.32.02 AM

Conclusion:

Patching these sections of code together with some (a ton of) logic, I completed the program.  However, just like how redstone can be improved, so can code.  While writing this post, I realized that the index variable in step 3 is not needed, and may be making my code harder to understand.  There’s always things to touch up, like the disabled debugging blocks, and there’s always a better way to code things.  Also there’s a ton of ways to use this programs in your own programs.  You could use it to display how many mobs are left in your monster arena, or the points each player has earned in spleef.

If you want a little practice, you could stitch together the little blocks of code shown in the post.  The logic, figuring out how to plan a program, is the hardest part of programming and the most essential towards building harder things and tackling larger problems.  The implementation is just practice, and changes between all languages, but the logic always stays the same, even between redstone and Blocky.

Good luck,

Christian

GET STARTED TODAY! Code, Customize, Learn

Why wait? Start modding Minecraft today! We’ll be there to help every step of the way!

Sign up online