I have a class, that displays current time (gettime) and can increase time (changetime):
Code: Select all
init -1 python:
#Start time
minute = 0
check_minute = 0
hour = 8
ptime = 0
weekday = 1
month = 5
number = 1
year = 2010
class Ctime:
def gettime(self):
#Дни недели
if weekday == 1: _weekday = 'Понедельник'
if weekday == 2: _weekday = 'Вторник'
if weekday == 3: _weekday = 'Среда'
if weekday == 4: _weekday = 'Четверг'
if weekday == 5: _weekday = 'Пятница'
if weekday == 6: _weekday = 'Суббота'
if weekday == 7: _weekday = 'Воскресенье'
#Месяца
if month == 1: _month = 'Января'
if month == 2: _month = 'Февраля'
if month == 3: _month = 'Марта'
if month == 4: _month = 'Апреля'
if month == 5: _month = 'Мая'
if month == 6: _month = 'Июня'
if month == 7: _month = 'Июля'
if month == 8: _month = 'Августа'
if month == 9: _month = 'Сентября'
if month == 10: _month = 'Октября'
if month == 11: _month = 'Ноября'
if month == 12: _month = 'Декабря'
if minute < 10:
output = '%d %s %d года, %s. %s:0%s' % (number, _month, year, _weekday, hour, minute)
else:
output = '%d %s %d года, %s. %s:%s' % (number, _month, year, _weekday, hour, minute)
return output
def changetime(self,change):
global minute, check_minute, hour, ptime, weekday, number, year, month
minute += change
check_minute += change
while minute >= 60:
minute -= 60
hour += 1
ptime += 1
if hour >= 24:
hour -= 24
weekday += 1
if weekday >=8: weekday -=7
number += 1
if number >= 31:
number = 30
month += 1
if month == 13:
month -=12
year += 1
return
Code: Select all
init:
$ currtime = Ctime()
Code: Select all
screen stats_screen:
frame xalign 1.0 yalign 0.0:
vbox xmaximum config.screen_width/5:
text "[currtime.gettime()]" style style.my_text
File "game/screens.rpy", line 567, in execute
text "[currtime.gettime()]" style style.my_text
AttributeError: Ctime instance has no attribute 'gettime()'
Question is why? How do I have to initialise this attribute?