Cycling weapons but only showing ones with ammo
Roksalt
Member Posts: 87
Ok so a quick bit of background....
Basically I have a "choose weapon" button that when tapped changes the players weapon using the following expression:
( game.weapon-selected +1)%X
That works really well, however here is the issue... I only want weapons that have ammo > 0 to appear. (If the weapon doesn't have any ammo I don't want it to be selectable).
So I thought a quick hack around this would be to simply have a rule that says:
IF game.weapon1-ammo > 0
{ do something}
Otherwise
{change attribute ( game.weapon-selected +1)%X}
That way I check to see if the weapon has ammo and if not I just jump to the next one...now again this actually works well however the issue comes when I fire the last bit of ammo from weapon 1 it also fires the first shot of weapon 2 at the same time...
so my question is:
a) can anyone suggest a cleaner (better) method for this problem of cycling through weapons but only showing those that have ammo?
b) if not, then using my current method what can i do to stop firing the next weapon straight away when I run out of ammo of my previous gun?
Thanks in advance :-)
Basically I have a "choose weapon" button that when tapped changes the players weapon using the following expression:
( game.weapon-selected +1)%X
That works really well, however here is the issue... I only want weapons that have ammo > 0 to appear. (If the weapon doesn't have any ammo I don't want it to be selectable).
So I thought a quick hack around this would be to simply have a rule that says:
IF game.weapon1-ammo > 0
{ do something}
Otherwise
{change attribute ( game.weapon-selected +1)%X}
That way I check to see if the weapon has ammo and if not I just jump to the next one...now again this actually works well however the issue comes when I fire the last bit of ammo from weapon 1 it also fires the first shot of weapon 2 at the same time...
so my question is:
a) can anyone suggest a cleaner (better) method for this problem of cycling through weapons but only showing those that have ammo?
b) if not, then using my current method what can i do to stop firing the next weapon straight away when I run out of ammo of my previous gun?
Thanks in advance :-)
Comments
Click on the white square to change weapons. The white square displays WeaponNumber: Ammo. Click on the red square to fire the current weapon.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks for the demo. I like the use of tables...
However there is still the same issue when changing from one weapon to the next in which the next weapon instantly when I run out of ammo of my previous weapon.
How would I fix this?
Cheers
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User