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
Human Bolt Diary
Regular
Posts: 108
Joined: Fri Oct 11, 2013 12:46 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#91 Post by Human Bolt Diary » Mon Jan 20, 2020 1:16 am

You can't really access variable names in python. You could hack together a solution using the inspect module, but it's not a good idea. The most efficient solution is to reference your entries by their number. Your second best is to add a tag to every entry, like:

Code: Select all

jupiter = EncEntry(
        parent=perso,
        name="Jupiter, god of thunder",
        text=[_(""" Text here""")],
        viewed_persistent=True,
    )
    
jupiter.tag = "jupiter"
    
    
Ayael wrote:
Tue Jan 14, 2020 11:01 am
Hi, it's me again ! I was wandering, how can we retrieve the entry ID name.

For example :

Code: Select all

jupiter = EncEntry(
        parent=perso,
        name="Jupiter, god of thunder",
        text=[_(""" Text here""")],
        viewed_persistent=True,
    )
I know, if I want to retrives "Juper, god of thunder", I can use

Code: Select all

entry.name
, but I can't find the code I should use to retrieve "jupiter".

(If you wander why, it's because I am using this kind of code to have images instead of text in the list :

Code: Select all

idle "images/codex/entry/entry_" + entry.name + "_idle.png"
But having the entry displaying name is really annoying, I would rather have the id name. I could use the ID number, but it's harder to remember).

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

Re: Encyclopaedia / Bestiary Framework

#92 Post by Human Bolt Diary » Mon Jan 20, 2020 1:27 am

v2.4 of the Encyclopaedia Framework has been released. Download is available at: https://github.com/jsfehler/renpy-encyc ... s/tag/v2.4

EncEntryTemplate was added in this release. Documentation at: https://renpy-encyclopaedia.readthedocs ... lates.html

A small wrapper around functools.partial, it can make writing and managing large amounts of entries a bit easier.

Code: Select all

about_gods = Encyclopaedia()

GreekGodsEntry = EncEntryTemplate(parent=about_gods, subject="Greek Gods")

about_zeus = GreekGodsEntry(name="Zeus")

User avatar
Ayael
Regular
Posts: 75
Joined: Fri Apr 07, 2017 2:17 pm
Projects: Anoldor, medieval fantasy otome game.
Contact:

Re: Encyclopaedia / Bestiary Framework

#93 Post by Ayael » Mon Jan 20, 2020 4:05 pm

oh thanks ! And it's a nice add-on ! You are the best !

User avatar
munni
Newbie
Posts: 11
Joined: Sun Mar 17, 2019 4:14 pm
Contact:

Re: Encyclopaedia / Bestiary Framework

#94 Post by munni » Mon Jan 27, 2020 12:44 pm

Hi there!

Would it be possible to switch from an encyclopaedia to another mid-game? When the character's POV switch, I'd like for the encyclopaedia to have a different layout + entries.

Code: Select all

$ protagonist = "character_A"
a "I know a lot about {a=set_entry:enc_people->about_Dogs}{color=#DA70D6}dogs{/color}{/a}."

$ protagonist = "character_B"
b "I specialize in making {a=set_entry:enc_recipes->about_Fruitcake}{color=#DA70D6}fruitcakes{/color}{/a}!"
I would like to combine that with the hyperlink feature you made a while back, but I think something is preventing the switch from happening. My guess is it has something to do with this bit:

Code: Select all

        def __init__(self,
                     sorting_mode=0,
                     show_locked_buttons=False,
                     show_locked_entry=False,
                     entry_screen="encyclopaedia_entry", # this one ?
                     tint_locked_image=True):
Thanks for sharing the encyclopaedia library with us by the way. It's a great VN feature for info-heavy games!

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

Re: Encyclopaedia / Bestiary Framework

#95 Post by Human Bolt Diary » Tue Jan 28, 2020 12:20 am

If the entries change too, it sounds like you need two separate Encyclopaedas, each pointing to a different screen.

"encyclopaedia_entry" is just a default screen I've included. Any screen that takes an Encyclopaedia as an argument is valid.

If only the layout changes, you could probably override the entry_screen attribute with the name of another screen, then switch it back whenever you want.

munni wrote:
Mon Jan 27, 2020 12:44 pm
Hi there!

Would it be possible to switch from an encyclopaedia to another mid-game? When the character's POV switch, I'd like for the encyclopaedia to have a different layout + entries.

Code: Select all

$ protagonist = "character_A"
a "I know a lot about {a=set_entry:enc_people->about_Dogs}{color=#DA70D6}dogs{/color}{/a}."

$ protagonist = "character_B"
b "I specialize in making {a=set_entry:enc_recipes->about_Fruitcake}{color=#DA70D6}fruitcakes{/color}{/a}!"
I would like to combine that with the hyperlink feature you made a while back, but I think something is preventing the switch from happening. My guess is it has something to do with this bit:

Code: Select all

        def __init__(self,
                     sorting_mode=0,
                     show_locked_buttons=False,
                     show_locked_entry=False,
                     entry_screen="encyclopaedia_entry", # this one ?
                     tint_locked_image=True):
Thanks for sharing the encyclopaedia library with us by the way. It's a great VN feature for info-heavy games!

User avatar
munni
Newbie
Posts: 11
Joined: Sun Mar 17, 2019 4:14 pm
Contact:

Re: Encyclopaedia / Bestiary Framework

#96 Post by munni » Tue Jan 28, 2020 8:19 am

In order to make a 'new' encyclopaedia, I duplicated the screens in encyclopaedia.rpy into something like this:

Code: Select all

screen encyclopaedia_list_A(enc):
	...
screen encyclopaedia_entry_A(enc):
	...	

screen encyclopaedia_list_B(enc):
	...
screen encyclopaedia_entry_B(enc):
	...
The screens look like this:
codex2.jpg

They work alright once you're inside them, but I can't find how to switch between A and B in-game. Should I duplicate something inside enc.rpy as well?
Do I need to do something specific in order to fully create another encyclopaedia?
Human Bolt Diary wrote:
Tue Jan 28, 2020 12:20 am
If the entries change too, it sounds like you need two separate Encyclopaedas, each pointing to a different screen.

"encyclopaedia_entry" is just a default screen I've included. Any screen that takes an Encyclopaedia as an argument is valid.

If only the layout changes, you could probably override the entry_screen attribute with the name of another screen, then switch it back whenever you want.

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

Re: Encyclopaedia / Bestiary Framework

#97 Post by Human Bolt Diary » Fri Jan 31, 2020 11:47 pm

Do you mean switching the screen used by one Encyclopaedia, or switching which Encyclopaedia you're using?

Switching the entry screen used by one Encyclopaedia can be done by changing the Encyclopaedia's entry_screen attribute.

Changing which encyclopaedia you're sending to the list screen depends entirely on you and how you call the Encyclopaedia.

munni wrote:
Tue Jan 28, 2020 8:19 am
In order to make a 'new' encyclopaedia, I duplicated the screens in encyclopaedia.rpy into something like this:

Code: Select all

screen encyclopaedia_list_A(enc):
	...
screen encyclopaedia_entry_A(enc):
	...	

screen encyclopaedia_list_B(enc):
	...
screen encyclopaedia_entry_B(enc):
	...
The screens look like this:

codex2.jpg


They work alright once you're inside them, but I can't find how to switch between A and B in-game. Should I duplicate something inside enc.rpy as well?
Do I need to do something specific in order to fully create another encyclopaedia?
Human Bolt Diary wrote:
Tue Jan 28, 2020 12:20 am
If the entries change too, it sounds like you need two separate Encyclopaedas, each pointing to a different screen.

"encyclopaedia_entry" is just a default screen I've included. Any screen that takes an Encyclopaedia as an argument is valid.

If only the layout changes, you could probably override the entry_screen attribute with the name of another screen, then switch it back whenever you want.

User avatar
munni
Newbie
Posts: 11
Joined: Sun Mar 17, 2019 4:14 pm
Contact:

Re: Encyclopaedia / Bestiary Framework

#98 Post by munni » Thu Feb 06, 2020 5:49 am

Human Bolt Diary wrote:
Fri Jan 31, 2020 11:47 pm
Do you mean switching the screen used by one Encyclopaedia, or switching which Encyclopaedia you're using?

Switching the entry screen used by one Encyclopaedia can be done by changing the Encyclopaedia's entry_screen attribute.

Changing which encyclopaedia you're sending to the list screen depends entirely on you and how you call the Encyclopaedia.
I would like to be able to switch, depending on what point the player is in the game, between Encyclopaedia A (green) and B (purple), so I guess not a screen, but an entire Encyclopaedia. For example in chapter 1, you get A, and then in chapter 2 you get B. This change should also reflect in the hyperlinks.

Enclyclopaedias A and B are each divided into 4 categories/tabs:
- 'enc_people', 'enc_places', 'enc_lore', 'enc_mysteries' for A
- 'enc_profile', 'enc_locations', 'enc_info' and 'enc_cases' for B

There are 2 ways to show call the Encyclopaedia:

Code: Select all

# METHOD 1 - QUICK MENU BUTTON
action ShowMenu("encyclopaedia_list", enc_people)
# shows 'enc_people' category by default

# METHOD 2 - HYPERLINK
{a=set_entry:enc_places->about_London}London{/a}
To setup the hyperlinks, I used what you posted a couple years ago:

Code: Select all

define config.hyperlink_handlers = {
    "set_entry": set_enc_entry_from_text_anchor,
}

init -1500 python:
    def set_enc_entry_from_text_anchor(value):
        p = value.split('->')
        enc = getattr(store, p[0])
        entry = getattr(store, p[1])

        renpy.show_screen("encyclopaedia_entry", _transient="False")
        enc.SetEntry(entry)()
Python is not my forte, so I'm not sure how to set it up to switch between an Encyclopaedia and another.

User avatar
Ayael
Regular
Posts: 75
Joined: Fri Apr 07, 2017 2:17 pm
Projects: Anoldor, medieval fantasy otome game.
Contact:

Re: Encyclopaedia / Bestiary Framework

#99 Post by Ayael » Mon Feb 17, 2020 12:00 pm

I do my game in french and english, so I translate everything but somehow, name seems to not translate themselves properly. It's the first time I have this issue...

Code: Select all

]name=_("Les elfes"),
It's suppose to work that way (it does for the text content).

