RetroAchievements / rcheevos

Library to parse and evaluate achievements and leaderboards for RetroAchievements
MIT License
86 stars 33 forks source link

Add Modulus Operator #335

Closed redwizard42 closed 4 months ago

redwizard42 commented 4 months ago

Adds the modulus operator to allow scaling to the remainder of a division. Most useful for anytime you have an increasing index that in practice has looping behavior without its value actually looping.

Example: A Game with 5 stages that loop, but the 0-based stage identified only ever increases, with no loop counter is present in RAM. With modulus operator, the developer could check that you are on 'any third stage' in the sequence using "Add Source Stage % 5 = Value 2"

Currently only modulo using a power of two can be accomplished (with Bitwise And)

redwizard42 commented 4 months ago

I corrected the extra comma in the operator enum. Habit from C# development where I do it all the time.