Pop-Up FIFO Pile
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.
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.
Pop-Up FIFO Pile
Hello,
this is kind of a continuation of a previous topic I made where I asked about a timer in a label. Since I found out that I can't use timers in labels and while loops in screens, I'm kind of in a pickle... So here's my issue:
I'm trying to make a pile of PopUps, so that if the player makes 2 consecutive actions that grants him a PopUp, they will have time to read them both. To that effect I wanna make a loop that will go through the Pop-up pile, doing one loop every 6 seconds, and allowing for an entry to enter the pile at any moment during the scroll-through of the loop. I'm joining my original code, which I know has mistakes but I feel it's more clear this way.
Also I should mention, I have tried using a single screen statement with a "for" loop going through the pile (without a "label" to manage all that like I have now) but this didn't allow the latest point I need the "allowing for an entry" part, the loop would reset).
I think that's all the information, do ask if you need more.
this is kind of a continuation of a previous topic I made where I asked about a timer in a label. Since I found out that I can't use timers in labels and while loops in screens, I'm kind of in a pickle... So here's my issue:
I'm trying to make a pile of PopUps, so that if the player makes 2 consecutive actions that grants him a PopUp, they will have time to read them both. To that effect I wanna make a loop that will go through the Pop-up pile, doing one loop every 6 seconds, and allowing for an entry to enter the pile at any moment during the scroll-through of the loop. I'm joining my original code, which I know has mistakes but I feel it's more clear this way.
Also I should mention, I have tried using a single screen statement with a "for" loop going through the pile (without a "label" to manage all that like I have now) but this didn't allow the latest point I need the "allowing for an entry" part, the loop would reset).
I think that's all the information, do ask if you need more.
-
- Veteran
- Posts: 293
- Joined: Fri Sep 17, 2021 2:09 am
- Organization: enaielei
- Tumblr: enaielei
- Deviantart: enaielei
- Github: enaielei
- Skype: enaielei
- Soundcloud: enaielei
- itch: enaielei
- Discord: enaielei#7487
- Contact:
Re: Pop-Up FIFO Pile
I suggest to probably keep a showing screen that watches for the elements in a popup list. You can do so by adding that screen, for example, in the overlay screens.
Code: Select all
init python:
config.overlay_screens.append("popup")
def add_popup(*popups):
for popup in popups:
store.popups.insert(0, popup)
default popups = []
screen popup():
default time = 6
default popup = None
timer 0.01:
repeat True
action (SetScreenVariable("popup", popups.pop(len(popups) - 1)) if popups and not popup else NullAction())
if popup:
timer time action SetScreenVariable("popup", None)
text popup: # the actual popup display itself, style according to what you want...
align (0.5, 0.5)
label start:
$ popups.insert(0, "Pop up 1")
"Queue Pop up 1"
$ popups.insert(0, "Pop up 2")
"Queue Pop up 2"
$ add_popup("Pop up 3", "Pop up 4") # you can also queue single or multiple popups using the helper function add_popup
"Queue Pop up 3 and 4"
Re: Pop-Up FIFO Pile
Thank you for your answer, I will try that ASAP
Re: Pop-Up FIFO Pile
I got a "nonetype object is not callable" error by inserting your code into mine. I tried using the add_popup function. Also half your code doesn't make any sense to me
action (SetScreenVariable("popup", popups.pop(len(popups) - 1)) if popups and not popup else NullAction())
What are you doing on that line ? you're writing "popup" with something that is not a value but a list function ? and that if block after on the same line doesn't have an action at the condition true but on the else it has ?
action (SetScreenVariable("popup", popups.pop(len(popups) - 1)) if popups and not popup else NullAction())
What are you doing on that line ? you're writing "popup" with something that is not a value but a list function ? and that if block after on the same line doesn't have an action at the condition true but on the else it has ?
Last edited by Misamor98 on Sat Jul 16, 2022 5:53 am, edited 1 time in total.
-
- Veteran
- Posts: 293
- Joined: Fri Sep 17, 2021 2:09 am
- Organization: enaielei
- Tumblr: enaielei
- Deviantart: enaielei
- Github: enaielei
- Skype: enaielei
- Soundcloud: enaielei
- itch: enaielei
- Discord: enaielei#7487
- Contact:
Re: Pop-Up FIFO Pile
I tested this code before I posted it in here. It worked alright for me.
What's your code now?
You can copy and paste the whole code in a blank project to see it for yourself.
What's your code now?
You can copy and paste the whole code in a blank project to see it for yourself.
Last edited by enaielei on Sat Jul 16, 2022 5:57 am, edited 1 time in total.
-
- Veteran
- Posts: 293
- Joined: Fri Sep 17, 2021 2:09 am
- Organization: enaielei
- Tumblr: enaielei
- Deviantart: enaielei
- Github: enaielei
- Skype: enaielei
- Soundcloud: enaielei
- itch: enaielei
- Discord: enaielei#7487
- Contact:
Re: Pop-Up FIFO Pile
That line specifically caters the removal of a popup from the queue.
As long as there are popups in the queue and no new popup is being shown it will remove a popup from the queue and display it as the current popup.
Re: Pop-Up FIFO Pile
To answer your question, my code looks like it first did with the integration of those lines at the beginning:
init python:
config.overlay_screens.append("PopUpManagerScreen")
I'm currently trying to intergrate some of your logic to my own code to make it work, like where you placed your timer, because my last attempts failed.
init python:
config.overlay_screens.append("PopUpManagerScreen")
I'm currently trying to intergrate some of your logic to my own code to make it work, like where you placed your timer, because my last attempts failed.
-
- Veteran
- Posts: 293
- Joined: Fri Sep 17, 2021 2:09 am
- Organization: enaielei
- Tumblr: enaielei
- Deviantart: enaielei
- Github: enaielei
- Skype: enaielei
- Soundcloud: enaielei
- itch: enaielei
- Discord: enaielei#7487
- Contact:
Re: Pop-Up FIFO Pile
I can't help you with those few lines of codes that you're sharing.
Especially that you only integrated it partially with your main code.
I suggest trying the whole code first in a blank project. Then try to piece out what's happening from there so that you can plan on what parts only do you need to integrate in your main code.
Especially that you only integrated it partially with your main code.
I suggest trying the whole code first in a blank project. Then try to piece out what's happening from there so that you can plan on what parts only do you need to integrate in your main code.
Re: Pop-Up FIFO Pile
It works now !
Thank you for your help.
Code: Select all
class PopUpAnnoucement(object):
def __init__(self, Message, PopUpType):
self.Message = Message
self.PopUpType = PopUpType
class FunctionsLibrary(object):
def __init__(self, Blank):
self.Blank = Blank
def PopUp(self, Message, PopUpType):
PopUpPile.insert(0, PopUpAnnoucement(Message, PopUpType))
default MAIN_FunctionsClass = FunctionsLibrary()
init python:
config.overlay_screens.append("PopUpManagerScreen")
transform PopUpFade():
xpos 1920
alpha 1.0
linear 1.0 xpos 1490
pause 3.0
linear 2.0 alpha 0.0
screen PopUpManagerScreen():
layer "notifications"
default popup = None
timer 0.1:
repeat True
action (SetScreenVariable("popup", PopUpPile.pop(len(PopUpPile) - 1)) if PopUpPile and not popup else NullAction())
if popup:
timer 6 action SetScreenVariable("popup", None)
fixed at PopUpFade ypos 425:
if popup.PopUpType == False:
add "gui/PopUps/QuestUpdatedPopUp.png"
else:
add "gui/PopUps/NewAchievementPopUp.png"
text popup.Message xpos 145 ypos 80 size 25 italic True
Who is online
Users browsing this forum: Bing [Bot]