Java Notes

Hey Coders!

I said I would upload the java code we worked on Saturday, so here it is. Remember that the file name needs to be the same as the class name (So make sure to save this in Test.java!)

import java.util.Scanner;
 
public class Test
{
public static void main(String[] args)
{
int age;
float favouriteNumber;
String name;
 
//In class we used i = i + 1, i++ is the same thing!
for (int i = 0; i < 10; i++)
{
System.out.println("Hello World!");
}
 
//Scanner is a program built into java that lets you get input from the user
//through the keyboard.
Scanner scanner = new Scanner(System.in);
 
System.out.print("What is your age? ");
age = scanner.nextInt();
System.out.print("\nWhat is your favourite number? ");
favouriteNumber = scanner.nextFloat();
System.out.print("\nWhat is your name? ");
name = scanner.next();
 
//Finally we close the scanner. If we try to use it after we close it the program will crash!
scanner.close();
 
System.out.println("Your name is " + name + ", your age is " + age + " and your favourite number is " + favouriteNumber + "!");
/*Is the exact same thing as we had on screen:
System.out.println("Your name is "
+ name
+ ", your age is "
+ age
+ " and your favorite number is "
+ favouriteNumber
+ "!");*/
 
//Remember, the "//" means it's a comment and is ignored when the code is compiled.
/* This is a comment too but can go on for
more than one line! */
}
}

In 3 weeks we will be looking at how to make functions in java, and then we will be ready to start robocode!

Latest Minecraft Server information – August Update!

A lot of Coders have been asking for this so here we go, WE HAVE A NEW MINECRAFT SERVER! You will find all the information about it here. It is still in testing but you are welcome to join and try and break it! Please comment and let us know how you get on!

**Check this page often, any information about the server will be posted here!**

We have a new version of the modpack, with some mods added and some removed. If it’s your first time downloading the modpack, you can follow the instructions below. Otherwise, you’ll need to delete the folder with the old modpack in it, and then you can follow the instructions below again.

Due to popular demand we again have an online Minecraft* server! Again we are using a modpack** along with loads of plugins*** in order to keep order on the server. The modpack is not like we had before (The Feed the Beast Lite pack, Tekkit pack****) but a completely custom made pack made by one of the gaming class! It contains many cool and important mods such as ComputerCraft for computers in game, BuildCraft so we can have quarries and machines that do amazing stuff, BiblioCraft so we have a lot of furniture, and a whole lot more! You will need to purchase a minecraft premium account in order to play on the server.

*Minecraft: Minecraft is a game in which you both mine materials, and then craft them. You can also build things. It’s like Lego!
**modpack: A modpack (In relation to Minecraft) is a collection of separate modifications for the game. Minecraft modifications add new features to the game, such as ComputerCraft which allows us to both use and program computers!
***plugins: Plugins are portions of code that only run on the server. They allow us to decide who can build in certain areas, remove bad players and loads of other cool things.
****Feed the Beast Lite|Tekkit: These were the modpacks that we used to run.

The pack we have we are calling the The Coder Pack (This is not to be confused with the Minecraft Coder Pack, which is the tools you actually use to modify Minecraft). Below are instructions to get your game up and running, and then connect to our server!

Requirements:

Playing a modified version of Minecraft usually does require a pretty good computer. If you are playing on an older computer you might have a bit of trouble, but give it a shot.

Installation:

  1. Download the ATLauncher here. Click Windows at the bottom if you are running Windows on your computer.
    1
    Once you do that you need to put the ATLauncher file into an empty folder, like this:
    2
    When that’s done open the file, and it’ll create the folders you’ll need for you:
    3
  2. Download the pack, available here.
  3. Extract the zip file into the “Instances” folder that the AC Launcher created:
    4
  4. In the AT Launcher, on the instances tab now should be The Coder Pack. If it does not show up, click on the account tab and log into your minecraft account.
    5
  5. Hit play and it should start!

From there minecraft will start running. Because this is modified minecraft it could take a few minutes to start up. Once it does you can play it in single player to get used to it, and once you are you can connect to the server.

Connecting:

