- Sep 9, 2022
- 43
- 25
I have this phyton code that I use to create and enable/disable places at runtime, but I have some issue with the tooltip because when the mouse gets over a button all tooltips gets displayed and have the same text
So the code is this:
here the is the code in Ren'Py that I use to display the map and set the tooltip.
I guess that I have to place it inside the Class but I'm not sure if it would works... and even if it have any sense at all.
Also on script.rpy I have a Variables label where I set at start all the locations and if they are active or not:
Thank you in advice for the help
So the code is this:
Code:
init python:
# MAP PLACES
class Place(object):
def __init__(self, x, y, name, isHome, owned, price, IsActive):
self.x = x
self.y = y
self.name = name
self.isHome = isHome
self.owned = owned
self.price = price
self.IsActive = IsActive
@property
def placeIcon(self):
if self.isHome == True and self.owned == False:
icon = "map/House_Rentable.png"
elif self.isHome == True and self.owned == True:
icon = "map/House_Rented.png"
else:
icon = "map/" + self.name.lower() + "_icon.png"
return(icon)
I guess that I have to place it inside the Class but I'm not sure if it would works... and even if it have any sense at all.
Code:
screen MapScreen():
frame:
xalign 0.0
yalign 0.0
xsize 1920
ysize 1080
background "map/TownMap.png"
$ rentableHouse = "map/house_Rentable.png"
$ rentedHouse = "map/house_Rented.png"
for q in Places:
if q.IsActive:
button:
xpos q.x
ypos q.y
image q.placeIcon
if q.price > 0:
tooltip "{size=-10}{outlinecolor=#0000FF}" + q.name + " ("+ str(q.price) +"/week){/outlinecolor}{/size}"
else:
tooltip "{size=-10}{outlinecolor=#0000FF}" + q.name + "{/outlinecolor}{/size}"
action Call((q.name).replace(" ",""))
$ tooltip = GetTooltip()
if tooltip:
text "[tooltip]"
Code:
$ Places = []
# Icon PosXY LABEL isHouse? isOwned? Price Active
$ Places.append(Place(843,264, "RAE Office", False, False, 0, True))
$ Places.append(Place(80, 750, "Cheapest House", True, False, 50, False))
$ Places.append(Place(1292, 840, "Cheap House", True, False, 250, False))
$ Places.append(Place(872, 789, "Tech House", True, False, 500, False))
Last edited: