Affection Points

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
plaul2002
Newbie
Posts: 11
Joined: Fri Aug 31, 2018 4:52 pm
Contact:

Re: Affection Points

#16 Post by plaul2002 » Fri Aug 31, 2018 6:03 pm

As a newbie this is fantastic help! Your explanations are amazing and your code is understandable! HERO!

M-77
Regular
Posts: 51
Joined: Tue Sep 04, 2018 7:58 am
Contact:

Re: Affection Points

#17 Post by M-77 » Tue Oct 23, 2018 1:34 pm

Hello, I put my Affection Points (and money) this way (see code at bottom), and want make more icons this way but with inter action.
And now, can anyone tell me (show your code) with what simple command (overscreen?) I can made to get the icons stay on screen during idle maps room. Not dissapearing?
Only hide if mousewheel clicked.
I also need some of them on or off (this is easy with the show screen... True/False command, already get this) in some events.
But how to made them react if clicked with the mouse? To open a inventory (not done yet) when clicked on the backpack icon, for example?
Open some quest list when the communicator is clicked. Jump back from one room to stage corridor.Or back from a niche/bath to a room if the "back" icon is clicked.
What is the simple right command with which parameters for that? (Some "action"+ "clicked" + "jump" I think).
I also want to set position in pixles not the strange Renpy Xpos, Ypos, anchor, etc. metrics because I have to place my icons accurate by pixel and knowing where.
Or have I to do every room as idle map now? But then no chance to made icons hide as they are pasted in on the bg graphics.

In script.rpy:

# Elie LP meter icon and display
init -2 python:
showlove= False
Elie_love = 100
max_love= 150
# def display_love():
# if showlove:
#This next line is optional. It adds a heart image under the text.
#Not use because shows up on left ui.image("HUD_LP_idle.png")
#Not use ui.text(" %d" %Elie_love, color="#ff0000")
#Not use config.overlay_functions.append(display_love)
# Money Meter (Gulden) icon and display
init python:
showgulden= False
Gulden = 100
max_gulden= 9999
# def display_gulden():
#Not use because shows up on left if showgulden:
#Not use ui.frame() #This is optional. It adds a frame around the text.
#Not use ui.text("Gulden: %d" %Gulden)
#Not use config.overlay_functions.append(display_gulden)
#Communicator
init python:
showcom= False
Communicator = 0
max_com= 1
#Inventory icon
init python:
showcom= False
Inventory = 0
max_inv= 1
#Map icon
init python:
showmap= False
Map = 0
max_map= 1
#Back icon
init python:
showback= False
Back = 0
max_back= 1

In screns.rpy:

#Money+Love Points screen display a coin and heart icon on top right screen with the amount in possession for each one on them
#Money Points screen
screen money():
frame:
xpos 0.91
ypos 0.06
textbutton "{b}Day [Day]{/b}" action If(renpy.get_screen("money_box1"), Hide("money_box1"), Show
("money_box1"))

screen money_box1():
vbox xpos 0.951 ypos 0.056:
image "Gulden.png"
text "{b} [Gulden]{/b}" color "#000000" yoffset -61 xalign 0.40

#Love Points screen
screen elie_love():
frame:
xpos 0.91
ypos 0.06
textbutton "{b}Day [Day]{/b}" action If(renpy.get_screen("elie_love_box1"), Hide("elie_love_box1"), Show
("elie_love_box1"))
screen elie_love_box1():
vbox xpos 0.951 ypos 0.140:
image "HUD_LP_idle.png"
text "{b}[Elie_love]{/b}" color "#cd2626" yoffset -65.5 xalign 0.49
#Communicator Icon screen display a sort of mobilephone icon on upper right screen
screen communicator():
frame:
xpos 0.91
ypos 0.06
textbutton "{b}Day [Day]{/b}" action If(renpy.get_screen("com_box1"), Hide("com_box1"), Show
("com_box1"))
screen com_box1():
vbox xpos 0.933 ypos 0.306:
image "HUDCOM_idle001.png"
#Inventory Icon screen display a backpack icon on upper right screen, has still to be linked to an inventory script
screen inventory():
frame:
xpos 0.91
ypos 0.06
textbutton "{b}Day [Day]{/b}" action If(renpy.get_screen("inv_box1"), Hide("inv_box1"), Show
("inv_box1"))
screen inv_box1():
vbox xpos 0.933 ypos 0.417:
image "HUDINV_idle001.png"
#Map Icon screen, optional as Map icon appears on idle maps too, used to go back to stage overmap
screen map():
frame:
xpos 0.91
ypos 0.06
textbutton "{b}Day [Day]{/b}" action If(renpy.get_screen("map_box1"), Hide("map_box1"), Show
("map_box1"))
screen map_box1():
vbox xpos 0.933 ypos 0.529:
image "HUDMAP_idle001.png"
#Back screen, icon appears on idle maps too, to go one room back to stage map, not overmap. Or to exit from idle maps in rooms
screen back_box1():
frame:
xpos 0.933
ypos 0.06
textbutton "{b}Day [Day]{/b}" action If(renpy.get_screen("back_box1"), Hide("back_box1"), Show
("map_box1"))
screen back_box1():
vbox xpos 0.940 ypos 0.652:
image "HUD_back001_idle.png"

