Page 1 of 1

So folks, ... today. \o/

Posted: Sat Feb 25, 2012 9:46 pm
by Zehren
So folks, I made this thread today. \o/

So folks, I hit 100 light armour today. \o/
So folks, I am boastful today. \o/

Re: So folks, ... today. \o/

Posted: Fri Mar 02, 2012 9:12 am
by Drayn
So folks, I got really bored and made this

Code: Select all

#! /usr/bin/python

import time
import datetime
import os

if os.name == "posix": 
	clear = "clear"
elif os.name in ("nt", "dos", "ce"):
	clear = "CLS"

class clock():

	def __init__(self):	              #yyyy, mm, dd, h, min	
		self.epoch = datetime.datetime(1828, 10, 16, 9, 45)
		self.tick()
	
	def tick(self):
		
		today = datetime.datetime.now()
		elapsed = (today - self.epoch) * 6

		self.year = elapsed.days / 352
		self.month = (elapsed.days % 352) / 22
		self.day = (elapsed.days % 352) % 22
		
		self.hour = elapsed.seconds / 3600
		self.minute = (elapsed.seconds % 3600) / 60
		self.second = (elapsed.seconds % 3600) % 60

geasTime = clock()

while 1:
	try:
		time.sleep(0.16)
		os.system(clear)
		geasTime.tick()
	
		print "TIME:  %02d:%02d:%02d" % (geasTime.hour, geasTime.minute, geasTime.second)
		print "DATE:  %02d/%02d/%04d" % (geasTime.day, geasTime.month, geasTime.year)
		
		print "\nHit Ctrl-C to exit"
	except KeyboardInterrupt:
		break
today \o/ (well, yesterday, but I finished it today.)

Re: So folks, ... today. \o/

Posted: Fri Mar 02, 2012 2:20 pm
by Eleassa
So uh... what's it do?

Re: So folks, ... today. \o/

Posted: Fri Mar 02, 2012 4:09 pm
by Urlyth
Makes everyone else bored figuring it :)

Sorry
/me is so mean!

Re: So folks, ... today. \o/

Posted: Fri Mar 02, 2012 4:22 pm
by luminier
im pretty sure it's an clock for geas that runs in his MUD client so he always knows what time it is and such.

Re: So folks, ... today. \o/

Posted: Fri Mar 02, 2012 4:47 pm
by Drayn
Prizes to Lumi :)

You win a code snippet

Code: Select all

while 1:
    print "Luminier is awesome"
(don't actually run it :P)

My character is already top notch at astronomy (hence being able to have a decent stab at the Epoch) so it's more of a toy. I've done a bit more to it to allow conversion of geas dates into real dates and vice versa, just a handy little tool for various stuffs like knowing when IC dates crop up in RL :)

Here updated (and not very tested) code:

Code: Select all

#! /usr/bin/python

import time
import datetime
import os

if os.name == "posix": 
	clear = "clear"
elif os.name in ("nt", "dos", "ce"):
	clear = "CLS"
	
loop = True

class clock():

	def __init__(self):	              #yyyy, mm, dd, h, min	
		self.epoch = datetime.datetime(1828, 10, 16, 9, 45)
		self.tick()

	def tick(self):
		dt = datetime.datetime.now()
		self.calcTime(dt)

	def calcTime(self, dt):
		elapsed = (dt - self.epoch) * 6

		self.year = elapsed.days / 352
		self.month = (elapsed.days % 352) / 22
		self.day = (elapsed.days % 352) % 22
		
		self.hour = elapsed.seconds / 3600
		self.minute = (elapsed.seconds % 3600) / 60
		self.second = (elapsed.seconds % 3600) % 60
	
	def displayDT(self):
		print "TIME:  %02d:%02d:%02d" % (self.hour, self.minute, self.second)
		print "DATE:  %02d/%02d/%04d" % (self.day, self.month, self.year)
		

geasTime = clock()

while loop:
	print "\n\n1: Clock"
	print "2: Real world to geas time"
	print "3: Geas to real world time"
	print "0: Quit"
	choice = raw_input("Please select an option: ")
	
	if choice == "0": loop = False
	
	if choice == "1":
		while 1:
			try:
				time.sleep(0.16)
				os.system(clear)
				geasTime.tick()
				geasTime.displayDT()
		
				print "\nHit Ctrl-C to exit"
			except KeyboardInterrupt:
				break
	
	if choice == "2":
		dstring = raw_input("Enter date (dd/mm/yyyy): ")
		tstring = raw_input("Enter time (hh:mm): ")
		d = dstring.split("/")
		t = tstring.split(":")
		
		try:
			dt = datetime.datetime(int(d[2]), int(d[1]), int(d[0]), int(t[0]), int(t[1]))
		except:
			print "Whoops!  Something went wrong, probably a bad value entered, try again"
		
		print ("\n\n")
		geasTime.calcTime(dt)
		geasTime.displayDT()
	
	if choice == "3":
		print "Remember to enter the geas date correctly or things will go oddly."
		print "The geas calendar has 16 months in a year with 22 days each"
		dstring = raw_input("Enter date (dd/mm/yyyy): ")
		d = dstring.split("/")
		
		try:
			d[2] = int(d[2]) * 16
			d[2] = d[2] * 22
			d[1] = int(d[1]) * 22
		
			days = int(d[0]) + d[1] + d[2]
			elapsed = datetime.timedelta(days / 6)
		
			date = geasTime.epoch + elapsed
		except:
			print "Whoops!  Something went wrong, probably a bad value entered, try again"
			
		print date.strftime("\n%d/%m/%y")
It should run on any computer (cos it's python and python rocks cross platform compatibility) but I'm a linux user so it's not windows tested and I really can't be bothered if it doesn't work on win or mac. As far as I can tell, the time and date remains pretty synced to the game (a bit difficult to tell) at least the day is usually right :)

The exception handling should cope with most typos and mistakes, but I've not put much time into fully idiot proofing it...I wasn't THAT bored :D

If you want to run it, just install python, save the script as a text file (with a .py extension preferably) the execute the program in what ever manner your OS supports. If you're sensible and use linux the top line informs bash that it's a python script so typing ./geastime.py (or whatever you saved it as) will make it go :)

Lemme know if you use it and if you spot any major problems.

Oh, it might need manually correcting for different time zones. I'm in GMT (UTC 0) and I'm not entirely certain if the script grabs UTC or local time. If it's local, just correct the epoch manually (plus or minus your time zone from the time).

Re: So folks, ... today. \o/

Posted: Fri Mar 02, 2012 8:51 pm
by ghalt
Python is so great.
I'm really, really, horribly upset that

Code: Select all

raise "hell"
no longer works in 3 though. :/

Re: So folks, ... today. \o/

Posted: Sat Mar 03, 2012 8:56 am
by Drayn

Re: So folks, ... today. \o/

Posted: Sun Mar 04, 2012 8:31 pm
by ghalt
If I'm making a serious program I'll use many times, I can figure out how to do it The Right Way. If I'm making some one-off script, and I have to debug it, I want to be able to type raise "hell" and have my program crash while cursing at me. :P