So, I'm not sure if this is possible, but I'm in a situation where I need to do such or something similar. I'm designing a multi-level game, where the game goes on to level 2 once the player comes into contact with the door at the end of level 1. Now...without going into a lot of detail about my code (There's just a lot of it, waaaay too much to post here), I want to modify a string called "currentLevelImage" in a module called "common" from another module called "player"
The string "currentLevelImage" basically represents the filename of the level image i want to load. What i essentially want to do is:
for door in objects.doors: if player collidesWith(door): s= common.currentLevelImage[:1] common.currentLevelImage= str(int(s)+1)+ '.png' #DOES NOT WORK AS INTENDED level.levelSpawner.changeImage(common.currentLevelImage)
Dont worry about the actual code, its is written in pseudo-code mostly (to shorten it up), but line 4 is what needs to be fixed. Again, there is a string in the module "common" that I want to modify. My basic code is all correct (indentation, importing all correct modules), I just didn't wanna post it all here. Is this actually not possible? If so, how could I do it a different way? Thanks to anyone who can help!