The server is at 198.20.117.69. To connect to this easily click the add a server button, call it the Monaghan Coderdojo Server, and put that IP address in as the address. Hit connect and you should then be logged in, have fun!
Server Stats

Details:

The server is running using BeastNode.com minecraft hosting service. Because we are running a special modpack it did take quite a bit more configuration to get it running than a normal server needs!
We are using Forge as a base to run the server. Forge is a program that allows us to both run minecraft modifications. Unlike before when we used MCPC+ we could use both forge and bukkit mods and plugins, now we just use forge instead. This means the server will be a lot more stable than it was before! We would appreciate it very much if you would let us know if you encounter a bug. You can leave a comment below and we will get back to you as fast as we can.

Competition Deadline – Next CoderDojo!

Hey Guys!
At the next CoderDojo on Saturday 12th April we will be reviewing the entries for the Superjet Robot Dinosaur competition. Remember to have your entries ready to give to us in the morning. As always if you are stuck on something just let us know and we’ll help (or point you in the right direction!). Everyone who enters will get a t-shirt. There will be a winner from each group in the dojo, and each winner will win a raspberry pi. The overall winner will also win a Rapiro Robot, so make sure to have your entries ready!

Apologies for not doing the minecraft server class at the last CoderDojo. We had a problem with the internet switch again, so we didn’t have internet for the people in my class on laptops… If we have time and a working switch at the next dojo we’ll do it then. Still planning to look at port forwarding (so again I’ll be going into a little bit of how networks and the internet work, make sure to bring your thinking caps!) so you’ll understand how to set up a simple minecraft server at home.

See you all at the next CoderDojo!

Unity/Minecraft Server class Update

Hey guys!
In the games development class we’ve been working on loads of different things recently, such as more Unity! We also had a couple of weeks to look at blender 3D as well so we could see how 3D models are made. We then also this week had a look at Paint.net. It’s a little bit like Microsoft paint but has some cool extras like layers and transparency support.
At the bottom of this post are a couple of things: 2 unity projects and a pdf of how I made one of the projects. The games are very similar but teach a lot of the basics of unity such as building prefabs, instantiation, removing objects from the world, and then the programming that holds it all together.
For the next Minecraft class I’ll be looking at how we can open ports so we can have someone running a minecraft server at home! In this weeks class I looked at the various files that the minecraft server program generates, how to edit the files, whats in them and what happens if you change them!

See you all next week!

Unity Game PDF
Alien Shooting Game
Space Hopper

Random directions and bouncing

Yesterday, Robbie was unable to take the Unity3D class so I stepped in and helped out. Of course, in time-honoured substitute teacher tradition, I didn’t know the subject before the class, but had to bungle my way through anyway!

Unity3D is a 3D engine in the same vein as Blender. Personally, I would push to adopt Blender instead, as it is completely free (Unity3D has a “free” version, but it’s limited, and the licensing is quite high for hobbyists! Also, it doesn’t work on Linux), but Unity is what we are using.

So, I watched Robbie’s videos, which helped a lot! Robbie – those are awesome. After watching each of the videos once, I knew enough about Boo and Unity3D to get on with the job.

During class, we had the usual hiccoughs – some people (myself included) didn’t have Unity3D installed at first, some people played games, and there was an annoying song being played at the back of the class (you know who you are!). These are the trials that make teaching fun 😉

After a quick introduction to trigonometry (cosine, sine, and radians), we started work on the actual job at hand.

By the end of class, we all were at reasonably the same stage – we had the pong ball moving in a random direction, and were able to bounce the ball off the top and bottom walls.

Overall, I thought the class went well – there were two kids who were unable to get Unity installed at all because of some uninformative errors, but we mostly bungled through okay.

Next week, we’re back to normal – Robbie will be back to talk about pong paddles, and I’m off to take some guys from Gordon’s class and show them the wonders of CSS.

What language should you learn?

Zach at Codecademy <contact@codecademy.com> has written a useful post on what language is best for what —

People often ask me what programming language they should learn, and I always say the same thing: “It depends.”