M-77
Regular
Posts: 51
Joined: Tue Sep 04, 2018 7:58 am
Contact:

Re: Affection Points

#18 Post by M-77 » Tue Oct 30, 2018 4:01 pm

With help from the "f95zone" I was able to get the desired show up of the hud icons adding a "zorder -1" command under the "imagemap:" in my "script" file:

Code: Select all

label go_home:
show AShipStage2A0041_idle with dissolve
show Elie_stand_ssuit001 at left with dissolve
e "I chose to go to my room to take a look around."
e "Anyway..."
hide Elie_stand_ssuit001
hide AShipStage2A0041_idle
show screen money_box1
show screen elie_love_box1
show screen com_box1
show screen inv_box1
show screen map_box1
show screen back_box1
screen your_room1():
    zorder -1
    imagemap:
        xpos 0
        ypos 0
        idle "images/AShipStage2A0041_idle.png"
        hover "images/AShipStage2A0041_hover.png"
        hotspot (1797, 575, 127, 124) action Jump ("HUD000aidle")
        hotspot (1804, 702, 106, 40) action Jump ("Stage_2")
        hotspot (505, 435, 125, 70) action Jump ("Vitrine001_Elie") alt "vitrine001_elie"
And how to made the "back_box1" icon hover? No action here because it works through a imagemap in the script. What variable I have to add to the "action" command here to made the icon hover like the "map_box1" icon do?. This here is from the "screens.rpy":

Code: Select all

#Map Icon screen, optional as Map icon appears on idle maps too, used to go back to stage overmap
screen map_box1():
    imagebutton:
        idle "HUDMAP_idle001.png" 
        hover "HUDMAP_hover001.png"
        xpos 0.933 ypos 0.529 
        focus_mask True 
        action Jump("HUD000aidle") 
#Back screen, icon appears on idle maps too, to go one room back to stage map, not overmap. Or to exit from idle maps in rooms
screen back_box1():
    imagebutton:
        idle "HUD_back001_idle.png"
        hover "HUD_back001_hover.png"
        xpos 0.933 ypos 0.650
        action None

AcerbicDream
Newbie
Posts: 1
Joined: Wed Jun 19, 2019 2:50 am
Projects: The Wild Things
Deviantart: AcerbicDream
itch: AcerbicDream
Contact:

Re: Affection Points

#19 Post by AcerbicDream » Wed Jun 19, 2019 2:55 am

Is there a way to max the affection points? So if I keep on adding affection and want to max it at 30 or 100 is there a way to do so?
"Stressed, Depressed, and trying to stay dressed."

M-77
Regular
Posts: 51
Joined: Tue Sep 04, 2018 7:58 am
Contact:

Re: Affection Points

#20 Post by M-77 » Thu Jun 20, 2019 2:40 pm

Yes, before your "label start:" type this:

Code: Select all

init -2 python:
Player_affection = 0
max_affection= 100
This start with 0 points. And set max points to 100. You can change both values how you like.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1433
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: Affection Points

#21 Post by xavimat » Fri Jun 21, 2019 4:50 am

M-77 wrote:
Thu Jun 20, 2019 2:40 pm
Yes, before your "label start:" type this:

Code: Select all

init -2 python:
Player_affection = 0
max_affection= 100
This start with 0 points. And set max points to 100. You can change both values how you like.
Sorry to correct you. Better use "default" to avoid problems with saves:

Code: Select all

default Player_affection = 0
default max_affection= 100
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
xavimat
Eileen-Class Veteran
Posts: 1433
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: Affection Points

#22 Post by xavimat » Fri Jun 21, 2019 4:52 am

AcerbicDream wrote:
Wed Jun 19, 2019 2:55 am
Is there a way to max the affection points? So if I keep on adding affection and want to max it at 30 or 100 is there a way to do so?
You can use the min() function.
If you add points this way: $ points += 1 there is no max limit.
If you add points this way: $ points = min(100, points + 1) it will stop increasing at 100.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
richycapy
Regular
Posts: 35
Joined: Mon May 27, 2019 8:53 pm
Organization: EN Productions
Location: Mexico
Contact:

Re: Affection Points

#23 Post by richycapy » Fri Oct 25, 2019 2:19 am

Hi! is there a way to do this, but the other way around? decreasing? and don't go under 0?
xavimat wrote:
Fri Jun 21, 2019 4:52 am
You can use the min() function.
If you add points this way: $ points += 1 there is no max limit.
If you add points this way: $ points = min(100, points + 1) it will stop increasing at 100.
EDIT: I found how, here is how:

If you add points this way: $ points -= 1 there is no min limit.
If you add points this way: $ points = max(points - 1, 0) it will stop decreasing at 0.

Post Reply

Who is online

Users browsing this forum: No registered users