define setlclvar = SetLocalVariable (un expected result)

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
Kia
Miko-Class Veteran
Posts: 921
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Skype: KiaAzad
Contact:

define setlclvar = SetLocalVariable (un expected result)

#1 Post by Kia » Mon Mar 25, 2019 1:27 pm

I've tried to abbreviate the screen actions but it doesn't seem to work as expected.
in this test:

Code: Select all

init -100:
    define setlclvar = SetLocalVariable

screen loc(a = "1",b = "11"):
    default tt = ""
    vbox:
        button:
            text a
            action NullAction()
            hovered setlclvar("tt",b)
            unhovered setlclvar("tt","")
        text tt
it seems that "unhovered" have a problem with abbreviated version of the action and doesn't work, when try to reload, the game seems to enter an infinite loop.
the problem wouldn't occur if I replace the "setlclvar" with "SetLocalVariable" for "unhovered"
doesn't seem to have any problem with "SetScreenVariable" either

rames44
Veteran
Posts: 231
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: define setlclvar = SetLocalVariable (un expected result)

#2 Post by rames44 » Wed Mar 27, 2019 12:19 pm

I don’t know if this has anything to do with it, but the SetLocalVariable function is marked as “not pure” in the Ren’py source code, while most other actions are marked as pure. So there may be something “special” about SetLocalVariable.

User avatar
Kia
Miko-Class Veteran
Posts: 921
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Skype: KiaAzad
Contact:

Re: define setlclvar = SetLocalVariable (un expected result)

#3 Post by Kia » Sat Mar 30, 2019 12:48 am

rames44 wrote:
Wed Mar 27, 2019 12:19 pm
the SetLocalVariable function is marked as “not pure” in the Ren’py source code, while most other actions are marked as pure. So there may be something “special” about SetLocalVariable.
now I have to wonder what @renpy.pure does.
I wish there was somewhere I could learn about these stuff, maybe I could learn enough to contribute to the development of renpy. unfortunately, while learning to make games with renpy is very easy, when it comes to what's going on under the hood, there's a lack of comments or documentation to give me an idea what am I looking at.

rames44
Veteran
Posts: 231
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: define setlclvar = SetLocalVariable (un expected result)

#4 Post by rames44 » Sat Mar 30, 2019 12:43 pm

The concept of “pure” in Ren’py is “if called with the same inputs, you’ll always get the same output.” It implies that the item (function/object/whatever) doesn’t have any internal state that affects its behavior. I know that PyTom uses that information (pure or not) as an optimization when doing things like screen prediction. I haven’t looked at SetLocalVariable in any detail to see why it’s not pure or has anything to do with your issue - it was just something I noted.

Post Reply

Who is online

Users browsing this forum: No registered users