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: 18
Joined: Wed Mar 31, 2021 5:12 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#106 Post by Spire » Sat Aug 07, 2021 1:23 am

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!
Image
______
WISHLIST The VII Enigma on STEAM NOW - Proudly made using Renpy
______

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 » 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.
Mighty Morphine Vowel Arranger

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

Re: Encyclopaedia / Bestiary Framework

#108 Post by Spire » Sat Aug 28, 2021 9:13 am

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.
Image
______
WISHLIST The VII Enigma on STEAM NOW - Proudly made using Renpy
______

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 » 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.
Mighty Morphine Vowel Arranger

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

Re: Encyclopaedia / Bestiary Framework

#110 Post by Spire » Sat Aug 28, 2021 11:13 pm

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.
Image
______
WISHLIST The VII Enigma on STEAM NOW - Proudly made using Renpy
______

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

Re: Encyclopaedia / Bestiary Framework

#111 Post by Human Bolt Diary » Sun Aug 29, 2021 4:24 pm

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: 318
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: Encyclopaedia / Bestiary Framework

#112 Post by AERenoir » Sun Sep 26, 2021 1:54 pm

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 » Tue Sep 13, 2022 5:49 am

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

Post Reply

Who is online

Users browsing this forum: No registered users