[SOLVED]When using {a=call:} to make dictionary system

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
User avatar
birctreel
Regular
Posts: 29
Joined: Wed Dec 20, 2017 7:17 am
Projects: Knell of st.Godhrkar
Organization: -Andinomie-
Tumblr: birctreel
Location: Beijing, China
Contact:

[SOLVED]When using {a=call:} to make dictionary system

#1 Post by birctreel » Sat Sep 22, 2018 11:20 pm

Hello everyone here!
I'm making a VN game with dictionary system - a simple and regular one: when we click the red key word in our script, there will be a new frame with the key word and its explanation shown nearby. My plan is like:
Image
And Code is like:

Code: Select all

    "Alone in the holy chapel of St. Godhrkar, Hayceno concludes his prayer. He then looks up to the magnificent machine carved in a rather peculiar decor – a pair of wings of flame and the apostles with the hourglass in one of their hands. {p}Though it is the religious  symbol of {a=call:dictionary}West-Iyrie{/a}, it still requires technology to function. For some time, the whole chapel is filled with the sound of flowing sand and the rotating gears."
    
label dictionary:
    show screen dic(x = renpy.get_mouse_pos()[0],x = renpy.get_mouse_pos()[1])
    return
    
screen dic(x,y):
    predict False
    tag frame
    zorder 250
    vbox:
        xpos x
        ypos y
        frame:
            style_prefix "dic"
            xmaximum 400
            has vbox
            #label persistent.Dic xalign .5 
            #text persistent.Dicc ypos 20 xpos 20 size 20
            label "West-Iyrie"
            text "The most widely held religion in the world, originated in Thalizac, Promland. Believing in the unity of the binary gods Andinomie, and their angels, Ychsympal. Due to historical reasons, however, it's not as popular in Promland, except in Thalizac."
    
    
However there is a big problem that
When we click the key word, the dictionary frame shows as soon as the script goes forward. I don't know how to stop it. Is there any way, when click the word which is linked by {a=call:}, the script could not go forward, but only the frame shows?



Here is my own stupid method but still has big problem:
I'm trying to add a rollback code, to offset it:

Code: Select all

label dictionary:
    show screen special
    show screen dic(x = renpy.get_mouse_pos()[0],x = renpy.get_mouse_pos()[1])
    return
    
screen special:
    predict False
    on "show" action (Rollback(), Hide("special"))
    
But as long as it rolls back, the dictionary frame won't show either.

Could there are any solutions of this problem?

Thank you very much for reading this problem. Hope we can solve it together QAQ
Last edited by birctreel on Sun Sep 23, 2018 7:52 am, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1456
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: When using {a=call:} to make dictionary system

#2 Post by philat » Sun Sep 23, 2018 5:12 am

Since I assume the glossary will be for more than one thing.

Code: Select all

init python:
    def glossary_handler(target):
        x, y = renpy.get_mouse_pos()
        renpy.show_screen("glossary", target, x, y)
        renpy.restart_interaction()

    config.hyperlink_handlers["glossary"] = glossary_handler

default glossary_dict = {
"West-Iyrie":"The most widely held religion in the world, originated in Thalizac, Promland. Believing in the unity of the binary gods Andinomie, and their angels, Ychsympal. Due to historical reasons, however, it's not as popular in Promland, except in Thalizac.",
"Blah-blah": "Lorem ipsum etc etc"
}

screen glossary(target, x, y): # deleted styling elements but feel free to add them back
    zorder 250
    button background None action Hide("glossary")
    vbox:
        xpos x
        ypos y
        frame:
            xmaximum 400
            has vbox
            label target
            text glossary_dict[target]

label start:
    "Though it is the religious  symbol of {a=glossary:West-Iyrie}West-Iyrie{/a}, it still requires technology to function. {a=glossary:Blah-blah}For{/a} some time, the whole chapel is filled with the sound of flowing sand and the rotating gears."

User avatar
birctreel
Regular
Posts: 29
Joined: Wed Dec 20, 2017 7:17 am
Projects: Knell of st.Godhrkar
Organization: -Andinomie-
Tumblr: birctreel
Location: Beijing, China
Contact:

Re: When using {a=call:} to make dictionary system

#3 Post by birctreel » Sun Sep 23, 2018 7:51 am

philat wrote:
Sun Sep 23, 2018 5:12 am
Since I assume the glossary will be for more than one thing.

Code: Select all

init python:
    def glossary_handler(target):
        x, y = renpy.get_mouse_pos()
        renpy.show_screen("glossary", target, x, y)
        renpy.restart_interaction()

    config.hyperlink_handlers["glossary"] = glossary_handler

default glossary_dict = {
"West-Iyrie":"The most widely held religion in the world, originated in Thalizac, Promland. Believing in the unity of the binary gods Andinomie, and their angels, Ychsympal. Due to historical reasons, however, it's not as popular in Promland, except in Thalizac.",
"Blah-blah": "Lorem ipsum etc etc"
}

screen glossary(target, x, y): # deleted styling elements but feel free to add them back
    zorder 250
    button background None action Hide("glossary")
    vbox:
        xpos x
        ypos y
        frame:
            xmaximum 400
            has vbox
            label target
            text glossary_dict[target]

label start:
    "Though it is the religious  symbol of {a=glossary:West-Iyrie}West-Iyrie{/a}, it still requires technology to function. {a=glossary:Blah-blah}For{/a} some time, the whole chapel is filled with the sound of flowing sand and the rotating gears."
!!!!!!!!!!!!!!!!!!!!!!!!
Thank you so much it works perfectly!!!!!!!!!!
And it's exactly what I'm thinking! And even more, the dictionary is also great way to store every key words!
Don't know how to express my high gratitude to you! Thank you so much for that!!

philat
Eileen-Class Veteran
Posts: 1456
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: [SOLVED]When using {a=call:} to make dictionary system

#4 Post by philat » Sun Sep 23, 2018 8:28 am

No problem. Good luck with your game; it looks really interesting.

User avatar
birctreel
Regular
Posts: 29
Joined: Wed Dec 20, 2017 7:17 am
Projects: Knell of st.Godhrkar
Organization: -Andinomie-
Tumblr: birctreel
Location: Beijing, China
Contact:

Re: [SOLVED]When using {a=call:} to make dictionary system

#5 Post by birctreel » Sun Sep 23, 2018 9:36 am

philat wrote:
Sun Sep 23, 2018 8:28 am
No problem. Good luck with your game; it looks really interesting.
Thanks!
Actually we already had a demo. It's here:viewtopic.php?f=59&t=48629
Now I'm just trying to rewrite the UI to make it better :D
Best wishes to you XD

Post Reply

Who is online

Users browsing this forum: No registered users