i need to make a reload script.
i have 6 bullets in the gun when i press a button i need the script to figure out how much bullets i have room for in the gun and subtract it from the extra ammo property and if there is not enough extra ammo add what is left in the ammo to the bullets and empty all of the ammo


this is for the game engine right?

I’m not just going to go and make a script for you, there is a significant amount that must be done in animating the parts [probably using an armature…]

so, you’ll have an open animation [where the bullets that are there come out]
you’ll have a load a single bullet animation [all the script would need to do is play this multiple times]
and you have close animation

so, animations both for ipos and action actuators are played in a constant amount of time, not a constant number of frames

so, you’ll check a timer property to see if that amount of time has passed, and if so and the animation needs to be played again, you play it again

if not, you play the close animation

you are probably expecting to do something really fancy like reload the bullets which have already been shot, while this is possible you’d to keep track of which bullets were actuall shot [if you think about it you could keep just the number] and have an action actuator for EACH OF THE BULLET RELOAD ANIMATIONS, so, that’s 6 actuators and animations [no fun]