Difference between revisions of "IRC & Minecraft"

From Unallocated Space
Jump to navigation Jump to search
(Created page with "Why build a communication bridge between IRC and Minecraft? Why not. == Running the Minecraft Server == <pre> tail -f mcpipe | java -Xmx1024M -Xms1024M -jar minecraft_server....")
 
 
Line 27: Line 27:
  
 
Strangely, the Minecraft server writes most of its data out through stderr and not stdout, hence having to use |&.
 
Strangely, the Minecraft server writes most of its data out through stderr and not stdout, hence having to use |&.
 +
 +
 +
 +
 +
[[File:Irc2mc2.png]]
 +
[[File:Irc2mc1.png]]

Latest revision as of 13:58, 6 April 2011

Why build a communication bridge between IRC and Minecraft? Why not.


Running the Minecraft Server

tail -f mcpipe | java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui |& python mc2irc.py


mc2irc.py

import time,sys,os,string

while True:
        tmp=sys.stdin.readline().strip()
        if tmp != "" and "!irc" in tmp and "[CONSOLE]" not in tmp:
                tmp=string.replace(tmp,"!irc","")
                os.system("echo 'From MineCraft: "+tmp[27:]+" (!mc to reply)' > /uas/irc/irc")
        time.sleep(1)

Talking to people inside the Minecraft server through IRC is done using the !mc command on the IRC Bot. Inside Minecraft chat using !irc will send messages to the IRC channel through the bot.

Strangely, the Minecraft server writes most of its data out through stderr and not stdout, hence having to use |&.



Irc2mc2.png Irc2mc1.png