The translation string, appears as it should, on the translation file :

Code: Select all

translate english strings:

    # game/encylopedie.rpy:178
    old "Les elfes"
    new "The elves"
But, the translation is simply not working for all the title (and the title only). Since it's specific to the name only, I think the problem come from the way it is done.

Edit :
I resolve the issue by doing

Code: Select all

  label enc.active.name xalign 0.5
instead of :

Code: Select all

label enc.active.label xalign 0.5 
The ID disapeared, and the translation worked. I couldn't find a way to have the full translation ID + name.

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

Re: Encyclopaedia / Bestiary Framework

#100 Post by AERenoir » Thu Sep 17, 2020 8:15 am

So is there a way to paginate the list of entries instead of having a long list going down?
The glossary/encyclopaedia I'm trying to make is in the shape of a journal or dictionary and I kind of figured out how to imagemap the filter tags and the base, but I'm not sure how to input the entry buttons based on the format that already exist.

I'm thinking that I would like the entry buttons are themselves would be images/imagebuttons. I'm not sure how to even begin to do that. Something like this:

Image


I'd thought of just using a gallery that links to scene snippets instead, but I need the filter function.

User avatar
Ayael
Regular
Posts: 75
Joined: Fri Apr 07, 2017 2:17 pm
Projects: Anoldor, medieval fantasy otome game.
Contact:

