#Duplicates are getting added to my image path array

3 messages · Page 1 of 1 (latest)

lime nebula
#

I have a virtual camera that my player uses. When the player first opens the game, I call this function to get the images currently stored in their computer that they have "taken" in my game. This is because we have a limit for how many images they can take in game(this is for narrative purpose so will not be changing this). Later on in the game, they can check how many they have again. I reuse this function. In my head, this function should not increase how many images they have taken because if a path to the image is already in my image_paths list, then it shouldn't get added. However, when I print out my paths, I see duplicates. I can't quite figure out what in this code I'm sharing allows a duplicate path to be added, so figured I would ask here. Thanks so much!

remote sequoia
#

so you're checking image_paths for 'photo_path' but adding 'user_photo_folder + "/" + photo_path'. That means the if statement is always false. and the else statement always executes.

    var full_photo_path = "%s/%s" % [user_photo_folder, photo_path]
    if not full_photo_path in image_paths:
        image_paths.append(full_photo_path)
    photo_path = dir.get_next()
edgy marsh
#

Just an idea, but maybe add a condition to only read .png files or whatever the photo formats are, doesnt godot create a .imported file of every asset in the same folder its in with the same name if eveything else works an is just duplicate files maybe is that?