[SOLVED]renpy.notify x2 in diff pos at = time.

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
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

[SOLVED]renpy.notify x2 in diff pos at = time.

#1 Post by johandark »

I have this code:

Code: Select all

default pf = PointFucker()

default pk = PointKeeper()

init python:        
    class PointFucker(object):
        def __init__(self):
            self.dp = 0
            
        def ch_dp(self, num):
            self.dp += num
            renpy.notify(str(num) + " {size=12}DÍDAC POINT!!{/size}")
            
    class PointKeeper(object):
        def __init__(self):
            self.np = 0
            
        def ch_np(self, num):
            self.np += num
            renpy.notify(str(num) + " {size=12}NEUS POINT!!{/size}")
The thing is, that in game there are some moments where points are showed at the same time.

DÍDAC POINTS and NEUS POINTS... but only one shows off.


I wanted to customize the renpy.notify this way:

Code: Select all

transform _notify_transform:
    # These control the position.
    yalign .1

    # These control the actions on show and hide.
    on show:
        alpha 0 xalign 1.1
        linear .5 alpha 1.0 xalign .9
    on hide:
        linear .5 alpha 0.0 xalign 1.1
        
transform _my_notify_transform:
    # These control the position.
    yalign .2

    # These control the actions on show and hide.
    on show:
        alpha 0 xalign 1.1
        linear .5 alpha 1.0 xalign .9
    on hide:
        linear .5 alpha 0.0 xalign 1.1
So there is a new renpy.notify = "renpy.my_notify"

So NEUS POINTS could go this way:

Code: Select all

            renpy.my_notify(str(num) + " {size=12}NEUS POINT!!{/size}")
But obviously it was too easy to work fine...

The only difference between both is "y align" one is ".1" and the other is ".2" So they appear on above the other.

A example text:

Code: Select all

label start:

    pt "Are we in Sparta?"
    
    menu afternoon01_posiblerape:
        
        pt "This is Madness!"
        
        "This is SPARTA!!.":
            
            $ pk.ch_np(1)
            
            $ pf.ch_dp(-3)
            
            jump fallingdown
The thing is to show Neus Points in one place and Didac points in another and if they meet in same moment they can be showed at the same time.

Thanks in advance!
Last edited by johandark on Mon Jul 25, 2016 5:42 am, edited 1 time in total.
Image

User avatar
TaoistFruitbat
Newbie
Posts: 20
Joined: Wed Jun 29, 2016 12:46 am
Projects: Soulshine
Contact:

Re: renpy.notify duplicated in different positions at same t

#2 Post by TaoistFruitbat »

I'm not exactly sure what you were trying for in your code, but here is a quick way to do what you want with the default notify system. Explanation is commented in with the code.

Code: Select all

default fupk = FuckingPointKeeper()

init python:        
    class FuckingPointKeeper(object):

        # Init all points to be 0.
        def __init__(self):
            self.dp = 0 # Didac points
            self.np = 0 # Nues points
            self.pp = 0 # Pointy points
            
        # Changes point values
        # By default this function changes all points by 0.
        # EX: If we put in ch_pts(np= 10) then np will increase by 10
        # and all others will increase by 0.
        def ch_pts(self, dp = 0, np = 0, pp = 0):

            self.notify_string = "" # We add to this string stuff we want to to be displayed

            # If dp changes
            if dp != 0:
                # Increase points
                self.dp += dp
                # Add message to string
                self.notify_string += str(dp) + " {size=12}DÍDAC POINT!!{/size} \n"
            # Otherwise, we add a new line.
            # (This will make each point type display in a fixed position
            # If you don't care about this just delete the else code.
            else: 
                self.notify_string += "\n" 

            # Same code for np
            if np != 0:
                self.np += np
                self.notify_string += str(np) + " {size=12}NEUS POINT!!{/size} \n"
            else: 
                self.notify_string += "\n" 

            # Same code for pp
            if pp != 0:
                self.pp += pp
                self.notify_string += str(pp) + " {size=12}POINTY POINT!!{/size} \n"
            else: 
                self.notify_string += "\n"

            # Display the string
            renpy.notify(self.notify_string)
            

# The game starts here.
label start:

    menu:

        "Points?"

        "dp":
            $ fupk.ch_pts(dp = 100)
            jump start

        "np":
            $ fupk.ch_pts(np = 100)
            jump start

        "pp":
            $ fupk.ch_pts(pp = 100)
            jump start

        "dp and np":
            $ fupk.ch_pts(dp = 100, np = 50)
            jump start

        "dp and pp":
            $ fupk.ch_pts(dp = 100, pp = 200)
            jump start

        "np and pp":
            $ fupk.ch_pts(np = 100, pp = 101)
            jump start

        "ALL THE POINTS":
            $ fupk.ch_pts(dp = 314, np = 15, pp = 69)
            jump start


User avatar
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: renpy.notify duplicated in different positions at same t

#3 Post by johandark »

I don´t understand really well your code...

I guess I´m doing something wrong, but I don´t really know what...