Re: Encyclopaedia / Bestiary Framework

#101 Post by Ayael » Wed Sep 23, 2020 5:12 pm

AERenoir wrote:
Thu Sep 17, 2020 8:15 am
So is there a way to paginate the list of entries instead of having a long list going down?
The glossary/encyclopaedia I'm trying to make is in the shape of a journal or dictionary and I kind of figured out how to imagemap the filter tags and the base, but I'm not sure how to input the entry buttons based on the format that already exist.

I'm thinking that I would like the entry buttons are themselves would be images/imagebuttons. I'm not sure how to even begin to do that. Something like this:

Image


I'd thought of just using a gallery that links to scene snippets instead, but I need the filter function.
Don't use imagemap but screen langage, you can do the same things but with more flexibility, (hint : if you are used to image map you can just put a background with a full image and then position transparent imagebutton of the right size at the place you want).
Anyway to answer your question, yes you can definitely custom it to the way you like it ! (Even if doing an auto pagination require a little more knowledge.)

I can't give you the full answer since it would be a bit too tedious for me, but I hope it will still help you to know where to look in order to achieve your goal !

User avatar
DiamondDust132
Newbie
Posts: 20
Joined: Thu Sep 28, 2017 2:38 am
Organization: Team Requiem
itch: team-requiem
Location: Georgia
Contact:

Re: Encyclopaedia / Bestiary Framework

#102 Post by DiamondDust132 » Tue Jan 12, 2021 11:44 pm

Avalonica wrote:
Mon Nov 04, 2019 8:04 pm
Another thing that is very relevant is (at least from what I get when using the hyperlink) is that I do get the "about_dune" entry, but when I press ESC it opens the OPTIONS menu, so the only way to quit down the Encyclopaedia is: Close Entry > Return. It's too many steps. :oops:

