Hardware Reference
In-Depth Information
Start up Minecraft, IDLE, and if you are working on a PC or a Mac, start up the server
too. You should have had a bit of practice with starting everything up by now, but refer
back to Adventure 1 if you need any reminders.
1. In IDLE, create a new text file by choosing File New File from the menu. Save
the file as tips.txt .
2. Now list four or five tips, using one line of text for each tip. Here are a few example
Minecraft tips, but it's much more fun if you make up your own. Make sure you
press the Enter key at the end of each line, so that this creates a newline inside the
file for each line. (You will find out more about newlines later in this adventure.)
Build yourself a house before the mobs come and get you
Use flowing water to fill underwater channels
Build up with sand then knock out the bottom block
Use both first-person and third-person views
Double tap space bar to fly into the sky
3. Save this file. You don't run this file, as it is not a Python program but a text file
you're going to tell your Python program to use.
A newline is a special invisible character that the computer uses to mark the end
of a line of text.
It is also sometimes called a carriage-return , which is historic from the days of
mechanical typewriters. Whenever you wanted to type on the next line of the
page, you would use the carriage return, which would make the carriage return to
the left of the page and then down by one line.
Don't use commas in your tips.txt file, or in any messages that you ever use
with mc.postToChat() . There is a small bug in the Minecraft API, where any
comma inside the message text causes the message to be cut off at that position.
Now you have a data file with tips in it—in other words, input data—it's time to write
the program that processes that input data. This program will read a random tip from
the file and display it after a random interval on the Minecraft chat. Then, while you
are playing your game, helpful tips will pop up on the chat.
Search WWH ::




Custom Search