Code: Select all

init python:        
    class PointFucker(object):
        def __init__(self):
            self.dp = 0
            
            self.notify_string = "" # We add to this string stuff we want to to be displayed
            
        def ch_dp(self, num):
            self.dp += num
            
            self.notify_string = "" # We add to this string stuff we want to to be displayed
            
            if num >= 0:
                self.notify_string("{color=#6abd45}{size=30}+" + str(num) +"{/size}{/color} {color=#ffee2e}{size=12}DIDAC{/size}{/color}{image=images/menu/heart_icon.png} \n")
                
            elif num <=-1:
                self.notify_string("{color=#ed2024}{size=30}" + str(num) +"{/size}{/color} {color=#ffee2e}{size=12}DIDAC{/size}{/color}{image=images/menu/heart_icon.png} \n") 
                
            else: 
                self.notify_string += "\n" 


    class PointKeeper(object):
        def __init__(self):
            self.np = 0
            
        def ch_np(self, num):
            self.np += num
            if num >= 0:
                self.notify_string("{color=#6abd45}{size=30}+" + str(num) +"{/size}{/color} {color=#AF6EEB}{size=12}NEUS{/size}{/color}{image=images/menu/heart_icon.png} \n")
                
            elif num <=-1:
                self.notify_string("{color=#ed2024}{size=30}" + str(num) +"{/size}{/color} {color=#AF6EEB}{size=12}NEUS{/size}{/color}{image=images/menu/heart_icon.png} \n")
                
            else: 
                self.notify_string += "\n"
If I use

Code: Select all

            if num >= 0:
                renpy.notify("{color=#6abd45}{size=30}+" + str(num) +"{/size}{/color} {color=#ffee2e}{size=12}DIDAC{/size}{/color}{image=images/menu/heart_icon.png} \n")
It works, but both lines are in same line and then it does not work.

Thanks for your comment!
Image

User avatar
TaoistFruitbat
Newbie
Posts: 20
Joined: Wed Jun 29, 2016 12:46 am
Projects: Soulshine
Contact:

Re: renpy.notify duplicated in different positions at same t

#4 Post by TaoistFruitbat »

I only have time to glance at your code right now, but I believe you are having problems because there can be only one notify at a time.
"Only one notification is displayed at a time. If a second notification is displayed, the first notification is replaced."
- The documentation
What my code is doing is displaying notify only once with only one string. We start with an empty string, then bit by bit append to the string all of the text we will display. Most important of all, we never call notify twice. We call it once with a string like "+100 D-points\n +150 P-points."

(This is an okay solution if you only have a few types of points. If you have many types of points then the code will be hard to maintain, because this solution duplicates a lot of code and you would have to update the rules for each point type one by one.)

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: renpy.notify duplicated in different positions at same t

#5 Post by trooper6 »

What you can do is to create two screens, one for dp and one for np.
Have them be at different locations on the screen.
Put them on a timer so they hide themselves after 2 seconds (or whatever) and then show the screen.
Basically make two different versions of your own notify.
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
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: renpy.notify duplicated in different positions at same t

#6 Post by johandark »

Ok, now I think I understood the problem.

I´m very noob in programming, so excuse me.

So in my example didn´t work because notify can only appear one at a time.

That means the only solution were to use them in a single string... But with that option I´m not sure if I could have 2 self."points" that could have independent numbers and positive or negative numbers.

I´ve tried your code TaoistFruitbat, but when I added new numbers in label start... they weren´t adding up nor substracting.

So trooper, your solution doesn´t look bad... I´ve tried it.

Using this:

Code: Select all

renpy.my_notify(str(num) + " {size=12}NEUS POINT!!{/size}")
But it didn´t work... And for what said TaoistFruit... is not possible have two notifications at the same time.. right?

Sorry for my low knowledge of programming.
Image

User avatar
TaoistFruitbat
Newbie
Posts: 20
Joined: Wed Jun 29, 2016 12:46 am
Projects: Soulshine
Contact:

Re: renpy.notify duplicated in different positions at same t

#7 Post by TaoistFruitbat »

If you make your own versions of the notify screen you can have two at the same time. It's only the default notify that there must be only one of.

How many different types of points are you going to have? If it is a few then my solution or trooper's would work fine. But if you will have many different types of points (say ten or more) then you may want a more powerful notify system. (I need to make such a notify system for my game. I won't start work on it for a while, but if you don't mind waiting a couple of months I'm happy to share the code with you.)

If you post the code you have I'll take a look at it.

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: renpy.notify duplicated in different positions at same t

#8 Post by trooper6 »

I have to go out, but I'll put some code up for you when I get back home.
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
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: renpy.notify duplicated in different positions at same t

#9 Post by nyaatrap »

renpy.show_screen("notify", message="text") is same to renpy.notify, but you can pass arguments.
notify is just a screen defined as following:

Code: Select all

screen notify(message):
    zorder 100

    text message size 26 at _notify_transform

    # This controls how long it takes between when the screen is
    # first shown, and when it begins hiding.
    timer 2 action Hide('notify')
