Encyclopaedia / Bestiary Framework

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
Spire
Newbie
Posts: 22
Joined: Wed Mar 31, 2021 5:12 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#106 Post by Spire »

Big thanks to the OP for this framework, it's such a great help.

I thought I'd make my first post a helpful one. I'm developing a 20+ hour sci-fi action epic (It's almost complete), and having a well functioning Tips List was crucial. I managed to get the buttons working quite smoothly, so read the below and add it into your game if it helps.

For anyone who wants buttons that take you straight back into the game, and that returns you to the game from a hyperlink without skipping forward, replace / add in these buttons.

Put the below in the List screen:

Code: Select all

    
    
                        if main_menu:
                            textbutton "Close Entry"  action [Hide("encyclopaedia_list"), Return()] xfill True
                        else:
                            textbutton "Close Entry"  action [Hide("encyclopaedia_list"), Return(), RestartStatement()] xfill True
And if you want a direct button from your entry that will take you straight back to the game without needing to navigate back through the menus, add in extra the below button to the entry screen. The 'Close Entry' button will take you straight back to the game, the 'Entry List' button will take you back to the list page. Rename the buttons as suits. Also just make sure you replace the current buttons with this code making sure you line it up correctly.

Code: Select all

       
       
        frame:

            style_prefix "encyclopaedia"
            xfill True
            yalign .88
            hbox:
                if main_menu:
                    xfill True
                    # Flavour text that displays the current sorting mode
                    #text "Sorting Mode: {}".format(enc.labels.sorting_mode)
                    textbutton "Entry List" id "close_entry_button" xalign .55 clicked [enc.ResetSubPage(), Show("encyclopaedia_list", None, enc)] style "gui_button"
                    textbutton "Close Entry" id "close_entry_button" xalign .25 action [Hide("encyclopaedia_entry"), Return()] style "gui_button"

                else:
                    xfill True
                    # Flavour text that displays the current sorting mode
                    #text "Sorting Mode: {}".format(enc.labels.sorting_mode)
                    textbutton "Entry List" id "close_entry_button" xalign .55 clicked [enc.ResetSubPage(), Show("encyclopaedia_list", None, enc)] style "gui_button"
                    textbutton "Close Entry" id "close_entry_button" xalign .25 action [Hide("encyclopaedia_entry"), Return(), RestartStatement()] style "gui_button"
It is very important to keep the "if Main_Menu:" code in for those who will make your list accessible from the menu. If you have other custom menus, the "RestartStatement()" bit of coding is what stops the game skipping ahead when going back into the game. So for other custom menus, add another clause as an exemption with an "if" statement, similar to what I did above with the main menu, where I have removed that "RestartStatement()" code.

Need any more help just let me know!

User avatar
JenivereDomino
Regular
Posts: 27
Joined: Tue Nov 17, 2020 4:14 pm
Completed: Summer Horrordays
Projects: "Project Cadence" (Placeholder)
Organization: PunderBash Games
Deviantart: JenivereDomino
Github: JenivereSH
itch: punderbashgames
Location: United Kingdom
Discord: Jenivere #1227
Contact:

Re: Encyclopaedia / Bestiary Framework

#107 Post by JenivereDomino »

We have been using this for our game but for some reason the unlocks just aren't working. We are following the instructions on the website docs and making sure we use the _persistent part of the unlocks, but for some unknown reason it seemed to work for a while then when I recompiled and deleted persistent to double check it was still working it now doesn't. The entries simply don't unlock?

Example of entry:
theGods = EncEntry(
parent=glossary,
# #number='',
name='The Gods',
text=[
'There are 16 Gods who watch over all of creation from within the Divine Realm. There are 4 Major Gods who each rule over 3 Minor Gods.'
],
viewed_persistent=True,
locked=True,
locked_persistent=True
)


Where we are unlocking it:

if theGods.locked_persistent == True:
show screen show_gloss
$ theGods.locked_persistent = False

(screen show_gloss is a notification window to show the term is unlocked the first time it is encountered)

I have tried removing the _persistent from the unlock part, which seemed to unlock the entry in the glossary, but then began to give an error when I got further through the script to more terms, and wouldn't recognise the if statement above (which I want, because I want to notify when the item unlocks the first time only). I have also tried putting the persistent unlock outside of the if block as well and that didn't work either.


We are also encountering an error in another branch where we are testing the self voicing features, where some entries need to use {alt}name{/alt} and {noalt}name1{/noalt} to ensure the correct pronunciation of names or other terms by the self voicing. I also want to use {alt} to be able to give image description for characters with their glossary entry as a reference point for people who are unable to see.

Using Renpy 7.4.6.1693

Any advice would be very welcome, we seem to be going in circles with this working then not working.
Mighty Morphine Vowel Arranger

User avatar
Spire
Newbie
Posts: 22
Joined: Wed Mar 31, 2021 5:12 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#108 Post by Spire »

JenivereDomino wrote: Fri Aug 27, 2021 5:25 pm We have been using this for our game but for some reason the unlocks just aren't working. We are following the instructions on the website docs and making sure we use the _persistent part of the unlocks, but for some unknown reason it seemed to work for a while then when I recompiled and deleted persistent to double check it was still working it now doesn't. The entries simply don't unlock?

Example of entry:
theGods = EncEntry(
parent=glossary,
# #number='',
name='The Gods',
text=[
'There are 16 Gods who watch over all of creation from within the Divine Realm. There are 4 Major Gods who each rule over 3 Minor Gods.'
],
viewed_persistent=True,
locked=True,
locked_persistent=True
)


Where we are unlocking it:

if theGods.locked_persistent == True:
show screen show_gloss
$ theGods.locked_persistent = False

(screen show_gloss is a notification window to show the term is unlocked the first time it is encountered)

I have tried removing the _persistent from the unlock part, which seemed to unlock the entry in the glossary, but then began to give an error when I got further through the script to more terms, and wouldn't recognise the if statement above (which I want, because I want to notify when the item unlocks the first time only). I have also tried putting the persistent unlock outside of the if block as well and that didn't work either.


We are also encountering an error in another branch where we are testing the self voicing features, where some entries need to use {alt}name{/alt} and {noalt}name1{/noalt} to ensure the correct pronunciation of names or other terms by the self voicing. I also want to use {alt} to be able to give image description for characters with their glossary entry as a reference point for people who are unable to see.

Using Renpy 7.4.6.1693

Any advice would be very welcome, we seem to be going in circles with this working then not working.
My entries in my encyclopaedia use persistent data also, so I'll show you the coding I use that works for me. I can't speak to how that affects the notification coding you are using though.

In my coding, I don't have that "locked-true" line. So try this kind of structure for the ending of your entries, where you only have 2 lines rather than the three you had:

Code: Select all

    about_xx = EncEntry(
        parent=your_new_encyclopaedia,
        name="xxx",
        subject="TERMS AND EVENTS",
        image="xxx",
        text=[
            "xxx."

        ],
        viewed_persistent=True,
        locked_persistent=True,


    )
Then to unlock it, I use the following:

Code: Select all

    python:
        about_xx.locked = False

I think using the python coding is strange for this and it isn't what the documentation said, but using the above code worked perfectly when nothing else worked for me, so hopefully that will help you. Unlocking it in this way still functions exactly the same, as the entry itself uses the persistent data, so once it is unlocked, it is unlocked.

User avatar
JenivereDomino
Regular
Posts: 27
Joined: Tue Nov 17, 2020 4:14 pm
Completed: Summer Horrordays
Projects: "Project Cadence" (Placeholder)
Organization: PunderBash Games
Deviantart: JenivereDomino
Github: JenivereSH
itch: punderbashgames
Location: United Kingdom
Discord: Jenivere #1227
Contact:

Re: Encyclopaedia / Bestiary Framework

#109 Post by JenivereDomino »

Spire wrote: Sat Aug 28, 2021 9:13 am My entries in my encyclopaedia use persistent data also, so I'll show you the coding I use that works for me. I can't speak to how that affects the notification coding you are using though.

In my coding, I don't have that "locked-true" line. So try this kind of structure for the ending of your entries, where you only have 2 lines rather than the three you had:

Code: Select all

    about_xx = EncEntry(
        parent=your_new_encyclopaedia,
        name="xxx",
        subject="TERMS AND EVENTS",
        image="xxx",
        text=[
            "xxx."

        ],
        viewed_persistent=True,
        locked_persistent=True,


    )
Then to unlock it, I use the following:

Code: Select all

    python:
        about_xx.locked = False

I think using the python coding is strange for this and it isn't what the documentation said, but using the above code worked perfectly when nothing else worked for me, so hopefully that will help you. Unlocking it in this way still functions exactly the same, as the entry itself uses the persistent data, so once it is unlocked, it is unlocked.
Yeah we've tried that. Through some trial and error, we have figured out it might be where we are using the alt tags for the self voicing, which I need in there or names are pronounced completely wrong (eg, the character "Tyr" should sound like "Tier", but the self voicing reads it out as 3 individual letters "t y r" as if it is an acronym)... Unfortunately it seems like our solution is going to be having our coding team-mate build a different system from the ground up that will be able to handle the alt tags. We aren't in a rush for it tbh as there's a lot more work to go on the project as a whole and we are about to take a month off for the spooktober jam.

Thanks for the advice anyway, I appreciate the reply.
Mighty Morphine Vowel Arranger

User avatar
Spire
Newbie
Posts: 22
Joined: Wed Mar 31, 2021 5:12 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#110 Post by Spire »

JenivereDomino wrote: Sat Aug 28, 2021 1:47 pm
Spire wrote: Sat Aug 28, 2021 9:13 am My entries in my encyclopaedia use persistent data also, so I'll show you the coding I use that works for me. I can't speak to how that affects the notification coding you are using though.

In my coding, I don't have that "locked-true" line. So try this kind of structure for the ending of your entries, where you only have 2 lines rather than the three you had:

Code: Select all

    about_xx = EncEntry(
        parent=your_new_encyclopaedia,
        name="xxx",
        subject="TERMS AND EVENTS",
        image="xxx",
        text=[
            "xxx."

        ],
        viewed_persistent=True,
        locked_persistent=True,


    )
Then to unlock it, I use the following:

Code: Select all

    python:
        about_xx.locked = False

I think using the python coding is strange for this and it isn't what the documentation said, but using the above code worked perfectly when nothing else worked for me, so hopefully that will help you. Unlocking it in this way still functions exactly the same, as the entry itself uses the persistent data, so once it is unlocked, it is unlocked.
Yeah we've tried that. Through some trial and error, we have figured out it might be where we are using the alt tags for the self voicing, which I need in there or names are pronounced completely wrong (eg, the character "Tyr" should sound like "Tier", but the self voicing reads it out as 3 individual letters "t y r" as if it is an acronym)... Unfortunately it seems like our solution is going to be having our coding team-mate build a different system from the ground up that will be able to handle the alt tags. We aren't in a rush for it tbh as there's a lot more work to go on the project as a whole and we are about to take a month off for the spooktober jam.

Thanks for the advice anyway, I appreciate the reply.
That makes sense, I haven't used any self-voicing tags so I'm not sure how that interacts with it.

All the best with your project.

Human Bolt Diary
Regular
Posts: 111
Joined: Fri Oct 11, 2013 12:46 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#111 Post by Human Bolt Diary »

JenivereDomino wrote: Sat Aug 28, 2021 1:47 pm
Spire wrote: Sat Aug 28, 2021 9:13 am My entries in my encyclopaedia use persistent data also, so I'll show you the coding I use that works for me. I can't speak to how that affects the notification coding you are using though.

In my coding, I don't have that "locked-true" line. So try this kind of structure for the ending of your entries, where you only have 2 lines rather than the three you had:

Code: Select all

    about_xx = EncEntry(
        parent=your_new_encyclopaedia,
        name="xxx",
        subject="TERMS AND EVENTS",
        image="xxx",
        text=[
            "xxx."

        ],
        viewed_persistent=True,
        locked_persistent=True,


    )
Then to unlock it, I use the following:

Code: Select all

    python:
        about_xx.locked = False

I think using the python coding is strange for this and it isn't what the documentation said, but using the above code worked perfectly when nothing else worked for me, so hopefully that will help you. Unlocking it in this way still functions exactly the same, as the entry itself uses the persistent data, so once it is unlocked, it is unlocked.
Yeah we've tried that. Through some trial and error, we have figured out it might be where we are using the alt tags for the self voicing, which I need in there or names are pronounced completely wrong (eg, the character "Tyr" should sound like "Tier", but the self voicing reads it out as 3 individual letters "t y r" as if it is an acronym)... Unfortunately it seems like our solution is going to be having our coding team-mate build a different system from the ground up that will be able to handle the alt tags. We aren't in a rush for it tbh as there's a lot more work to go on the project as a whole and we are about to take a month off for the spooktober jam.

Thanks for the advice anyway, I appreciate the reply.
If you can create a renpy project with a minimal example that demonstrates this bug, I'll look into it.

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: Encyclopaedia / Bestiary Framework

#112 Post by AERenoir »

Is it possible to include (or use) a picture that is not the entry image as part of the entry button in the directory screen?
Since every entry would've needed a separate icon/image, I'm not sure how/where to code this in. Do I have to modify the original template and add another Parameter to EncEntry?

User avatar
disqette
Newbie
Posts: 2
Joined: Tue Aug 09, 2022 12:53 pm
Discord: ci#3113
Contact:

Re: Encyclopaedia / Bestiary Framework

#113 Post by disqette »

Hello, I am having an issue with setting the default sorting method. I used the method in the documentation, but whenever I add a locked entry, I receive a traceback error. It works just fine when there aren't any locked entries. I have no idea how to fix this, any help would be appreciated.

Code: Select all

label start:
    init python:
        datalog = Encyclopaedia(
            sorting_mode=Encyclopaedia.SORT_ALPHABETICAL
        )
        about_zeus = EncEntry(
            parent=datalog,
            name="Zeus",
            text=[
                "TESTING ZONE"
            ],
            viewed_persistent=True,
            locked_persistent=False
        )
        nootella = EncEntry(
            parent=datalog,
            name="Locked",
            text=[
                "You can't see me."
            ],
            viewed_persistent=False,
            locked_persistent=True
        )

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 10, in script
    init python:
  File "game/script.rpy", line 10, in script
    init python:
  File "game/script.rpy", line 23, in <module>
    nootella = EncEntry(
  File "game/enc.rpy", line 374, in __init__
    parent.add_entry(self)
  File "game/enc.rpy", line 848, in add_entry
    self.sort_entries(
  File "game/enc.rpy", line 766, in sort_entries
    push_locked_to_bottom(entries)
  File "game/enc.rpy", line 1023, in push_locked_to_bottom
    new_list = sorted(seq, reverse=True, key=attrgetter('locked'))
TypeError: '<' not supported between instances of 'NoneType' and 'bool'
Edit: I fixed it! I'll leave my post here in case anyone else ever runs into this issue.
Changed line 667 in enc.rpy from

Code: Select all

self.locked_at_bottom = True
to

Code: Select all

self.locked_at_bottom = False

Human Bolt Diary
Regular
Posts: 111
Joined: Fri Oct 11, 2013 12:46 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#114 Post by Human Bolt Diary »

Version 3.0 of the framework has been released. This version is only compatible with Ren'Py 8.1.0+ and has been heavily rewritten to support Python 3.9. There are breaking changes but these are mostly related to screens. Generally you shouldn't need to rewrite any EncEntry objects you've created.

Online documentation: https://renpy-encyclopaedia.readthedocs.io/

Demo game: https://jsfehler.itch.io/renpy-encyclopaedia

Source code: https://github.com/jsfehler/renpy-encyclopaedia

Latest release: https://github.com/jsfehler/renpy-encyc ... /releases/

Richday
Newbie
Posts: 4
Joined: Thu Aug 10, 2023 12:14 am
Projects: Color of Truth
Github: Richd4y
itch: richday
Location: Russia
Discord: richday
Contact:

Re: Encyclopaedia / Bestiary Framework

#115 Post by Richday »


Richday
Newbie
Posts: 4
Joined: Thu Aug 10, 2023 12:14 am
Projects: Color of Truth
Github: Richd4y
itch: richday
Location: Russia
Discord: richday
Contact:

Re: Encyclopaedia / Bestiary Framework

#116 Post by Richday »

Hello! The novel I'm working on requires access to an encyclopedia from the game's main menu with persistent data storage. According to the documentation (https://renpy-encyclopaedia.readthedocs ... local.html), you need to create an encyclopedia using the init python block and for each entry specify viewed_persistent=True , locked_persistent=True .

It is also required that unlocked entries should not appear in the dictionary until the player opens them during the game. Here's my code:

Code: Select all

# setup enc (codex) Global (with persistance data) 
init python:

    library_enc = Encyclopaedia(
        name="Codex",
        show_locked_buttons=False,  # show unseen (???) buttons in codex list or no
        sorting_mode=3,
    )

    # Register a callback function.
    library_enc.on('entry_unlocked')(notify_entry_unlocked)

    # Use EncEntryTemplate to set reasonable defaults and reduce duplication
    LibraryEntry = EncEntryTemplate(parent=library_enc, locked=True) #, locked_persistent=True, viewed_persistent=True)

    about_library = LibraryEntry(
        name=_('Library'),
        subject=_('Locations'),
        text=(
            "You find yourself sitting on a comfortable armchair. "
            "Around you, rows of books. "
            "You are in what appears to be a library, somehow."
        ),
        image=Transform('images/library.png', zoom=0.5),
        viewed_persistent=True,
        locked_persistent=True,
    )

    about_garden = LibraryEntry(
        name=_('Garden'),
        subject=_('Locations'),
        text=[
            "You focus on the concept of outside.",
            (
                "As you walk through rows of books, you notice their titles "
                "have become nearly all related to gardening and camping."
            ),
            (
                "You see something creating a gap between 2 rows. "
                "A stone pillar, and on it you see a door. "
                "The door is solid matte black with an ornate, silver door handle. "
                "You touch the door with an open palm. It feels like a chilled slab of granite. "
                "You grab the equally cold door handle and prepare for a struggle, but the door opens with ease. "
                "Natural light bathes your face. "
                "You step through and find yourself in an elegant garden. "
            )
        ],
        image=Transform('images/garden.png', zoom=0.5),
        viewed_persistent=True,
        locked_persistent=True,
    )
But I get the following error on first run when persistent data is cleared:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 2, in script
    init python:
  File "game/script.rpy", line 67, in <module>
    about_garden = LibraryEntry(
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 2, in script
    init python:
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\ast.py", line 1138, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\python.py", line 1122, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/script.rpy", line 67, in <module>
    about_garden = LibraryEntry(
  File "game/encyclopaedia/encentry_ren.py", line 101, in __init__
    parent.add_entry(self)
  File "game/encyclopaedia/encyclopaedia_ren.py", line 275, in add_entry
    self.sort_entries(
  File "game/encyclopaedia/encyclopaedia_ren.py", line 205, in sort_entries
    push_locked_to_bottom(entries)
  File "game/encyclopaedia/entry_sorting_ren.py", line 21, in push_locked_to_bottom
    new_list = sorted(seq, reverse=True, key=attrgetter('locked'))
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\revertable.py", line 281, in revertable_sorted
    return RevertableList(sorted(*args, **kwargs))
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'

Windows-10-10.0.19045 AMD64
What am I doing wrong and what places should I check? Renpy-Encyclopaedia 3.0.0

Human Bolt Diary
Regular
Posts: 111
Joined: Fri Oct 11, 2013 12:46 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#117 Post by Human Bolt Diary »

This has been fixed on the project's master branch. I'll cut a new release sometime in the next few days.
Richday wrote: Thu Nov 09, 2023 1:52 am Hello! The novel I'm working on requires access to an encyclopedia from the game's main menu with persistent data storage. According to the documentation (https://renpy-encyclopaedia.readthedocs ... local.html), you need to create an encyclopedia using the init python block and for each entry specify viewed_persistent=True , locked_persistent=True .

It is also required that unlocked entries should not appear in the dictionary until the player opens them during the game. Here's my code:

Code: Select all

# setup enc (codex) Global (with persistance data) 
init python:

    library_enc = Encyclopaedia(
        name="Codex",
        show_locked_buttons=False,  # show unseen (???) buttons in codex list or no
        sorting_mode=3,
    )

    # Register a callback function.
    library_enc.on('entry_unlocked')(notify_entry_unlocked)

    # Use EncEntryTemplate to set reasonable defaults and reduce duplication
    LibraryEntry = EncEntryTemplate(parent=library_enc, locked=True) #, locked_persistent=True, viewed_persistent=True)

    about_library = LibraryEntry(
        name=_('Library'),
        subject=_('Locations'),
        text=(
            "You find yourself sitting on a comfortable armchair. "
            "Around you, rows of books. "
            "You are in what appears to be a library, somehow."
        ),
        image=Transform('images/library.png', zoom=0.5),
        viewed_persistent=True,
        locked_persistent=True,
    )

    about_garden = LibraryEntry(
        name=_('Garden'),
        subject=_('Locations'),
        text=[
            "You focus on the concept of outside.",
            (
                "As you walk through rows of books, you notice their titles "
                "have become nearly all related to gardening and camping."
            ),
            (
                "You see something creating a gap between 2 rows. "
                "A stone pillar, and on it you see a door. "
                "The door is solid matte black with an ornate, silver door handle. "
                "You touch the door with an open palm. It feels like a chilled slab of granite. "
                "You grab the equally cold door handle and prepare for a struggle, but the door opens with ease. "
                "Natural light bathes your face. "
                "You step through and find yourself in an elegant garden. "
            )
        ],
        image=Transform('images/garden.png', zoom=0.5),
        viewed_persistent=True,
        locked_persistent=True,
    )
But I get the following error on first run when persistent data is cleared:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 2, in script
    init python:
  File "game/script.rpy", line 67, in <module>
    about_garden = LibraryEntry(
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 2, in script
    init python:
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\ast.py", line 1138, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\python.py", line 1122, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/script.rpy", line 67, in <module>
    about_garden = LibraryEntry(
  File "game/encyclopaedia/encentry_ren.py", line 101, in __init__
    parent.add_entry(self)
  File "game/encyclopaedia/encyclopaedia_ren.py", line 275, in add_entry
    self.sort_entries(
  File "game/encyclopaedia/encyclopaedia_ren.py", line 205, in sort_entries
    push_locked_to_bottom(entries)
  File "game/encyclopaedia/entry_sorting_ren.py", line 21, in push_locked_to_bottom
    new_list = sorted(seq, reverse=True, key=attrgetter('locked'))
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\revertable.py", line 281, in revertable_sorted
    return RevertableList(sorted(*args, **kwargs))
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'

Windows-10-10.0.19045 AMD64
What am I doing wrong and what places should I check? Renpy-Encyclopaedia 3.0.0

Richday
Newbie
Posts: 4
Joined: Thu Aug 10, 2023 12:14 am
Projects: Color of Truth
Github: Richd4y
itch: richday
Location: Russia
Discord: richday
Contact:

Re: Encyclopaedia / Bestiary Framework

#118 Post by Richday »

Human Bolt Diary wrote: Fri Nov 10, 2023 1:20 am This has been fixed on the project's master branch. I'll cut a new release sometime in the next few days.
Awesome! This is very good news. Thank you for continuing to improve your framework!

I also encounter a problem when sorting by unread ( key=attrgetter('locked') ). This happens for a global encyclopedia with persistent data when I have read and unread data at the same time and click on the filter unread button.

If all entries in the encyclopedia are read or unread (new), then the error does not occur.

I see that this is close to the previous problem, which arises due to the data type. Will this also be fixed in the next version?

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
TypeError: '<' not supported between instances of 'bool' and 'NoneType'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
    python hide:
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\ast.py", line 1138, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\python.py", line 1122, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in <module>
    python hide:
  File "renpy/common/_layout/screen_main_menu.rpym", line 35, in _execute_python_hide
    ui.interact()
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\core.py", line 3582, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\core.py", line 4543, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\transition.py", line 53, in event
    return self.new_widget.event(ev, x, y, st) # E1101
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\screen.py", line 770, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1403, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 281, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1403, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 281, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\behavior.py", line 1142, in event
    return handle_click(self.clicked)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\behavior.py", line 1075, in handle_click
    rv = run(action)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\behavior.py", line 379, in run
    return action(*args, **kwargs)
  File "game/encyclopaedia/actions_ren.py", line 242, in __call__
    self.enc.sort_entries(
  File "game/encyclopaedia/encyclopaedia_ren.py", line 199, in sort_entries
    entries.sort(key=attrgetter('viewed'))
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\revertable.py", line 97, in do_mutation
    return method(self, *args, **kwargs)
TypeError: '<' not supported between instances of 'bool' and 'NoneType'

Windows-10-10.0.19045 AMD64
Ren'Py 8.1.3.23091805

Richday
Newbie
Posts: 4
Joined: Thu Aug 10, 2023 12:14 am
Projects: Color of Truth
Github: Richd4y
itch: richday
Location: Russia
Discord: richday
Contact:

Re: Encyclopaedia / Bestiary Framework

#119 Post by Richday »

Richday wrote: Fri Nov 10, 2023 3:11 am
Human Bolt Diary wrote: Fri Nov 10, 2023 1:20 am This has been fixed on the project's master branch. I'll cut a new release sometime in the next few days.
Awesome! This is very good news. Thank you for continuing to improve your framework!

I also encounter a problem when sorting by unread ( key=attrgetter('locked') ). This happens for a global encyclopedia with persistent data when I have read and unread data at the same time and click on the filter unread button.

If all entries in the encyclopedia are read or unread (new), then the error does not occur.

I see that this is close to the previous problem, which arises due to the data type. Will this also be fixed in the next version?

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
TypeError: '<' not supported between instances of 'bool' and 'NoneType'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
    python hide:
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\ast.py", line 1138, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\python.py", line 1122, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "renpy/common/_layout/screen_main_menu.rpym", line 28, in <module>
    python hide:
  File "renpy/common/_layout/screen_main_menu.rpym", line 35, in _execute_python_hide
    ui.interact()
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\core.py", line 3582, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\core.py", line 4543, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\transition.py", line 53, in event
    return self.new_widget.event(ev, x, y, st) # E1101
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\screen.py", line 770, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1403, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 281, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1403, in event
    rv = super(Window, self).event(ev, x, y, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 281, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\layout.py", line 1179, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\behavior.py", line 1142, in event
    return handle_click(self.clicked)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\behavior.py", line 1075, in handle_click
    rv = run(action)
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\display\behavior.py", line 379, in run
    return action(*args, **kwargs)
  File "game/encyclopaedia/actions_ren.py", line 242, in __call__
    self.enc.sort_entries(
  File "game/encyclopaedia/encyclopaedia_ren.py", line 199, in sort_entries
    entries.sort(key=attrgetter('viewed'))
  File "C:\Users\Kostpomin\renpy-8.1.1-sdk\renpy\revertable.py", line 97, in do_mutation
    return method(self, *args, **kwargs)
TypeError: '<' not supported between instances of 'bool' and 'NoneType'

Windows-10-10.0.19045 AMD64
Ren'Py 8.1.3.23091805
Fixed it. Add to encentry_ren.py . Made it similar to the previous fix

Code: Select all

# fix: Crash when sorting list[EncEntry] by UNREAD with viewed_persistent
        self.viewed_persistent = viewed_persistent
        if self.viewed_persistent:
            self._viewed = getattr(persistent, self._name + "_viewed")

            if self._viewed is None:
                self._viewed = viewed
                setattr(persistent, self._name + "_viewed", viewed)

Post Reply

Who is online

Users browsing this forum: No registered users