Can Python search all say statements between two labels?

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
Thailandian
Regular
Posts: 30
Joined: Tue Jun 01, 2021 6:24 am
Contact:

Can Python search all say statements between two labels?

#1 Post by Thailandian »

I'm working on a scene viewer that would, among other things, be able to list scenes that contain a word or phrase.

The idea is that every scene would start with a label; then if I could use python to search for the term between that label and the next, if the term appears, python would return that label (and therefore scene) as one that the user might wish to view.

I have read about the Dialogue History system, and it looks like it may have potential, but as far as I understand, it seems to be limited by the config.history_length variable. Also, the HistoryEntry class does not have a label field.

Anyway, as always, any ideas or suggestions (including bad ones) are most welcome!

User avatar
m_from_space
Miko-Class Veteran
Posts: 889
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Can Python search all say statements between two labels?

#2 Post by m_from_space »

Probably not as easily. Because you're asking about something that a Renpy interpreter is doing when executing the code.

You could provide the user with a given set of keywords manually for each label on your side of course.

One thing that *might* work though is using a translation file (without translating it). So you could create a translation file for some dummy language, then use renpy.file() to open it while in your game - I don't know if you can - and then read through that file in search for keywords and extract the label it is referring to (the label name is always part of an entry).

I'm really not sure what your goal is here, but good luck. ;)

Thailandian
Regular
Posts: 30
Joined: Tue Jun 01, 2021 6:24 am
Contact:

Re: Can Python search all say statements between two labels?

#3 Post by Thailandian »

Actually that's an interesting idea - also the "Extract Dialogue" function has quite a few options so perhaps the tab delimited spreadsheet may give me the data I need. In any case, I suspect preparing a separate file and loading it into a variable using renpy.file() may be the way to go.

To explain my goal, say for example in a crime mystery, the detective finds a bloody pair of scissors. The user recalls someone mentioning missing scissors from an earlier chapter, and wants to search the entire novel so far for any scene in which the word 'scissors' was mentioned. A search of the database would return every scene viewed so far that fits this criteria. The user could then view those scenes to see who said it, what was the context etc.

Anyway, my next step will be to look at the various Extract Dialogue outputs and investigate renpy.file().

Post Reply

Who is online

Users browsing this forum: Bing [Bot]