[SOLVED] Calendar Object Not Defined

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
aykonsilvers
Newbie
Posts: 5
Joined: Fri Oct 15, 2021 6:12 pm
Organization: Zoom
Github: shieldskcd
Discord: aykonsilvers#2695
Contact:

[SOLVED] Calendar Object Not Defined

#1 Post 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.
Last edited by aykonsilvers on Mon Oct 18, 2021 6:04 pm, edited 1 time in total.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Calendar Object Not Defined

#2 Post 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

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Calendar Object Not Defined

#3 Post 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.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Calendar Object Not Defined

#4 Post by rayminator »

I just watched his video he didn't put Calendar.object he put Calendar.Output

User avatar
aykonsilvers
Newbie
Posts: 5
Joined: Fri Oct 15, 2021 6:12 pm
Organization: Zoom
Github: shieldskcd
Discord: aykonsilvers#2695
Contact:

Re: Calendar Object Not Defined

#5 Post 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

User avatar
aykonsilvers
Newbie
Posts: 5
Joined: Fri Oct 15, 2021 6:12 pm
Organization: Zoom
Github: shieldskcd
Discord: aykonsilvers#2695
Contact:

Re: Calendar Object Not Defined

#6 Post 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.

User avatar
aykonsilvers
Newbie
Posts: 5
Joined: Fri Oct 15, 2021 6:12 pm
Organization: Zoom
Github: shieldskcd
Discord: aykonsilvers#2695
Contact:

Re: Calendar Object Not Defined

#7 Post 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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]