Minecraft Pocket Edition - now with carrot cake.

Since discovering that you can play Minecraft on your phone, one thing has been bothering me. You can take flour, eggs, milk, and sugar to make a cake, or flour and cocoa beans to make chocolate chip cookies, or even pumpkin, egg, and sugar to make a pumpkin pie, and yet despite having a perpetual surfeit of carrots, there is no way for me to craft a carrot cake - the best cake that there is.

Delightfully, even though this is a phone app, there are various ways to add your own items and patches. On Android, I used BlockLauncher Pro (£2.54, or the identical free version, which has ads). This allows you to add custom texture packs and little scripts in ModPE. It was difficult to find a comprehensive tutorial or documentation, so I used other people's scripts, this useful function list, and trial and error to work out how to create my cake.

I started by making an icon for the cake. It needs to be a 16 x 16 PNG.

Large pixel art carrot cake

This is the image that will be shown in the inventory, and will be held in the player's hand.

To tell Minecraft PE to use it, you need to zip it up in the correct folder structure. The path to the image is 'images/items-opaque/carrot_cake_0.png'. In the root of the folder is a meta-data file called 'pack.mcmeta'. This contains the description of your image pack:

{
  "pack": {
    "pack_format": 1,
    "description": "Carrot cake!"
  }
}

I put these all together into Carrot Cake Texture.zip. To install this, download the file, then open up BlockLauncher and click on the spanner at the top of the screen. Then go to 'Texture Pack', 'Select', and pick the file out of your Downloads folder. This step doesn't do anything particularly exciting, but it comes into its own when we add some javascript.

In a new file, called 'carrot_cake.js', we can define the new item.

ModPE.setFoodItem(501,"carrot_cake","carrot_cake",6,"Carrot Cake");

ModPE.setFoodItem is the command to add a new edible object. Each item in Minecraft has a unique ID. I picked 501 for the carrot cake, because it hasn't been used yet. "carrot_cake" is the name of the picture to use from the texture pack - this is defined by taking 'carrot_cake_0.png' and removing '_0.png'. 6 is the number of half hunger points you gain by eating the carrot cake. Finally we define the name that is shown to the user, 'Carrot Cake'.

Next, we want to make the cake available in the inventory in Creative Mode, by using its ID of 501:

Player.addItemCreativeInv(501,1,0);

Next, I wanted to be able to make a cake out of carrots, wheat, egg, and sugar. You can look up the item IDs of items in Minecraft to do this step. Carrot is 391, sugar is 353, egg is 344, and wheat is 296.
Item.addCraftRecipe(501, 1, 0, [391, 2, 0, 353, 1, 0, 344, 1, 0, 296, 1, 0]);

To use this, download carrot_cake.js and open up BlockLauncher, then click on the spanner and go to 'Manage ModPE Scripts'. Press 'import' and find the file in your Downloads folder. Now if you go back to the main menu and open up your game, you should be able to make yourself a lovely cake!

...

Ada Lovelace Hackathon


Image courtesy of Sydney Padua

Ada Augusta Byron was born on December 10th, 1815, daughter of Lord and Lady Byron (yes, that Lord Byron). After her parents' separation, her mother, determined that Ada stay as far away from poetry as possible, encouraged her interest in mathematics and logic.

During her childhood, Ada developed an interest in flying, and took to studying the mathematics of 'Flyology', creating wings based on the proportions of birds.

Through her tutor, Mary Somerville, Ada met the inventor Charles Babbage. Babbage was obsessed with building a calculating machine called the Analytical Engine, which, had it ever been built, would have been the first computer. Babbage and Lovelace became great friends and corresponded about the Engine and other mathematical topics.

An Italian mathematician, Luigi Menabrea, wrote a description of the workings of the Analytical Engine. Being an accomplished linguist, Ada set about translating this work into English. She added a few notes of her own to the translation – the notes ended up being longer than the original text, and contained what is commonly thought of as the first ever computer program.

Lovelace's legacy goes beyond her groundbreaking code – she also thought deeply about the scope for computation in everyday life, predicting mathematical music, and neuronal modelling.

Back in November, the folks at the Oxford Hackspace kindly hosted our hackathon to celebrate the life and works of Ada Lovelace.

Continue reading Ada Lovelace Hackathon

...

<IRC channel> plays <game>

You might remember Twitch Plays Pokémon, which was a game of Pokémon Red played by an entire chat room of people.

A wonderful friend of mine is getting married soon, and for her hen do I thought it would be fun to set up the same thing for us.

Playing Pokemon Red as a team

There's a really great project on GitHub called TwitchPlaysX, which lets you do exactly this. The instructions in the readme are fairly self-explanatory for putting it together in Ubuntu, so what I did for the hen do was to set it up using debootstrap. It occurred to me afterwards, however, that it would have been fairly straightforward to put it together in Debian, so what follows are instructions for doing that.

The easiest way to get node.js installed is to install it from source. Do:

wget https://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz
tar -xvf node-v0.12.7.tar.gz
cd node-v0.12.7
./configure
make
sudo make install

Next, you copy over the code, and install all of the dependencies.

git clone https://github.com/hzoo/TwitchPlaysX.git
cd TwitchPlaysX
npm install
sudo apt-get install xdotool

Finally, you need to make a configuration file.

vim config.json

The one below lets you use a normal IRC server instead of a Twitch chat. This means that you can have everyone at a party install an IRC client on their phone, connect to a channel, and start playing. Android users can use AndroIRC, and iPhone users can use Colloquy. You need to pick a name for your channel; in the instructions below, we will call it "this_channel", and we'll be using the Freenode IRC server.

To connect to the channel in AndroIRC, press the "+" symbol, select freenode, choose a nickname, and then type "/join this_channel". In most other IRC clients, type "/server irc.freenode.net", then "/nick your-nickname", then "/join this_channel".

Save the following text in the config.json file:

{

"TWITCH_IP": "irc.freenode.net",
"TWITCH_USERNAME": "God",
"TWITCH_CHANNEL": "#this_channel",
"CONFIG_OS": "other",
"CONFIG_PROGRAM_NAME": "ZSNES",
"CONFIG_MAX_CHAR_NAME": 20,
"CONFIG_MAX_CHAR_COMMAND": 20,
"CONFIG_SEND_KEY": true
}

I have CONFIG_PROGRAM_NAME set to ZSNES, because I was playing Legend of Zelda in my channel. If you want to play a Gameboy game, use "VisualBoyAdvance" instead. The commands that get sent are "a", "b", "x", "y", "s", and "e". To set ZSNES to use these, open it up, go to CONFIG, then INPUT, then press SET KEYS and press the appropriate keys when prompted, using "s" for "start" and "e" for "select".

To get it running, make sure that you have ZSNES open, and then do:

npm start

Connect to your IRC channel and start typing commands: they should show up in the console, and your game should start to play. This was a seriously fun way to spend an evening, especially if you have friends who write IRC bots off the cuff for fun. Other bits of revelry from the evening included a rousing game of "Pin the Gonad on the Nematode Worm", and a custom version of Cards Against Humanity.

Custom Cards Against Humanity

For Community fans, I think a really good game to play this with would be Journey to the Centre of Hawkthorne.

...