Page 1 of 1

SL script parsing inconsistencies.

Posted: Tue Jul 14, 2015 8:29 pm
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.