Question about timed information overlay

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
madbunnie13
Newbie
Posts: 16
Joined: Sun Feb 09, 2014 11:35 pm
Contact:

Question about timed information overlay

#1 Post by madbunnie13 » Wed Oct 29, 2014 5:15 pm

So I am creating a game with an information which displays character information, and each time
it updates i want to have an overlay on the top right hand side of the game saying "XXX's profile has been updated"

It worked fine when I had only one information at a time, but can't seem to get it to run with a list of information:

Code: Select all

init python:
    information = []
    def popup_overlay():
        if len(information) > 0 and hide_popups == False:
            ui.frame(xanchor="right",xpos=1.0, ypos=0.1)
            ui.text(information[0])
    config.overlay_functions.append(popup_overlay)

screen show_popup_info:
    timer 3.0 repeat True action If(((information > 0) and information), true=information.pop(0), false=Hide('show_popup_info'))
and this is what i do in the actual script:

Code: Select all

    $ information.append("Girl's profile is updated")
    show screen show_popup_info

the error i get is:

File "game/functions.rpy", line 2, in <module>
timer 3.0 repeat True action If(information, true=information.pop(0), false=Hide('show_popup_info'))
IndexError: pop from empty list
Last edited by madbunnie13 on Wed Oct 29, 2014 6:59 pm, edited 2 times in total.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 747
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Question about timed information overlay

#2 Post by Milkymalk » Wed Oct 29, 2014 5:48 pm

Can you also post how it worked with one piece of information?
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

madbunnie13
Newbie
Posts: 16
Joined: Sun Feb 09, 2014 11:35 pm
Contact:

Re: Question about timed information overlay

#3 Post by madbunnie13 » Wed Oct 29, 2014 6:06 pm

this is all i changed for it to work with one piece of information

Code: Select all


screen show_popup_info:
    timer 3.0 action SetVariable("information", "")
init python:
    information = ""
    def popup_overlay():
        if information and hide_popups == False:
            ui.frame(xanchor="right",xpos=1.0, ypos=0.1)
            ui.text(information[0])
    config.overlay_functions.append(popup_overlay)

and in the scripts:

Code: Select all

$information = "Girl's profile has been updated"
show screen show_popup_info

User avatar
Milkymalk
Miko-Class Veteran
Posts: 747
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Question about timed information overlay

#4 Post by Milkymalk » Wed Oct 29, 2014 6:50 pm

While I'm not sure, the problem is most probably in this line:

Code: Select all

timer 3.0 repeat True action If(((information > 0) and information), true=information.pop(0), false=Hide('show_popup_info'))
What confuses me is the part "((information > 0) and information)". AFAIK "information" is True while it's not empty [], but what is the purpose of "(information > 0)"? What happens if you remove that?
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

madbunnie13
Newbie
Posts: 16
Joined: Sun Feb 09, 2014 11:35 pm
Contact:

Re: Question about timed information overlay

#5 Post by madbunnie13 » Wed Oct 29, 2014 6:55 pm

Code: Select all

 
len(information) > 0 and information
so the information needs to exist and has at least one element. Not sure if it is needed, but i put it in just to be save.

I tried to remove it and nothing happened, still getting the same error...

also the error i get is:

File "game/functions.rpy", line 2, in <module>
timer 3.0 repeat True action If(information, true=information.pop(0), false=Hide('show_popup_info'))
IndexError: pop from empty list

User avatar
Milkymalk
Miko-Class Veteran
Posts: 747
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Question about timed information overlay

#6 Post by Milkymalk » Wed Oct 29, 2014 8:01 pm

Just "information" as a condition should suffice. It only returns True if the list is non-empty.

I think I have an idea.

Screen actions are called the moment they are parsed, meaning that "information.pop(0)" will happen all the time without the timer actually being finished. You probably need to curry it in order to use it here, but I have my problems with curry functions myself. Can someone with more expertise with curry funtions please take over?
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

madbunnie13
Newbie
Posts: 16
Joined: Sun Feb 09, 2014 11:35 pm
Contact:

Re: Question about timed information overlay

#7 Post by madbunnie13 » Wed Oct 29, 2014 8:10 pm

T-T running out of ideas,
The information.pop should only be called if it's not empty...

User avatar
Milkymalk
Miko-Class Veteran
Posts: 747
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Question about timed information overlay

#8 Post by Milkymalk » Wed Oct 29, 2014 8:20 pm

Yes I know, but that's not how it works.

Remember how the documentation for screen language says that your screen code should not have effects outside the screen? That's the reason.

You need to curry the function, something like:

Code: Select all

popcurry = renpy.curry(information.pop)
and then call "popcurry(0)" as an action. No guarantee that this is the correct syntax though, I struggle heavily when I need to use currying myself.

The reason for this IS that it's not only called when it's executed, but it's called upon parsing and whatever it returns is called. A curry function is a function that returns a function, and that one is called when it's actually supposed to.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

madbunnie13
Newbie
Posts: 16
Joined: Sun Feb 09, 2014 11:35 pm
Contact:

Re: Question about timed information overlay

#9 Post by madbunnie13 » Wed Oct 29, 2014 8:32 pm

Code: Select all

screen show_popup_info:
    timer 3.0 repeat True action remove_used_info
        
init python:
    def RemoveUsedInfo():
        if(information):
            information.pop(0)
            
    remove_used_info = renpy.curry(RemoveUsedInfo)
no luck, doesn't pop the information, also makes the game run funny( clicking once will skip two lines), no errors but doesn't work.... :(

User avatar
Milkymalk
Miko-Class Veteran
Posts: 747
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Question about timed information overlay

#10 Post by Milkymalk » Wed Oct 29, 2014 8:34 pm

Sorry, I'm out of ideas for now. Anyone else?
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

madbunnie13
Newbie
Posts: 16
Joined: Sun Feb 09, 2014 11:35 pm
Contact:

Re: Question about timed information overlay

#11 Post by madbunnie13 » Wed Oct 29, 2014 8:46 pm

No worries, I'm sure someone will show us a different way to handle it. :D

Post Reply

Who is online

Users browsing this forum: No registered users