When accessing the Encyclopaedia with ShowMenu("encyclopaedia_list", your_new_encyclopaedia ) an ESC is all that is needed to close it all down. Is there any way when "directly" calling a entry in the Encyclopaedia that we somehow when have "read" that entry we just can press ESC and return to the game.
Yeah, having this problem as well. No clue if this is still being worked on, but any help would be appreciated. I'm presuming (but I suck at python so maybe I'm totally off) the issue comes from 'showing' the screen instead of 'calling' it, so the game treats hitting ESC as if you're still on the dialogue screen and not in the encyclopaedia screen, so it just opens the save/options menu. Since middle clicking hides everything like when you're on the dialogue window, that seems to confirm it. Opening the glossary from the quick menu works as anticipated.

I'm using this code to get the hyperlinks working, so I'm thinking there's something there I gotta tinker with, but having no luck so far.

Code: Select all

define config.hyperlink_handlers = {
    "set_entry": set_enc_entry_from_text_anchor,
}

init -1500 python:
    def set_enc_entry_from_text_anchor(value):
        p = value.split('->')
        enc = getattr(store, p[0])
        entry = getattr(store, p[1])

        renpy.show_screen("encyclopaedia_entry", _transient="False")
        enc.SetEntry(entry)()
EDIT 1/20/21

Well, that's what I get for not reading the thread properly. Half of the answer to my question was there. Still haven't solved the 'right click opens the save menu' issue, but I've figured out the hyperlink issue. You just wanna edit the 'Close Entry' textbutton in encyclopaedia_screen.rpy like so:

Code: Select all

textbutton "Close Entry" id "close_entry_button" xalign .98 clicked [enc.Sort(sorting_mode=enc.default_sorting_mode),
                                                     Hide("encyclopaedia_list"),
                                                     Hide("encyclopaedia_entry", transition=dissolve),
                                                     enc.ResetSubPage(),]
              
 
So when the player clicks a hyperlink, now hitting 'Close Entry' will take you straight back to the dialogue window. That way, they don't have to hit 'Close Entry' and then 'Return.' One less step. I deleted the Return() part from the above code so that it doesn't skip the text ahead after closing the glossary, and I added a dissolve transition to make it look a little nicer. Again, I'm not great at python, so this might cause unintended effects, but I haven't noticed any so far.

frankfrankstud
Newbie
Posts: 12
Joined: Tue Feb 09, 2021 3:42 am
Contact:

Re: Encyclopaedia / Bestiary Framework

#103 Post by frankfrankstud » Wed Feb 10, 2021 12:20 am

Hello everyone,

Has anyone figured out the way to fix the hyperlink issue where escape opens the save menu instead of closing the encyclopedia? It's also causing an issue where my quick menu doesn't hide. I guess it's an issue with showing the screen instead of calling it?

User avatar
VolTitanDev
Newbie
Posts: 5
Joined: Mon May 25, 2020 12:07 pm
Projects: Foot fetish fortress VolTitan
IRC Nick: VolTitanDev
Deviantart: timefire69
itch: https://voltitandev.
Contact:

Re: Encyclopaedia / Bestiary Framework

#104 Post by VolTitanDev » Sat Mar 27, 2021 1:52 pm

Hi I was having some trouble understanding where to place the Zeus entry example

about_zeus = EncEntry(
parent=your_new_glossary,
name="Zeus",
text=[
"Zeus is the sky and thunder god in ancient Greek religion, who ruled as king of the gods of Mount Olympus."
" His name is cognate with the first element of his Roman equivalent Jupiter."
" His mythologies and powers are similar, though not identical, to those of Indo-European deities such as Indra, Jupiter, Perun, Thor, and Odin."
],
viewed_persistent=True,
)
Would the new entries placed in the encycopedia_screeen file or the screen_renpy file?

User avatar
Ayael
Regular
Posts: 75
Joined: Fri Apr 07, 2017 2:17 pm
Projects: Anoldor, medieval fantasy otome game.
Contact:

Re: Encyclopaedia / Bestiary Framework

#105 Post by Ayael » Sat Mar 27, 2021 2:46 pm

VolTitanDev wrote:
Sat Mar 27, 2021 1:52 pm
Hi I was having some trouble understanding where to place the Zeus entry example

about_zeus = EncEntry(
parent=your_new_glossary,
name="Zeus",
text=[
"Zeus is the sky and thunder god in ancient Greek religion, who ruled as king of the gods of Mount Olympus."
" His name is cognate with the first element of his Roman equivalent Jupiter."
" His mythologies and powers are similar, though not identical, to those of Indo-European deities such as Indra, Jupiter, Perun, Thor, and Odin."
],
viewed_persistent=True,
)
Would the new entries placed in the encycopedia_screeen file or the screen_renpy file?
Anywhere you want as long you don't put it inside something else, but you can put it into script.rpy too for example I personnaly created a new file just for all the entries.

Post Reply

Who is online

Users browsing this forum: Dragonstar89