ModderDojo Topic 4: Moving from Scratch to JavaScript

GeneralFeaturesOfProgrammingLanguages

Note: some individual topics are short: we got most of the way through the first 3 in our taster session. See this post: https://cdathenry.wordpress.com/2015/09/27/minecraft-modding-taster-session-week-1/

JavaScript is a well-established programming language, mainly used in web development. ScriptCraft is a Minecraft mod that allows you to write JavaScript code for building structures in Minecraft and writing new Minecraft mods. (So it’s a mod for creating other mods.)

Steps 1-3: Install ScriptCraft, Learn how to Connect to a Server, and Create a First Mod

We covered these steps in the first two weeks:

  1. Getting Started with ScriptCraft and JavaScript
  2. How to Connect to Each Other’s Servers
  3. Creating our First ScriptCraft Mods

To try out ScriptCraft, look back at the introductory posts here: https://cdathenry.wordpress.com/2015/09/27/minecraft-modding-taster-session-week-1/

Step 4: Comparing JavaScript to Scratch

Some people criticise Scratch as being “childish”, but I don’t agree. While it is designed so that even 8 year olds can use it, it is still has all of the key features of ‘adult’ programming languages, as listed in the image at the top of this post.

(Technically, any programming language with variables, decision and loops is Turing Complete.)

This means that, if you already know how to write a Scratch programs that use these features, you will be able to apply that knowledge to any other language, such as JavaScript. The syntax of JavaScript is different, but it uses the same computational thinking.

Variables-Operators

Loops

Decisions

Notes:

  • Even though they have basic ideas in common, every programming language has its own specific commands that relate to its purpose: Scratch is focused on 2D games and animations, while ScriptCraft is focused on operating inside Minecraft, and JavaScript generally is used for interactive websites.
  • the echo command that features in these slides is not a standard JavaScript command, it is just used in ScriptCraft to display things on your screen in Minecraft.  Everything else is standard JavaScript.

Week 2 – Scratch Beginners – Building on our first game

Hi everyone,

Great to see so many of you there on Saturday. This weeks starting point was our game from last week. We wanted to add extra functionality. We added code to the Heart so that something happened when the Hippo touched it. Most people added some sound.

hippo

sensing

We also made our first variable. We did this so that we could keep track of our score. Using this score we also could add code to make something happen when you reached a certain score and win the game. Again here we added a sound and switched backgrounds.

variable

We learned and used a lot of new code this week and we will see over the coming weeks how we can incorporate it into many different types of games.

Why don’t you try using all the code we have used so far to create your own game. We will take time at the beginning of next weeks session to look at any games that people want to show us.

yourgame

See you all next week!

Here are the notes from todays session in PDF CDA-S5-Week_02-FirstGame-Part2.pdf

Week 2 – 2015 Scratch Beginneers

Hi everyone,

This week we took a look at the open source graphics program called Paint.net

It’s a very useful piece of software for editing and working with photos and clip art. Over the next couple of weeks we will use it to clean up our photos of our 3D playdoh models or Lego figures.

PAINTNET

Here are the PDF version of the notes: CDA-S4-Challenge09-LearnAboutPainting.pdf

See you all next week

Week 2 – Scratch Beginners – Building on our first game

Hi everyone,

Great to see you all there on Saturday. This weeks starting point was our game from last week. We wanted to add extra functionality. We added code to the Snowflake so that something happened when the Penguin touched it. Most people added some sound.

sensing

We also made our first variable. We did this so that we could keep track of our score. Using this score we also could add code to make something happen when you reached a certain score and win the game. Again here we added a sound and switched backgrounds.

variable

We learned and used a lot of new code this week and we will see over the coming weeks how we can incorporate it into many different types of games.

Why don’t you try using all the code you have learnt so far to create your own game. We will take time at the beginning of next weeks session to look at any games that people want to show us.

yourgame

See you all next week!

Here are the notes from todays session in PDF CDA-S4-Week_02-FirstGame-Part2.pdf

Python Games – Week 2 : Preparing for our Adventure Game

We made fantastic progress again in the Python Games stream.

We covered Escape Characters, Functions and Boolean Logic (with a quick look at logic gates). Then we looked at the Dragon’s Realm game code available here.

We had a brainstorming session with some great ideas from the ninjas for our own adventure game which we are going to start coding next week.

DSC_0479

My slides from today are available here.python session_2

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.