So folks, ... today. \o/

Feeling lonely and want to chat? That's your place to go then. Can't be off-topic enough to not be posted here.

Moderator: Wizards

Post Reply
Message
Author
Zehren
Overlord
Posts: 1057
Joined: Sun Dec 06, 2009 7:50 am

So folks, ... today. \o/

#1 Post by Zehren » Sat Feb 25, 2012 9:46 pm

So folks, I made this thread today. \o/

So folks, I hit 100 light armour today. \o/
So folks, I am boastful today. \o/
Drayn wrote:Zehren, the Karmassassin!

Drayn
Hero
Posts: 439
Joined: Sun Aug 07, 2011 4:09 pm

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

#2 Post by Drayn » Fri Mar 02, 2012 9:12 am

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.)

Eleassa
Professional
Posts: 88
Joined: Sat Jun 19, 2010 10:42 am
Location: A village on the edge of nowhere, Maine, USA

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

#3 Post by Eleassa » Fri Mar 02, 2012 2:20 pm

So uh... what's it do?
Two rules to live by:
Don't sweat the petty stuff.
Don't pet the sweaty stuff.

A third rule to live by:
Don't do ANYTHING you don't want to admit and/or explain to a paramedic

Urlyth
Veteran
Posts: 111
Joined: Sun Jan 24, 2010 12:20 pm

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

#4 Post by Urlyth » Fri Mar 02, 2012 4:09 pm

Makes everyone else bored figuring it :)

Sorry
/me is so mean!

User avatar
luminier
Overlord
Posts: 2732
Joined: Wed Jul 25, 2007 11:40 pm
Location: Manitoba Canada

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

#5 Post by luminier » Fri Mar 02, 2012 4:22 pm

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.
The right man in the wrong place can make all the difference in the world.

Drayn
Hero
Posts: 439
Joined: Sun Aug 07, 2011 4:09 pm

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

#6 Post by Drayn » Fri Mar 02, 2012 4:47 pm

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).

ghalt
Master
Posts: 210
Joined: Mon Jun 20, 2011 11:10 pm

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

#7 Post by ghalt » Fri Mar 02, 2012 8:51 pm

Python is so great.
I'm really, really, horribly upset that

Code: Select all

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

Drayn
Hero
Posts: 439
Joined: Sun Aug 07, 2011 4:09 pm

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

#8 Post by Drayn » Sat Mar 03, 2012 8:56 am


ghalt
Master
Posts: 210
Joined: Mon Jun 20, 2011 11:10 pm

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

#9 Post by ghalt » Sun Mar 04, 2012 8:31 pm

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

Post Reply