Archive for the ‘Minecraft’ Category
I like to run my Minecraft server from a cron job so that I can have a script check once a minute if it’s running (and restart if if necessary, without any manual intervention). But that makes it very tricky to send commands to the server console to automate the backup. What to do?
A colleague of mine suggested using the “screen” command (here’s an example of using screen to automate Minecraft backups), but I hit upon another solution that I like better: I use a simple script to read commands from a file and echo them, and I launch the Minecraft server by piping my command reader script to it.
Here’s the script I run as a cron job to keep my Minecraft server running:
# check if the server is running and store that info in a variable:
RUNNING=`ps -ef | grep minecraft_server | grep -v grep`
if [ -n "$RUNNING" ]; then
# log the fact that it is running:
date > running.txt
# relaunch sequence
# stop the command reader:
echo stop > cmdfile
# give the command reader time to stop:
# clear the command file, in case the command reader wasn't running:
truncate --size 0 cmdfile
# log the restart and try again:
date > restart.txt
/home/myusername/bin/commandReader.sh world | ./launchserver.sh
I save that script in my bin folder as keepMinecraftRunning.sh and add this line to my crontab (using crontab -e):
* * * * * /home/myusername/bin/keepMinecraftRunning.sh
And here’s the commandReader.sh script that sends commands to the Minecraft server:
# set what time to make the backup:
# make sure the command file exists:
while [ "$COMMAND" != "$STOP_CMD" ] ;
if [ -n "$COMMAND" ]; then
truncate --size 0 cmdfile ;
echo $COMMAND ;
# wait a few seconds before reading the command file again:
sleep 5 ;
# if it's backup time, make the backup:
CURR_TIME=`date +%H%M` ;
if [ "$CURR_TIME" = "$BACKUP_TIME" ] ; then
echo save-all ;
echo save-off ;
CURR_DATE=`date +%Y%m%d` ;
# $1 is the argument, which should be the name of your world (eg. "world")
# This makes a daily tar of your world, in a file like world_20121021.tar
tar cf $1_$CURR_DATE.tar $1 ;
echo save-on ;
# wait a minute to avoid saving twice:
sleep 60 ;
I save this script in my bin as commandReader.sh. Aside from making the backup, the script simply reads whatever is in the file “cmdfile” (created in the minecraft server directory), pipes the command to the minecraft server, and clears the file. So if I open any terminal on the machine running the server, I can simply send commands to my Minecraft server like so:
echo "time set 0" > /home/myusername/minecraft_server_folder/cmdfile
And echoing “stop” into the file stops both the Minecraft server and the command reader script.
In my minecraft server folder, I put a script called launchserver.sh. This can be just the standard launch command line (
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui), but I found the server performs better if I use a script that calculates the appropriate amount of memory — see the script here.
Then — with the server taking care of itself — I can get back to the important business of building castles!
I’m usually more interested in implementing video games than in anaylzing video game design, but I think the success of Minecraft alongside the failure of Lego Universe provide a really interesting example.
First of all, I love Legos — they’ve been my favorite toy forever — and I have two little boys (ages 10 and 9) who also love Legos. Last year, when Lego first announced Lego Universe, I looked forward to trying it out. I figured that my kids were about the age where they’d be wanting to play online multiplayer video games soon, and rather than fight it, I might as well steer them towards more interesting ones. So we signed up for the free version, and played it a bit. It wasn’t addictive, but I didn’t expect it to be. I figured I’d probably sign up for the paid version at some point, but never quite got around to it.
Then one day my younger son was watching Lego videos on YouTube, and YouTube’s sidebar of related videos turned up a Minecraft video. My son watched it and was hooked. He spent so much time watching YouTube videos of people playing Minecraft that my husband figured it was ridiculous for him to watch the game so much and not play it, so he bought him a Minecraft account. And after watching my son play this game just a little, I knew I had to get myself an account, and one for my other son. And we have had a fantastic time playing together!! Here’s a video we made of us playing attack/defend the tower:
Right off the bat, I became wildly hooked on this game! It’s really unlike me, too, because I don’t normally play video games all that much — I certainly don’t generally spend hours on end playing a video game! But it hit me that a lot of what makes this game so much fun is kind of the same thing that makes it so much fun to play with Legos. Watch this video I made about strategies for constructing a defensive fortress, and see if you see what I mean:
Basically, you have the raw materials to build whatever you want, and the game is totally open-ended about what your objectives are. If you want to build the most amazing building/city/castle, you can. If you want to go around fighting monsters, you can — and you can figure out and build tricky traps for them if you like (but you don’t have to). If you want to go on a scripted, pre-set adventure, you can. Just go to YouTube and look for different Minecraft challenges — you can download different obstacle courses and adventure maps that other people have constructed. What’s more, if you want to script/construct an adventure for other people to play, you can! Just upload a video of it to YouTube when it’s done. (Minecraft makes it fun for users to share content.)
This is part of the same reason why Lego toys have such universal appeal. My kids like the story of the Ninjago universe, for example, and play stories of the characters that Lego invented for them. However, if you’d rather just use your own ideas to build something, you can. Here’s a tree-house I built a while ago:
The biggest additional appealing element that Minecraft has (but Lego doesn’t) is the three-dimensional environment made of blocks. Since virtual blocks are free, why not? And Minecraft has a really good algorithm for generating interesting landscapes and cave systems. I’ve found it’s actually kind of fun to simply wander around and explore the randomly-generated world. Another fun thing is that you have the choice of setting it to “creative mode” — where you can have an infinite number of any brick or item you need — or to “survival mode”, where there’s a bit of challenge involved in finding or making the blocks and items you want.
Playing the video game that got it right made it crystal clear what Lego Universe did wrong. In a nutshell, Lego Universe was way too scripted.
I watched/helped my son play Lego Universe, and we were given a set scene and a long series of trivial tasks to perform in order to advance through the game. The worst part was that they scripted what your character needs to “build”. I put “build” in quotes here, because, really, you just press a button and your mini-figure waves its little arms, and the item you need to build in this part of the script just appears. (I understand that the paid version was more open-ended, but I never saw it because we were kind of turned off by the free part.) Contrast this with Minecraft, where — using a handful of mechanical/electrical pieces — people build all sorts of different machines, from simple vending machines to entire, functioning computers! There are simple formulas you can build if you want to (like golems), but mostly the raw materials are pretty simple and open to possibilities.
When Lego Universe first shut down, they posted a video explaining what had happened. I think they’ve since taken it down (because I can’t find it anymore), but the striking part was that they’d started out with a more open-ended game, and did some focus groups, and some twelve or thirteen year old kids told them they’d rather have a more scripted game. So Lego came up with a rather generic evil universe storyline — of the same variety that every toy company uses to sell toys to boys ages five to fifteen. This shows the danger of trying to use focus groups for the original ideas of your product. Obviously twelve-year-old kids are going to tell you to just copy some other games that they like.
Normally this sort of story wouldn’t be surprising at all: a clever individual comes up with a brilliant idea that that giant, bureaucratic corporation couldn’t/didn’t think of. It just surprised me because Lego Group has generally done a very good job of staying ahead of the game in terms of good ideas. The Ninjago series is more interesting and fun than similar, competing toy lines like Bakugan and Beyblade. The surprise mini-figure packs at the toy store checkout counter are a fun impulse item — and something that other toy companies have since copied. They have a good mix of theme construction sets (like Star Wars and Harry Potter) along with sets that start you making your own story, like City and Castle. They have a huge number of simple pieces, and you can use the ideas from the sets to make interesting things out of them, or come up with your own construction ideas. Even their Advent Calendar had a bunch of clever ideas for making interesting items out of simple raw materials. Plus, they figured out that a good part of their customer base is actually adults — and they came up with a series of sets that are marketed to adults, like the elaborate London Tower Bridge.
In twenty-twenty hindsight, I think Lego’s biggest error was to leave too much of the planning of Lego Universe to their (very successful) video game department, instead of leveraging what people like about Lego toys. The video game department is successful largely because people love Lego’s iconic mini-figures, which make a fantastically easy-to-animate set of characters for video games. That’s great, but something that’s “Lego Universe” should feature more of Lego’s universal appeal. Since they intended their video game to be for kids and teens on the young end of online multi-player gaming, they were foolish not to take advantage of the fact that the parents (the ones with the wallets) often enjoy playing Legos with their kids — and make a game that’s fun for parents who like to build things.
I imagine that Lego will come out with a copycat game. They would be foolish not to. But I hope they get their ideas team in gear and add something really new to it themselves, and don’t just make a pale imitation of Minecraft.