Page 1 of 1

[SOLVED] Calendar Object Not Defined

Posted: Fri Oct 15, 2021 6:55 pm
by aykonsilvers
Hello fellow devs,
I am a very new Ren'Py developer who has just started learning thanks to Thundy's awesome Ren'Py tutorials on YouTube. I am in lesson 11 and have just created my first class that will be used to hold calendar data. I created the code exactly as instructed by the video, I have re-checked my code at least 4 times already. In the tutorial, after he creates the object he wants to check and see if the Calendar Object is populating using the developer console. Mine says that Calendar is not Defined when I try it.

Here is the code that is being called:

Code: Select all

init python:
    class Calendar(object):
        def __init__(self, Hours, Hour, Days, Day, Months, Month, WeekDays, MonthDays):
        self.Hour = Hour
        self.Hours = Hours
        self.Days = Days
        self.Day = Day
        self.Month = Month
        self.Months = Months
        self.WeekDays = WeekDays
        self.MonthDays = MonthDays
    @property
    def Output(self):
        return self.WeekDays[self.Day] + " " + self.Months[self.Month] + " " + str(self.Days + 1) + " " + str(self.Hours).zfill(2)
When he runs the developer console and types "print Calendar.object" he gets a hex value of some sort. Mine has a panic attack and says that the object is not defined and presents this message:

Code: Select all

  File "renpy/common/00console.rpy", line 689, in run
    renpy.python.py_exec(code)
  File "/Users/************/RenPy/renpy-7.4.9-sdk/renpy/python.py", line 2258, in py_exec
    exec(py_compile(source, 'exec'), store, locals)
  File "<none>", line 1, in <module>
NameError: name 'Calendar' is not defined
I am not sure if this is the expected behavior or not, but can someone give it a glance and let me know?

Also, this is an Xpost to my thread in the RenPy Sub on Reddit.

Re: Calendar Object Not Defined

Posted: Fri Oct 15, 2021 8:59 pm
by rayminator
you need to post the full traceback log as the rule of this forum

are you sure he putting in Calendar.object or Calendar.day

this is wrong

Code: Select all

class Calendar(object):
        def __init__(self, Hours, Hour, Days, Day, Months, Month, WeekDays, MonthDays):
        self.Hour = Hour
        self.Hours = Hours
        self.Days = Days
        self.Day = Day
        self.Month = Month
        self.Months = Months
        self.WeekDays = WeekDays
        self.MonthDays = MonthDays
it should be like this and I would change hours to hrs it might be conflicting with hour with hours

Code: Select all

class Calendar(object):
        def __init__(self, Hours, Hour, Days, Day, Months, Month, WeekDays, MonthDays):
            self.Hour = Hour
            self.Hours = Hours
            self.Days = Days
            self.Day = Day
            self.Month = Month
            self.Months = Months
            self.WeekDays = WeekDays
            self.MonthDays = MonthDays

Re: Calendar Object Not Defined

Posted: Fri Oct 15, 2021 9:10 pm
by hell_oh_world
Yup, you need to observe proper indentation, also that Output method needs to be inside the class block.
If no luck at all, you can try force recompiling your scripts through the launcher, then rerun the game again.

Re: Calendar Object Not Defined

Posted: Fri Oct 15, 2021 9:17 pm
by rayminator
I just watched his video he didn't put Calendar.object he put Calendar.Output

Re: Calendar Object Not Defined

Posted: Mon Oct 18, 2021 1:30 pm
by aykonsilvers
Thank you for your replies. I have been working this with the Ren'Py reddit as well.

I did figure out the indentation issue and I think I have fixed that part but it still isn't working.

I also mistyped on the command when I was explaining it, the video does tell us to print Calendar.output and that is what I actually typed, I just made a typing error when I posted this here.

If you are curious, I do have this in my GitHub if seeing the code is any easier that way: https://github.com/shieldskcd/thundy_re ... 20Calendar

Re: Calendar Object Not Defined

Posted: Mon Oct 18, 2021 1:35 pm
by aykonsilvers
Also, as requested, here is the output in Traceback:

Code: Select all

While running game code:
  File "game/script.rpy", line 15, in script
    "Click"
  File "game/script.rpy", line 15, in script
    "Click"
  File "renpy/common/000window.rpy", line 114, in _window_auto_callback
    _window_show(auto=True)
  File "renpy/common/000window.rpy", line 69, in _window_show
    renpy.with_statement(trans)
  File "game/screens.rpy", line 98, in execute
    screen say(who, what):
  File "game/screens.rpy", line 98, in execute
    screen say(who, what):
  File "game/screens.rpy", line 101, in execute
    frame:
NameError: Name 'Output' is not defined.

Re: Calendar Object Not Defined

Posted: Mon Oct 18, 2021 6:03 pm
by aykonsilvers
Hello folks! Thanks for taking a look at the code for me. I finally just started from scratch on this exercise and re-did the code. I discovered that I had accidentally removed some of the calendar code in script.rpy that was needed to adjust the values for the calendar. It is working now!

If you want to reference the corrected code, you can check out my GH here: https://github.com/shieldskcd/thundy_re ... 20Calendar