Ren'Py [SOLVED]Menuitem, condition and function on the same line

GoldenD

Member
Sep 30, 2018
102
70
Python:
define dlgOffice = {
"Work" : "Find some info for my next job",
.../...
}

.../...

menu choiceMyOffice:
        # tried text(...) / "{}".format...  / "%s" %...
        "[dlgOffice['Work']]" if currentHour >= 6 and 1 == 1:

            call officeWork
Hi,

FIRST
if i understood web infos, we can condition menuitem like that and only that :
Python:
"menuitem" if condition:
It works fine, ok. But now, my condition has to be result of a function (a minimal wish to code it seems).
I have my own solution with a class like that :
Python:
"menuitem" if myClassFunction.result()==1 :
The question is : is there something more adapted to renpy ?

SECOND
I know, again with strings, I make efforts but I block intellectually.
My menuitem is a variable, of course. If i do as follows, it's alright
Python:
define dlgOfficeSearchJob   = "Find some info for my next job"

.../...

menu choiceMyOffice:

        "[dlgOfficeSearchJob]" if currentHour >= 6 and 1 == 1:

            call officeWork

Now, if i want to do this, I guess I’m falling back into an interpolation worry !

Python:
define dlgOffice = {
"Work":"Find some info for my next job",
.../...
}
.../...
menu choiceMyOffice:

        # tried text(...)  / "%s" %...  / "{}".format...
        "[dlgOffice['Work']" if currentHour >= 6 and 1 == 1:


            call officeWork
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,368
15,281
The question is : is there something more adapted to renpy ?
No.


Python:
define dlgOffice = {
"Work":"Find some info for my next job",
.../...
}
.../...
menu choiceMyOffice:

        # tried text(...)  / "%s" %...  / "{}".format...
        "[dlgOffice['Work']" if currentHour >= 6 and 1 == 1:
Ren'py can't use dictionaries for its text interpolation.