Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hello! Can you please explain this part  in a bit more detail. I am trying to make an achievement that is granted once player tries all 4 options of something.


# $ persistent.seen_endings.add("end1")

# $ ending_achievement.progress(len(persistent.seen_endings))

## This will prevent the achievement from being added to multiple times if the

## player sees the same ending multiple times.


I tried to do my own version and keep getting the error 

```

AttributeError: 'int' object has no attribute 'add'

or 

AttributeError: 'NoneType' object has no attribute 'add'


Do we need to define the class somewhere? I'm also severely sleep deprived so may be making simple mistake. Overall love this code a lot though!

You need to create a persistent set, e.g.

default persistent.seen_endings = set()

and then you will add to that set when you reach a relevant part in the game (that's this part:)

$ persistent.seen_endings.add("end1")

and in order to record that progress for an achievement, you can set the progress to the length of the list e.g.

$ ending_achievement.progress(len(persistent.seen_endings))

Sets are used because they can't have duplicates, so the length of the list will be the number of unique endings the player has seen, and it won't matter if they go through the same ending multiple times/it won't count them more than once towards the achievement.

Thank you for the speedy response! I really appreciate the breakdown.

I discovered that the issue was actually with the name I was giving my variable...I'm still not sure why it was happening but I suspect it was too similar to the name of something else in my project. Once I followed your code with a different name it worked!

Thanks again for your contributions as I'm really excited to have this feature and I will be crediting you in the final release!