I know that I saw this "somewhere", and forgot to save the example... Now, I have no idea what to search for, to find it.
It involved inline conditional "if" statement, in the RenPy portion of code. Though, I have a feeling it was actually just inline python.
It looked similar to this, I believe...
e "This is" if(time==night) "a clear night" (else) "a wonderful afternoon", ",just like my childhood."
Resulting in...
"This is a clear night, just like my childhood."
or
"This is a wonderful afternoon,just like my childhood."
inline conditional text, "some text"if(this)"write this too"
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.
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.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3784
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: inline conditional text, "some text"if(this)"write this too"
I'm not sure this is correct (or works, its untested), but I assume something like this?
Code: Select all
define night = [night]
if some_condition:
$ night = a clear night
else:
$ night = a wonderful afternoon
e "This is [night], just like my childhood"
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: inline conditional text, "some text"if(this)"write this too"
That is the way I know how to do that now... But, with the millions of possible variations, it is unrealistic to do it that way. Which is why I was looking for the inline code.
Thank-you for that code. I am sure that someone will find that solution suitable for them.
I simplified my sample, just for sake of trimming the complex fat from the actual use. If I find no other way to do this inline, I may just resort to doing it in a python block. However, that is counterproductive to production. Since I lose the simplicity of RenPy dialogue typing, at that point. (Same, same... Because the complexity needed will ultimately be the same both ways. RenPy's way is just easier for my brain to digest.)
One thing I found, was in the MENU options... But it doesn't work inline, for dialogue.
Menu:
"Something":
"Something conditional" if xTIME == "night":
That displays the second answer, in a choice-menu, only if xTIME equals "night"... Sort-of inline... But what I wanted was the missing "then" component...
I actually would expect to have seen that worded...
if xTIME == "night"; "Something conditional": (With ; being the missing "then" statement.)
But, for my use, that MENU thing would look more like this, for the "SAY" conditional.
e "Something static" if xTIME == "night"; "add this text to the prior if night" else "add this instead":
I may have another suitable work-around for my situation. But I would rather find that one odd code-hack... or whatever it was that I found last time.
Thank-you for that code. I am sure that someone will find that solution suitable for them.
I simplified my sample, just for sake of trimming the complex fat from the actual use. If I find no other way to do this inline, I may just resort to doing it in a python block. However, that is counterproductive to production. Since I lose the simplicity of RenPy dialogue typing, at that point. (Same, same... Because the complexity needed will ultimately be the same both ways. RenPy's way is just easier for my brain to digest.)
One thing I found, was in the MENU options... But it doesn't work inline, for dialogue.
Menu:
"Something":
"Something conditional" if xTIME == "night":
That displays the second answer, in a choice-menu, only if xTIME equals "night"... Sort-of inline... But what I wanted was the missing "then" component...
I actually would expect to have seen that worded...
if xTIME == "night"; "Something conditional": (With ; being the missing "then" statement.)
But, for my use, that MENU thing would look more like this, for the "SAY" conditional.
e "Something static" if xTIME == "night"; "add this text to the prior if night" else "add this instead":
I may have another suitable work-around for my situation. But I would rather find that one odd code-hack... or whatever it was that I found last time.
- Belgerum
- Regular
- Posts: 110
- Joined: Thu Nov 06, 2014 12:24 am
- Skype: belgerum09
- Soundcloud: Belgerum
- itch: Belgerum
- Contact:
Re: inline conditional text, "some text"if(this)"write this too"
This should work:
Code: Select all
$ e ("This is " + ("a clear night" if (time=="night") else "a beautiful morning" if (time=="morning") else "a wonderful afternoon") + ", just like my childhood.")
Re: inline conditional text, "some text"if(this)"write this too"
That is nearly perfect... I just couldn't fathom the inline code, within the "Say" statement.
Brain-twistingly backwards, but functional for what I was looking for.
{Do this} if (this is true)
instead of...
if (this is true) {Do this}
Thanks-again, both of you.
Brain-twistingly backwards, but functional for what I was looking for.
{Do this} if (this is true)
instead of...
if (this is true) {Do this}
Thanks-again, both of you.
Re: inline conditional text, "some text"if(this)"write this too"
Follow-up... info
This fails for the "narrator". (A line without a character-value.)
"This is the narrator talking"
This clearly works
$e ("..." + ("000" if(0==0) else "111"))
and to display NOTHING if no "else" {Needs SOMETHING to NOT print. }
$e ("..." + ("000" if(0==0) else ""))
These do not work, for various reasons...
* No "else" {Trying to add "+" [NOTHING] if it is untrue/true.}
$e ("..." + ("000" if(0==0)))
"Narrator", which is devoid of a [CHARACTER]
("..." + ("000" if(0==0) else "111"))
or/and
"..." + ("000" if(0==0) else "111")
For the moment, I just created a generic "narrator", so I can use $NARR to make it work.
This fails for the "narrator". (A line without a character-value.)
"This is the narrator talking"
This clearly works
$e ("..." + ("000" if(0==0) else "111"))
and to display NOTHING if no "else" {Needs SOMETHING to NOT print. }
$e ("..." + ("000" if(0==0) else ""))
These do not work, for various reasons...
* No "else" {Trying to add "+" [NOTHING] if it is untrue/true.}
$e ("..." + ("000" if(0==0)))
"Narrator", which is devoid of a [CHARACTER]
("..." + ("000" if(0==0) else "111"))
or/and
"..." + ("000" if(0==0) else "111")
For the moment, I just created a generic "narrator", so I can use $NARR to make it work.
- Belgerum
- Regular
- Posts: 110
- Joined: Thu Nov 06, 2014 12:24 am
- Skype: belgerum09
- Soundcloud: Belgerum
- itch: Belgerum
- Contact:
Re: inline conditional text, "some text"if(this)"write this too"
you won't be able to remove the "else" part from inline. That's just how python works. (else "") will work if you want nothing to happen, and so will (else None).
The usual way of using the narrator will not work here because it is a python statement. Renpy knows to assume the narrator character when nothing is given, but python does not.
The usual way of using the narrator will not work here because it is a python statement. Renpy knows to assume the narrator character when nothing is given, but python does not.
Who is online
Users browsing this forum: Ahrefs [Bot], downover, Google [Bot]