Feature request: improving substitution

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Feature request: improving substitution

#1 Post by Elmiwisa »

This request consist of multiple parts, each can be done separately. They are probably very simple to do, so I hope they will be implemented in future version of Ren'Py. They are:

1. Recognizing Unicode marker when parser need a string. Right now Ren'Py will cause an error if you attempt something like this:

Code: Select all

menu:
    u"Lalala~\u266B":
        me u"Me can't hear you heehee\u2764"
That's because when Ren'Py, while looking for a string, do not allow the possibility of a string having the "u" marking it being an Unicode string. Of course, I could do something like this and it will work for this situation:

Code: Select all

menu:
    "Lalala~\u266B":
        me "Me can't hear you heehee\u2764"
Because Ren'Py will substitute in Unicode when the string are about to be displayed. However, this is not quite satisfactory. The string STAY as "Lalala~\u266B" for as long as it can, passing through many other step while still in that form (ie. the Unicode code stay as a code, not being substituted with the actual character yet), preventing these step from acting on the string properly. For example, in the menu screen code, I might want to move the button around based on the location of the heart symbol in the string.
Beside, the problem go deeper than that. If an user-defined statement is made, and in the parse method, you ask for a string using l.string(), then it will also fail to recognize an "u"-marked string.
I think this issue would be easily resolved by making it so that Ren'Py recognize an "u"-marked string as a string.

2. Arbitrary expression substitution. I am not sure why this isn't done yet, but it seems like a nice idea to simply let people put any expression into a [] in a say or menu statement, and have it evaluate. Ren'Py already have the ability to evaluate arbitrary expression, so it's not an issue with a lack of ability. The only thing I think could have cause trouble here is Ren'Py trying to predict image and screen and thus might need to evaluate the expression many many times. However, seems like the only thing that do substitution is a Text gadget, and they seems simple enough that there is no need to predict them. Either that, or warn people somewhere that they can't do anything too intensive, or do something that cause changes somewhere else, in a square bracket. At the current state, the substitution can't even look into a list, forcing you to assign its value to a variable first.

3. Converting to string first when doing !q. Now if you output something that isn't string, and contains bracket in it and so you need to use !q, you would have to manually convert to string in a new variable before displaying it. If #2 is done, then this suggestion isn't needed. But right now it's quite annoying, especially if you are like me. I am careful and so I always use !q whenever I did not intend for the variable to contains any text formatting or anything, even if it's just number, because I try to avoid making any possible errors. That leads me to the next one:

4. Quote by default. Give a config option, that make everything in bracket will be quoted by default. Considering how rare it is that you would want some text formatting in your variable, this is probably a better choice. Add in the counterpart of !q, to specifically indicate that the variable should not be quoted.

5. Substitution early. Right now Ren'Py is somewhat schizophrenic about this. In say statement thing work as I wanted: the substitution were made before the screen code, so the screen code know the final text to display, assuming there are no text tag. For menu statement however the substitution is made after the screen code, so all the [] are still there by the time the menu code run. So you can't for example, readjust the position of button based on what the text content or its length.

Thank you!!! :D

Post Reply

Who is online

Users browsing this forum: No registered users