SL script parsing inconsistencies.

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
User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

SL script parsing inconsistencies.

#1 Post by xela »

There is something evil at work in the SL parser/scopes, I was helping someone in Q&A section with adding transform to NVL mode and ran into this:

*transform is plainly defined as:

Code: Select all

transform my_fade(t, alpha):
    alpha 1.0
    linear t alpha alpha

Code: Select all

        # Display dialogue.
        for who, what, who_id, what_id, window_id in dialogue:
            $ index = dialogue.index((who, what, who_id, what_id, window_id))
            $ l = len(dialogue)

            window:
                id window_id

                has hbox:
                    spacing 10
                   
                if index == l - 1:
                    $ pass
                elif index == l - 2 and "{fast}" not in dialogue[l-1][1]:
                    at my_fade(1, 0.5)
                else:
                    at my_fade(0, 0.5)

                if who is not None:
                    text who id who_id

                text what id what_id
The above seems to work!

=========================
Now this:

Code: Select all

        # Display dialogue.
        for who, what, who_id, what_id, window_id in dialogue:
            $ index = dialogue.index((who, what, who_id, what_id, window_id))
            $ l = len(dialogue)

            window:
                id window_id

                has hbox:
                    spacing 10

                python:
                    pass
                   
                if index == l - 1:
                    $ pass
                elif index == l - 2 and "{fast}" not in dialogue[l-1][1]:
                    at my_fade(1, 0.5)
                else:
                    at my_fade(0, 0.5)

                if who is not None:
                    text who id who_id

                text what id what_id

Code: Select all

                python:
                    pass
(or anything after python, really) for some reason prevents the transforms from being applied... Nothing else is changed in the code at all.

=========================
Another issue (this isn't new, I just never posted it since working around it is very easy):

Code: Select all

        # Display dialogue.
        for who, what, who_id, what_id, window_id in dialogue:
            $ index = dialogue.index((who, what, who_id, what_id, window_id))
            $ l = len(dialogue)

            window:
                id window_id

                has hbox:
                    spacing 10

                $ var = list(i for i in ["1", "2", "3"] if i in dialogue)
                   
                if index == l - 1:
                    $ pass
                elif index == l - 2 and "{fast}" not in dialogue[l-1][1]:
                    at my_fade(1, 0.5)
                else:
                    at my_fade(0, 0.5)

                if who is not None:
                    text who id who_id

                text what id what_id

Code: Select all

$ var = list(i for i in ["1", "2", "3"] if i in dialogue)
Simple list comprehension throws NameError claiming that dialogue is not defined...

============================
I am not saying that either example is meaningful as they are, but I can easily add meaning to them. Both are very easy to work around but if it's not difficult to fix, it may be sensible to do so.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: No registered users