You can overwrite, copy, or duplicate this screen then notify with show screen statement.

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: renpy.notify duplicated in different positions at same t

#10 Post by trooper6 »

Okay, so assuming you have two different types of points only, here is code that allows you to show both points at the same time (you use two different screens). Also, since I'm not convinced you need two different classes, I combined PointKeeper and PointFucker into one class, PointLocker. You just need to specify what sort of point you want to adjust.

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")

default pl = PointLocker()

transform PointAnimation(loc):
    # These control the position.
    xpos loc 
    ypos .015
    alpha 0

    # These control the actions on show and hide.
    on show:
        parallel:
            linear .25 alpha 1.0
        parallel:
            ease .75 ypos 0.05
    on hide:
        parallel:
            linear .5 alpha 0.0
        parallel:
            ease .75 ypos 0.0
            
screen Outer_dpScreen(message):
    use InnerScreen(message, 0.1)
    timer 3.0 action Hide("Outer_dpScreen")
    
screen Outer_npScreen(message):
    use InnerScreen(message, 0.5)
    timer 3.0 action Hide("Outer_npScreen")
    
screen InnerScreen(message, loc):
    text message at PointAnimation(loc)
    
    
screen Points():
    frame:
        xalign 1.0
        yalign 0.0
        vbox:
            text "Points:"
            text "Didac: [pl.dp]"
            text "Neus: [pl.np]"
    

init python:        
    class PointLocker(object):
        def __init__(self):
            self.dp = 0
            self.np = 0
            
        def ch_pts(self, type, num):
            if num >= 0:
                start = "{color=#6abd45}{size=30}+"
            else:
                start = "{color=#ed2024}{size=30}"
            end = "{/size}{/color}{color=#ffee2e}{size=12}%s{/size}{/color}{image=images/menu/heart_icon.png}" % ("DIDAC" if type == 'dp' else "NEUS")
            message = "%s %d %s" % (start, num, end)
            if type == "dp":
                self.dp += num
            else:
                self.np += num
            renpy.show_screen("Outer_{}Screen".format(type), message)

# The game starts here.
label start:
    show screen Points()

    e "Testing the first point change."
    $pl.ch_pts("dp", 5)
    $pl.ch_pts("np", -4)
    e "Testing the second point change."
    $pl.ch_pts("dp", 5)
    $pl.ch_pts("np", -4)  
    e "Test over."
    

    return
One last thing. What are Dídac points and Neus points by the way? Are they two very different sorts of points, like Money Points and Humor Points, or are they the just a bonus or a penalty to one point total...so for example love points is the total, and you get a bonus point or a penalty point to the love points? Because if that is the case, the bonus points are always positive and the penalty points are always negative, then you can simplify your code even further:

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")

default lp = LovePoints()

transform PointAnimation(loc):
    # These control the position.
    xpos loc 
    ypos .015
    alpha 0

    # These control the actions on show and hide.
    on show:
        parallel:
            linear .25 alpha 1.0
        parallel:
            ease .75 ypos 0.05
    on hide:
        parallel:
            linear .5 alpha 0.0
        parallel:
            ease .75 ypos 0.0
            
screen Outer_dpScreen(message):
    use InnerScreen(message, 0.1)
    timer 3.0 action Hide("Outer_dpScreen")
    
screen Outer_npScreen(message):
    use InnerScreen(message, 0.5)
    timer 3.0 action Hide("Outer_npScreen")
    
screen InnerScreen(message, loc):
    text message at PointAnimation(loc)
    
screen LoveScreen():
    frame:
        xalign 1.0
        yalign 0.0
        text "Love Points: [lp.love]"

init python:                   
    class LovePoints(object):
        def __init__(self):
            self.love = 0
            
        def ch_pts(self, add, num):
            if add:
                start = "{color=#6abd45}{size=30}+"
            else:
                start = "{color=#ed2024}{size=30}"
            end = "{/size}{/color}{color=#ffee2e}{size=12}%s{/size}{/color}{image=images/menu/heart_icon.png}" % ("DIDAC" if add else "NEUS")
            message = "%s %d %s" % (start, num, end)
            if add:
                self.love += num
                renpy.show_screen("Outer_dpScreen", message)
            else:
                self.love -= num
                renpy.show_screen("Outer_npScreen", message)
            

# The game starts here.
label start:
    show screen LoveScreen()
    e "Testing the first point change."
    $lp.ch_pts(True, 5)
    $lp.ch_pts(False, 4)
    e "Testing the second point change."
    $lp.ch_pts(True, 5)
    $lp.ch_pts(False, 4)  
    e "Test over."
    

    return
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
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

Re: renpy.notify duplicated in different positions at same t

#11 Post by johandark »

Thanks trooper6! The first code works perfectly!

Now I can start to think better on the design and continue with the game.

So far I made an screenshot to show you how it´s going on so far.

Thanks for your huge help!
Attachments
toilet.jpg
Image

Post Reply

Who is online

Users browsing this forum: peach_light