Hi all,
I'm trying to make a weapon reload system, where you can reload your pistol if the clip has less than 10 bullets, and the clip can hold 10. However, it becomes problematic when trying to program it to add the remainder of the ammo when it is less than 10.
So say there's 5 in the clip, and 8 in spare. It should subtract 5 from 8 and add 3 to the clip making it a total of 10 again. But there are many different combinations and it feels very inefficient to do it this way:
As you can see it's 'easy' when there are always enough (10 or more) spare ammo. But say there is 3 in the clip left, and 4 in spare, it should add only 4 making it a total of 7.
How do I go about shorten the code and not become 100 lines (as demonstrated in the image I posted)?