The "over complex" part having been addressed, lets talk about the two main errors.
I'll explain why you have an error, and tell how to solve it later, but first thing first, the most important error lay in this line:
My major problem is there is no syntax error also there is no logical error.
It's difficult to tell precisely from your screenshots, but I've seen many logical errors, including the one that lead to the issue that made you ask for help.
The most obvious, is that either you used the same name ("Calendar") for the class and the object itself, or you are working exclusively with the class. Both are as wrong. By naming the object like the class, you overwrite the class, and so loose it. And using the class instead of an object from this class, is like living in the blueprint of a house instead of living in an actual house.
The
AddTime
method is also full of logical error and weirdness.
By example you've this:
Code:
self.Minutes += minutes
if self.Minutes>60:
self.Minutes -= 60
self.Hours += 1
What can only works if you add at most 60 minutes. But one can want to add 61 minutes, or more, and then, boom. You should have looped here:
Code:
while self.Minutes>60:
self.Minutes -= 60
self.Hours += 1
Same for the part regarding the hours, that increment the day and should have been a loop. Then come the fact that after this there's the secondary processing (period of the day, season, etc.), but at no time you make the month change... It's perhaps on the not seen part of the code, but then it mean that the season processing is wrong, because based on a month that can change after that.
Talking about the
AddTime
method, what does it do exactly ? Its name and what you show of the code seem to imply that it advance the calendar. But then, what your screen is supposed to do ?
Code:
[...]
action Calendar.AddTime( 0, 0, 0, 0 )
[...]
action Calendar.AddTime( 1, 0, 0, 0 )
[...]
action Calendar.AddTime( 2, 0, 0, 0 )
[...]
action Calendar.AddTime( 3, 0, 0, 0 )
A choice "Advance by 0 month, 0 day, 0 hour and 0 minute" make absolutely no sense, so it's surely not what mean the first
imagebutton
.
But then this mean that each button is a "jump to month X"... what then mean that you are using
AddTime
to
set the date, not to
advance it.
Therefore, either the method is wrongly named, or it shouldn't be what to use here.
All this may sound harsh said like this (especially coming after
79flavors kindness), but being direct is the best way to show, and explain, why your claim regarding the absence of syntax and logical error
IS an error.
"A computer is like a mischievous genie. It will give you exactly what you ask for, but not always what you want." - Joe Sondow
There's no "oh, it magically don't works, what can be the reason". When you code, 99% of the errors come from you, the reasons being, by order of frequency, a syntax/typo error, a logical error, or a misunderstanding of how something works.
As for the error that made you write this, it's a misunderstanding regarding the
action
property.
You use
action Calendar.AddTime( whatever )
, what is wrong, and not just because of the "Calendar" part. Each time Ren'Py display/refresh the screen, it will call the
AddTime
twelve times, what is not what you expected.
Be noted that this confuse me even more. 0+1+...+11+12 => 78, what don't round to 12, yet you end in December, what seem to imply that, at least for the month,
AddTime
works as a
set method, not as a
advance one ; it would end in June. Therefore there's another error in the parts of
AddTime
that you haven't shown.
Now, why it don't works, independently to the logical error of your class ? Well, as I said, it's due to a misunderstanding.
Ren'Py
You must be registered to see the links
documentation:
"Along with these actions,
an action may be a function that does not take any arguments.
The function is called when the action is invoked. If the action returns a value, then the value is returned from an interaction."
It's not necessarily worded correctly, and can be a bit obscure for a novice, but the part regarding the arguments should have made you question what you did ; you pass arguments. Worded (a bit) better, the
action
property wait for a "code reference", that mean a function or method that is
not called yet.
By adding the
( whatever )
part, what you provide is in fact the return value of the
Calendar.AddTime
method. Not only this make the time advance without waiting that the player make his choice, and make it advance each time Ren'Py refresh the screen, but it also mean that nothing will happen when the player press a button, because the action will be
None
.
Now, being on the Screen Actions page of the documentation, a look at it make us find an action named
You must be registered to see the links
. I admit that its description is not made for everyone, but yet the name is relatively explicit, and it's what you should have used:
Code:
[...]
action Function( Calendar.AddTime, 0, 0, 0, 0 )
[...]
action Function( Calendar.AddTime, 1, 0, 0, 0 )
[...]
action Function( Calendar.AddTime, 2, 0, 0, 0 )
[...]
action Function( Calendar.AddTime, 3, 0, 0, 0 )
Then the date will not magically change and wait for the player to effectively press a button.
But, as implied by the first half of my answer, this will solve your direct issue, but not make your class works as you expect it to do.