Want to be more web savvy, or build a website? — start with Web Fundamentals. This covers all the basic HTML and CSS you’ll need to know to understand the web.

Want to make a game or app? — give JavaScript a try. This dynamic language will let you create interactive apps that you can use on a smartphone.

Want to process data or explore databases?Ruby or Python are your best bet.

That’s it! Like what you’re learning now? Click here to continue learning.

— Zach

The Minecraft Robot Wars

The server is up and running now! The ip address is 93.189.6.35:25572. Remember to use Feed the Beast Lite to connect, and it must be Feed the Beast Lite 1.2.1 to connect to the server!

Team 1 Detonators

 

Kayla

Daire

Nikolem

Shane

Kevin

Lúí

Osin

Conn

Peter

 

Team 2  Orange Monkey Eagle

Jake

Oisín

Eoin

Darren

Shane Maguire

Luke

Bobby

Fachtna

 

Playing Field

175 blocks wide

175 blocks long

Height tbd

Feed the beast lite

Robot

Heart of lava between lev 75 and 100

50 blocks wide

50 blocks deep

max 100 blocks high

75 blocks between robots

 

Rules

  1. Best of three
  2. No Nukes
  3. 1 TNT per launch
  4. Lava Heart so that when it blows it will rain fire on robot
  5. No Mining Lasers
  6. No Players Outside of robot
  7. Build in creative. fight in survival
  8. Each Team gets an obsidan chest 1 row building mats and 1 row redstone.
  9. I Iron Chest for each Cannon
  10. 2 flying robots per team, can only use 1 at a time, robot has to reload after each bombing raid
  11. 5 non moving sentry robots
  12. 10 turtle robots per team (programmable only)
  13. 75 blocks of bedrock( must be a minimum of 10 blocks from heart and not on the same plane)
  14. 150 blocks obsidan
  15. 100 blocks reinforced stone
  16. 50 blocks reinforced glass
  17. 1000 blocks concrete
  18. Stack of food each
  19. 2 arms per robot
  20. Teleport only inside your own robot.

 

Lua – Working with turtles

I hope everyone learned some new things today! We looked at getting the turtles in ComputerCraft up and running about, and also programming them to dig quarries for us! So now it’s on to you guys, there is no CoderDojo next weekend so I recommend working on something for the competition!

Remember – The competition is whoever makes the best Robot related project (Can be Scratch, ComputerCraft, LOVE, even something else) will win a robot. Nice! I’d enter the competition too but I’m really busy… 😀

For those who always seem to forget, the IP address of the server is 93.189.6.35:25572.

Anyway this post will explain what we did in the dojo today, and hopefully will explain anything I went over a bit too quick. Also I hope that what we did today put some pieces together on how Lua and ComputerCraft all work together.

First we looked at getting a turtle to move around. We had to first give them some fuel, then run the program refuel all. That takes everything in it’s inventory and increases the turtles fuel level, meaning it can move. Then we ran the go program with these arguments:

go forward
go backward
go up
go down
go left
go right

And those commands do what they say on the tin. Remember the go program is another program that someone wrote, and the next argument (forward, backward) tells the program what to do. Then, we ran the lua command prompt (the lua program, so we can type lua statements directly) and found that the turtle movement api commands are similar to what the go program did but also slightly different, like this:

go forward – Moved the turtle forward, but waited if there was something blocking it. If the turtle is out of fuel it will print this on screen.
turtle.forward() – Returns a boolean value to say if it could move forward or not. Doesn’t wait if something is blocking it, returns false instead. Also returns false if the turtle is out of fuel.

The rest were the same:

turtle.back()
turtle.up()
turtle.down()
turtle.turnLeft()
turtle.turnRight()

Also in the turtle API we found that mining turtles (Turtles with a diamond pickaxe) can dig too! So we wrote a little program in order for the turtle to dig a quarry for us, and here it is:

local hitBedrock = false
local amountMovedDown = 0
while not hitBedrock do
 turtle.digDown()
 if not turtle.down() then
  hitBedrock = true
 else
  amountMovedDown = amountMovedDown + 1
 end
end

