Topic 3: Creating our First ScriptCraft Mods

2014-10-17_20.54.57

(Notes updated September 2015.)

Previous Topic: Connecting to Each Other’s Servers.

Our First Mod: sayhi.js

I’ll show you how to write a very simple one, sayhi.js, and then a more complex one, scraper.js. After that, it’s up to you to figure out what you can do!

In the Canarymod folder, find the folder scriptcraft / plugins, then make a new folder with your name (or any unique folder name).

Using Notepad++, type in the code shown below and save it in a file called sayhi.js. Here are explanations of what everything means:

sayhi-scriptcraft

Try it out in Minecraft and see if it works!

NOTE: Every time you create a new ScriptCraft program or edit one, you have to type /js refresh() in Minecraft to update your changes. If no commands run, make sure you are opped. (In the Canarymod window, type op <your_mincraft_name>).

To run it, type /js sayhi() in Minecraft.

A More Complex Mod: scraper.js

This makes the skyscraper shown above. We will figure out together how it works!

scraper-scriptcraft

Topic 2: Connecting to Each Other’s Servers

bukkit

(Notes updated September 2015.)

Note: This continues what we started in Topic 1: Getting Started with ScriptCraft and JavaScript.

Next step: Creating our first Scriptcraft mods. https://cdathenry.wordpress.com/2014/10/17/topic-2-connecting-to-servers-and-creating-our-first-mod/

Previously, we installed a Canarymod server and inside it we installed ScriptCraft, a mod that will allow us to build structures in MineCraft by writing JavaScript code.

Canarymod is a Minecraft Server. Therefore, the instructions we followed to connect to it were:

  • Start MineCraft, making sure it’s the same version (1.8 in our case)
  • Choose Multiplayer, then Direct Connect and enter localhost as the server address
  • If this works, in your CraftBukkit window you’ll see a message that you connected.

Here, localhost is actually means “the address of this local computer”.

But you can also connect to a friend’s computer, if you are all on the same network and you can find out their address. (If you are on different networks, things get a bit more complex: you will have to search online about how to set up port forwarding on your router, and you will probably also need a free Dynamic DNS service.)

On a local network, to find your IP address, open a command window. (In Windows, run or search for cmd.) In the command window, enter the command ipconfig and read through to find an entry like this:

Wireless LAN adapter Wi-Fi:
    Connection-specific DNS Suffix . :
    Link-local IPv6 Address . . . . . : fe21:9ba2:9db6:13e9%4
    IPv4 Address. . . . . . . . . . . : 192.168.1.17
    Subnet Mask . . . . . . . . . . . : 255.255.128.0
    Default Gateway . . . . . . . . . : 10.101.0.1

The IPv4 address is what you need. Get a friend to start Minecraft on their computer, then Direct Connect and enter your IP address. They will then be connected to the server on your computer!

This can be handy if you want to work on projects together.

Next step: Creating our first ScriptCraft mods.

Scratch Beginners – Week 2 – Adding More Functions to First Game

CDA-S3-Challenge01-FirstGame-Part2We had a great crowd for our second session of Scratch beginners. Julie did a great job as lead mentor in Martha’s absence.

This week, we added lots of new functionality to our first game: make things happen when Jaws catches the Diver and keeping track of lives.

Here are the presentation slides from the day, in PDF format: CDA-S3-Challenge01-FirstGame-Part2.pdf

See you next time!

Python Beginners-Week 2: Our First Real Game

We had a good turn out at the python group again today. We did a lot of typing which some of the younger Ninjas found hard going. We won’t be doing that much again for a few weeks. We did a number guessing game which contained some concepts which are used in most computer programs. Our number guessing game is explained in chapter four of “Invent Your Own Computer Games with Python” by Al Sweigart http://inventwithpython.com/chapter4.html

Beginners Scratch – Challenge 2 – Guess Numbers

Today’s challenge: write a number guessing game!

In doing this, these are the big ideas you will learn about:

  1. Input and output: entering numbers and displaying them
  2. Using variables
  3. Comparing values and making decisions

Here are my notes from the day, in PDF format: CDA-S2-Challenge02-GuessNumbers.pdf.

If you would like me to send you the PowerPoint slides of my notes, get in touch via twitter or by leaving a comment.

Advanced Scratch – Week 2 – Buttons and Crazy Images.

What are we going to learn this week…

  • How to imitate a Button
  • How to use the Pen controls
  • How to use sliders

Buttons.

 Wouldn’t it be great if you could have buttons in Scratch, that you can click and make things happen?

Well you can, there might not be a code block to do it, but we can make one.

 You will need a Sprite with Two Costumes

  • One for the Up position
  • One for the Down Position

 

See how I have given the Sprite a meaningful name and also each costume has a name. The only difference between the sprites is the bottom one has no shadow and is slightly lower and left (covering the shadow).

Cool Tip: You can export the Button Sprite which will save it with all the code as well. This means it is easy to add Buttons to any other Scratch Projects. 

Crazy Images.

We are going to use the Pen Tool to draw some fancy Spirograph like images.

First we need a Sprite that will do the drawing, I just created an invisible Sprite, so you only see the Line being drawn.

Spirographs work using circles, but we are going to use triangles, squares, pentagons, hexagons and heptagons (7 sided).

If you walk 10 steps turn 90 degrees and walk another 10 steps and again and again, you have wlaked in a square, but if you change either how many steps or the angle you turn by a very SMALL amount and just keep[ going you can generate some very interesting patterns.

Sliders.

We will also be using sliders to control the nember of sides to the shape and the change in angles.

Sliders are variables that are displayed on the screen with a slider control to change the value as the program is running. To get the variable to show as a Slider just dbl click on it, once, changes it to a Slider, dbl clicking again, removes the name.

If you right click on the SLider you can set Min and Max values.

The code to create the Spirals is split into two parts. One runs when youclick the Green Flag, this just sets everything up ready.

 

The next piece of code is what does all the work, notice where the Slider variables are used and how the code makes more sense when you give variables descriptive names.