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: 104
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: 104
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: 67
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: 10
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: 104
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: 10
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: 104
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: 10
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: 67
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.

Post Reply

Who is online

Users browsing this forum: No registered users