Help with reloading clip size and ammo amount

Hello im looking for a way to reload my wepon in a realistic way

idally what im wanting is i press R to reload and say i had 1 bullet in the clip, and 4 bullets in my leftover ammo, it would take the 4 bullets from my ammo and add it to my clip so i would have 5!

or if i had 8 bullets left and 0 in the clip, i could reload and have 0 spare ammo and a full clip

please help this is urgent (university project)

all i have just now is if i run out of ammo i will auto reload by adding 8 bullets to my clip and taking 8 away from my ammo

thanks!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Change Attribute game.maxBullets to 8

    When key R is down
    .....When game.maxBullets<game.clipBullets+game.ammoBullets
    ..........Change Attribute game.clipBullets to game.clipBullets+game.ammoBullets
    ..........Change Attribute game.ammoBullets to game.ammoBullets-(game.maxBullets-game.clipBullets)
    .....Otherwise
    ..........Change Attribute game.clipBullets to game.clipBullets+game.ammoBullets
    ..........Change Attribute game.ammoBullets to 0 [or to game.maxBullets if you are auto-reloading ammo]

    I'm doing this all in my head so forgive me if it doesn't work correctly. I can probably do a demo later if you need it.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.