Created
October 29, 2013 15:13
-
-
Save schoentoon/7216533 to your computer and use it in GitHub Desktop.
Simple python script to print the weather/day state of a minecraft world for https://github.com/schoentoon/Minecraft-Overviewer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
print "Content-Type: application/json" | |
from nbt import * # https://github.com/twoolie/NBT | |
import json | |
nbtfile = nbt.NBTFile("/complete/path/to/world/data/scoreboard.dat", 'rb') | |
day = (int(str(nbtfile["Data"]["DayTime"])) % 24000) < 12000 | |
rain = int(str(nbtfile["Data"]["raining"])) == 1 | |
thunder = int(str(nbtfile["Data"]["thundering"])) == 1 | |
if (thunder): | |
weather_url = "weather/weather_thunder_day.png" if day else "weather/weather_thunder_night.png" | |
elif (rain): | |
weather_url = "weather/weather_stormy_day.png" if day else "weather/weather_stormy_night.png" | |
else: | |
weather_url = "weather/weather_sunny_day.png" if day else "weather/weather_sunny_night.png" | |
print json.dumps({"src":weather_url}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment