Hey guys, so I am looking for a reloading algorithm. Something where...

X = Current Ammo (Maximum of 30)
Y = Ammo left

So when you activate the reload sequence...

if X=24 and Y=60, then X=30 and Y=54

if X=15 and Y=4, then X=19 and Y=0

if X=19 and Y=15, then X=30 and Y=4

I have been trying and trying to get this working and to no avail. All of the solutions I made work, but they require a ton of if/else statements and I know there is a much more simple way of doing this. So, anyone have any ideas?