jsfehler / renpy-encyclopaedia

A Ren'Py plugin for creating an Encyclopaedia/Glossary/Bestiary or similar system.
https://renpy-encyclopaedia.readthedocs.io/
MIT License
58 stars 6 forks source link

Question about changing filter by next or previous #13

Open birctreel opened 7 months ago

birctreel commented 7 months ago

Hello there! I find no clues about my question so I have to bother here for a proper answer. It would be great if you can kindly point out what's wrong I did.

My goal : making 2 buttons to toggle filter forward or backward. Here is my UI example: image

My idea: Set a list of all my subject. i. e: default all_subject = ['subject1','subject2']

Set a screenvariable to count the number:

Screen Test():
    default order = 0
    fixed:
        imagebutton 'left_arrow':
            if order>0:
                action (SetScreenVariable('order',order-1,enc.FilterBySubject(all_subject[order])))
       text all_subject[order]
        imagebutton 'right_arrow':
            if order<len(all_subject):
                action (SetScreenVariable('order',order+1),enc.FilterBySubject(all_subject[order]))

someting like that! However, I find it doesn't work properly, or to say, it somehow not filter in the current order. Sometimes I click the next, but it stay the same, or even go back to previous subject. By the way, the order's value works well, but only the filter and the subject got wrong.

*Also, when I write some code like

Screen Test():
    for i in range (0,len(all_subject)):
        textbutton all_subject[i] action enc.FilterBySubject(all_subject[i])

if works well.

Maybe something goes wrong about the data refreshing? Or I wonder if there are anything wrong I did?

jsfehler commented 7 months ago

this line is missing a closing ) after order-1: action (SetScreenVariable('order',order-1,enc.FilterBySubject(all_subject[order])))

You also don't need a custom list, the Encyclopaedia object has the attribute subjects which you can use instead.