screen actions without buttons

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

screen actions without buttons

#1 Post by Kia »

I'm wondering if there's an easy way to trigger screen actions and functions without a button or resorting to timers? something to replace this:

Code: Select all

screen add2set:
    default test = []
    for i in range(6):
        timer .1 action AddToSet(test,1)
I know using a python function on the screen show is a way better idea, but I'm trying to test the limits of using a screen as a function replacement.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: screen actions without buttons

#2 Post by trooper6 »

Screens aren't supposed to have side effects that are visible from outside the screen. As the documentation says: "Screens must not cause side effects that are visible from outside the screen. Ren'Py will run a screen multiple times, as it deems necessary. It runs a screen as part of the image prediction process, before the screen is first shown. As a result, if running a screen has side effects, those side effects may occur at unpredictable times."

So it seems having your screen directly doing something is a bad idea. A Timer seems like the ways to go for you. Or if you really want to be complicated, you could create a UDD.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: screen actions without buttons

#3 Post by Kia »

well I know that screens code runs multiple time, however I can't see no difference between running the code inside a screen or inside a screen using a python function, that aside, I'm trying to keep the variables in the screens scope, using python means I have to define my variables global.
if a timer is a correct way to do it, something like timer with 0 delay should be the other, better correct way as well, something like:

Code: Select all

screen add2set:
    default test = []
    for i in range(6):
        doit action AddToSet(test,1)
I'm trying to make sure something like this doesn't exist before suggesting it, maybe there's a python equivalent that I'm not aware of

Code: Select all

screen add2set:
    default test = []
    for i in range(6):
        $ renpy.AddToSet(test,1)

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: screen actions without buttons

#4 Post by Alex »

In the first place, why do you want to fill the list inside a screen? Why not make it outside of the screen and then pass it to screen? What do you try to achieve?

Code: Select all

screen scr(scr_list):
   for item in scr_list:
       text "[item]"

lanel sater:
    $ my_list = [1,2,3,4,5]
    show screen scr(my_list)
    "?"

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: screen actions without buttons

#5 Post by Kia »

I have no use for it yet but I figured i can keep track of things while the screen is shown inside the screen instead of keeping a separate list, for example:

Code: Select all

default things = ["thing 1", "thing 2", "thing 3"]

screen things_click(t):
    default showem = []
    vbox:
        for i in range(len(t)):
            $ renpy.AddToSet(showem,1)
            if showem[i]:
                button:
                    text t[i]
                    action SetDict(showem, i, 0)

...
show screen things_click(things)
I can pass a list to that screen to show some objects, and it can keep track of the variable data inside the screen without changing anything outside of the screen, there's no need to keep track of what is what outside of that screen, there's no need to worry about the length of the list I pass to it and once I'm done the data is discarded by hiding the screen without touching the original list or any other variable. it can be very handy in battle systems or something like that I assume.
in my head it's like private variables as oppose to public ones.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot