[Screen language] Set an argument in used screen to call a class

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
KingsCard
Newbie
Posts: 14
Joined: Sat Feb 17, 2018 8:58 am
Contact:

[Screen language] Set an argument in used screen to call a class

#1 Post by KingsCard »

Hi,

I'm trying to customize a screen depending on an argument :

Code: Select all

screen characters: #parent screen
    default param = None
    frame:

        xpos c_datas.cur_loc_x
        ypos c_datas.cur_loc_y
        textbutton "Camille" action SetScreenVariable("param","c_datas") 

    frame:

        xpos d_datas.cur_loc_x
        ypos d_datas.cur_loc_y
        textbutton "Derek" action SetScreenVariable("param","d_datas")

    if param: #test param status
        frame:
            align (0.5,0.5)
            textbutton "[param]" action SetScreenVariable("param","d_datas")
            
    if param:
        use whisp(param)

screen whisp(param): #child screen
    frame:

        yalign 0.5
        xalign 0.5
        has vbox
        text "What you have in mind"
        for k,v in param._events_odds_dict[gt.tod]:
            text "[k] ([v] %)"

        text "What do you suggest ?"
        for item in param._events_dict:
            textbutton ("[item]") action SetVariable("param.whispered_event",item)
        textbutton "OK" action [Function(param.suggestion , param.cur_event, param.whispered_event, 10), SetScreenVariable("param",None)]
What I'm aiming to do : when you click on "Camille" or "Derek", it shows a screen with the corresponding instances of classes.

Problem is, I can't find the way to set the variable "param" to replace the names of instances "c_datas" & "d_datas". I tried differents ways without results.

Someone has a clue to do that ?

Thanks a lot ! :)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: [Screen language] Set an argument in used screen to call a class

#2 Post by Remix »

SetScreenVariable("param", c_datas) # value is a global object so no quotes
SetField( param, "attribute_name_in_quotes", value )

might get you heading in the right direction.
Frameworks & Scriptlets:

KingsCard
Newbie
Posts: 14
Joined: Sat Feb 17, 2018 8:58 am
Contact:

Re: [Screen language] Set an argument in used screen to call a class

#3 Post by KingsCard »

Remix wrote: Fri Dec 14, 2018 6:51 am SetScreenVariable("param", c_datas) # value is a global object so no quotes
Hi Remix, this did the job ! Thank you very much :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]