Properties And Python and Delay, new Question

lets say when i press “R”, The ‘int’ will be 30, and the ‘supply’ will be 120

when the ‘int’ is 4, and i press “R”, how can i only subtract only 26 from ‘supply’

this is a reloading thing so how can i make it affective for all instances:spin:


c = GameLogic.getCurrentController()
o = c.owner
key = c.sensors['key']

if key.positive:
   o['supply'] -= (30 - o['ammo'])
   o['ammo'] = 30
   #do reloading animation or whatever here

Keep in mind you need all of the properties to be exactly as they are in the script (ammo, not Ammo or AMMO), and you need your keyboard sensor to be called “key”

-Sam

If your supply is less than (30 - ammo), it becomes negative, and you still reload a full clip with bullets that you don’t have.

I’ve made a .blend example (attached) that handles that discrepancy. Hope it helps.

Attachments

clip_reload.blend (131 KB)

thank you so much!

how can i make a delay for the reload?