for i=0,amountMovedDown do
 turtle.up()
end

You can also get this code using a mining turtle and running the command pastebin get 69dbBGYE mineDown will download the quarry program, and you can then run it by running the mineDown program.

2013-05-25_22.29.18

2013-05-25_22.27.24

In the image you can see the fruits of our labour! After that, we made a mini mob farm, and had the turtles attack anything in front of them. It’s a really simple program, it’s the turtles attack function in a loop!

while true do
 sleep(0)
 turtle.attack()
end

2013-05-25_22.30.11

The pastebin code for the turtle is pastebin get a52U8pZU turtleAttack, and to run the program run turtleAttack.

Finally, for the last part we built the traditional password protected door. Except this time if you get the password wrong the turtles attack you!

2013-05-25_22.31.14

The code for the computer at the door is:

rednet.open(“back”)
while true do
 term.clear()
 term.setCursorPos(1,1)
 print(“Please enter the password”)
 password = read(“*”)
 if password == “password” then
  print(“You got the password right!”)
  redstone.setOutput(“left”, true)
  sleep(3)
  redstone.setOutput(“left”, false)
 else
  print(“You got the password wrong! lololol”)
  rednet.broadcast(“attack”)
 end
end

And the code for the turtles is:

rednet.open(“right”)
while true do
 local senderID, message, distance = rednet.receive()
 if message == “attack” then
  turtle.attack()
 end
end

The command to download the door computer code is pastebin get EmP5WE3i doorCode and called doorCode, and to get the turtle program run pastebin get 7yhYKtTm turtleListener and is called turtleListener.

2013-05-25_22.31.57

The new thing in this code is the rednet api commands. These allow you to send messages from one computer to another, in this case if the user puts the password in wrong the turtles will attack whoever is standing at the door!

The rednet.open(<side>) commands basically turn on the wireless modem for the computer and the turtle. If the computer or turtle doesn’t have a wireless modem this command will return false, but won’t really affect the program… Except for it not working properly! The rednet.broadcast(<message>) command sends the message to every computer in its range that is currently listening (that is, running the rednet.receive() command to listen) and the rednet.receive() command listens for rednet.broadcast(). rednet.receive() returns a few more variables than usual functions, in this case it returns the senders ID (senderID), the message itself (message) and the distance the message travelled (distance). This program only cares about the message though, and the first thing it does is check if the message it got was the string “attack”. And if it is, the turtle will attack whoever is standing in front of it!

2013-05-25_22.32.21

So I hope you guys had fun learning today! If you have any questions post it in the comments below, though I’d rather questions about the code or new code than about the server 😛

This week in Lua

Just before we start…

Todays Lua class got really packed today. There were just too many people, so starting next week I’m gonna be moving people from the class. You have to show me something you have done using computercraft to stay in the class, mostly because too many people are playing minecraft and not coding. I’ll be sending people to the scratch and the website coding classes. In order to stay in the class you need to come up with a project of some kind using Lua (so that can be minecraft, or anything else that uses Lua).

This week we looked at creating a very basic calculator. The code is avaliable here: http://pastebin.com/4dymt0UK . You can also run this command on a computer in minecraft to download the code: “pastebin get 4dymtoUK calc”. You can then run it by typing calc, or use edit calc to see the code (I recommend using notepad++ to edit it though!).

What I want you guys to do is extend it… Add subtraction, multiplication and division! And maybe even add a way to put more numbers into it. You could even change whats in it so far to an advanced monitor! If you have any questions about that just comment on this post, or ask me in game.

The code for the turtle that can solve the maze is here too: http://pastebin.com/JrkEgwGR, or “pastebin get JrkEgwGR mazesolve”. It’s a very basic maze solve algorithm that just follows the right wall until it eventually finds the light block. There are loads of potential solutions to the maze problem, you can see them here. Wouldn’t it be awesome if someone made a program that even generates mazes, places the maze, and then uses a turtle to solve it?…

And finally next week we are going to start making games using Lua! We will be using an engine called LOVE2D. To understand it what we will do is start making things in it that you should have already done in Scratch.

See you’s next week!