- Aug 13, 2020
- 11
- 2
I know there have been a couple of threads based on my question but none of them seem to have helped, I ran out of options and I'm not good at programming. What I want to do is basically to change the value of the variables based on hour. The issue that I have is that when I check the variables they have their initial value no matter the time, I made sure to call update_location_names() in all the places that were needed. Could it be that once the sub_place_data has take its values they don't change even if the variables do?
Python:
init python:
class SubPlace(object):
def __init__(self, ID, parent, name, x, y, iconPhoto, IsActive):
self.ID = ID
self.parent = parent
self.name = name
self.IsActive = IsActive
self.x = x
self.y = y
self.iconPhoto = iconPhoto
SubLocations = []
Places = []
t = 0
while t < 500:
SubLocations.append(SubPlace(t, -1, "",0, 0,"", False))
Places.append(Place(t, 0, 0, "", False))
t += 1
Places[0] = Place(0, 1000, 700, "Entrance", True)
#Places[1] = Place(1, 200, 700, "mall", True)
#Places[2] = Place(2, 1200, 300, "lobby", True)
#Places[3] = Place(3, 1700, 900, "office", True)
sub_place_data = []
SubLocations = [SubPlace(t, -1, "",0, 0,"", False) for t in range(500)]
MyRoom = "My room"
MomRoom = "Mom room"
LilSisRoom = "lil sis room"
Toilet = "toilet"
LivingRoom = "livingroom"
Kitchen = "kitchen"
WashingRoom = "Washing Room"
Bathroom = "Bathroom"
Entrance = "Entrance"
Housefront = "Housefront"
Class1 = "Class1"
Principal = "Principal"
MedicRoom = "MedicRoom"
LockerRoom = "LockerRoom"
SchoolToilets = "toilets"
Office = "Office"
def update_location_names():
global MyRoom, MomRoom, LilSisRoom, Toilet, Livingroom, WashingRoom, Bathroom, Entrance, Housefront, Class1, Principal, MedicRoom, LockerRoom, SchoolToilets, Office
MyRoom = "My room" if -1 <= calendar.Hours < 12 else "My room evening" if 12 <= calendar.Hours < 18 else "My room night"
MomRoom = "Mom room" if -1 <= calendar.Hours < 12 else "Mom room evening" if 12 <= calendar.Hours < 18 else "Mom room night"
LilSisRoom = "Lil sis room" if -1 <= calendar.Hours < 12 else "Lil sis room evening" if 12 <= calendar.Hours < 18 else "Lil sis room night"
Toilet = "Toilet" if -1 <= calendar.Hours < 12 else "Toilet evening" if 12 <= calendar.Hours < 18 else "Toilet night"
Livingroom = "Livingroom" if -1 <= calendar.Hours < 12 else "Livingroom evening" if 12 <= calendar.Hours < 18 else "Livingroom night"
WashingRoom = "Washing Room" if -1 <= calendar.Hours < 12 else "Washing Room evening" if 12 <= calendar.Hours < 18 else "Washing Room night"
Bathroom = "Bathroom" if -1 <= calendar.Hours < 12 else "Bathroom evening" if 12 <= calendar.Hours < 18 else "Bathroom night"
Entrance = "Entrance" if -1 <= calendar.Hours < 12 else "Entrance evening" if 12 <= calendar.Hours < 18 else "Entrance night"
Housefront = "Housefront" if -1 <= calendar.Hours < 12 else "Housefront evening" if 12 <= calendar.Hours < 18 else "Housefront night"
Class1 = "Class1" if -1 <= calendar.Hours < 12 else "Class1 evening" if 12 <= calendar.Hours < 18 else "Class1 night"
Principal = "Principal" if -1 <= calendar.Hours < 12 else "Principal evening" if 12 <= calendar.Hours < 18 else "Principal night"
MedicRoom = "MedicRoom" if -1 <= calendar.Hours < 12 else "MedicRoom evening" if 12 <= calendar.Hours < 18 else "MedicRoom night"
LockerRoom = "LockerRoom" if -1 <= calendar.Hours < 12 else "LockerRoom evening" if 12 <= calendar.Hours < 18 else "LockerRoom night"
SchoolToilets = "SchoolToilets" if -1 <= calendar.Hours < 12 else "SchoolToilets evening" if 12 <= calendar.Hours < 18 else "SchoolToilets night"
Office = "Office" if -1 <= calendar.Hours < 12 else "Office evening" if 12 <= calendar.Hours < 18 else "Office night"
sub_place_data = [
(0, 0, MyRoom, 50, 900, "SubLocationIcons/MCBedroomIcon_%s.png", True),
(1, 0, MomRoom, 230, 900, "SubLocationIcons/MOMBedroomIcon_%s.png", True),
(2, 0, LilSisRoom, 410, 900, "SubLocationIcons/LittleSisterBedroom_%s.png", True),
(3, 0, Toilet, 590, 900, "SubLocationIcons/ToiletIcon_%s.png", True),
(4, 0, "Livingroom", 770, 900, "SubLocationIcons/livingroomIcon_%s.png", True),
(5, 0, WashingRoom, 950, 900, "SubLocationIcons/WashingRoomIcon_%s.png", True),
(6, 0, Bathroom, 1130, 900, "SubLocationIcons/Bathroom_%s.png", True),
(7, 0, Entrance, 1310, 900, "SubLocationIcons/Entrance_%s.png", True),
(8, 0, Housefront, 1490, 900, "SubLocationIcons/HousefrontIcon_%s.png", True),
(9, 3, Class1, 50, 900, "SubLocationIcons/MOMBedroomIcon_%s.png", True),
(10, 3, Principal, 230, 900, "SubLocationIcons/MOMBedroomIcon_%s.png", True),
(11, 3, MedicRoom, 410, 900, "SubLocationIcons/MOMBedroomIcon_%s.png", True),
(12, 3, LockerRoom, 590, 900, "SubLocationIcons/MOMBedroomIcon_%s.png", True),
(13, 3, SchoolToilets, 770, 900, "SubLocationIcons/MOMBedroomIcon_%s.png", True),
(14, 3, Office, 950, 900, "SubLocationIcons/MOMBedroomIcon_%s.png", True)
]
update_location_names()
for i, data in enumerate(sub_place_data):
SubLocations[i] = SubPlace(*data)