Hello,
For my Computer Science class we have been asked to make a gun and i choose to make an FPS but have run into trouble with an ammo system. The weapon right now has an auto reload set to 0 so when it is at 0 it automatically reloads, but I have to stop there for it to work. So I am asking both a.) how to stop a variable going into negatives and b.) how to set something to react if a variable is between zero and a negative number. I would gracious for any reply
Offline
to make it reload do this
when space key pressed
if ammo=0
set ammo 5
else
change ammo by -1
do whatever you do to fire
wait 0.1 seconds
hope it helped
Last edited by jamiewinter (2012-09-21 17:46:58)
Offline
or you could do
when flag is clicked
forever
if
key space pressed
repeat until ammo=0
{do whatever to fire
{change ammo by -1
set ammo to 5
Offline
To make sure that the gun doesn't shoot with out ammo, and to make sure that it reloads, just add this to the gun's scripts:
if <(ammo) > (0) > Gun's scripts else reload scripts endI hope that this helps!
Offline
i think mine would work anyway but...
dont argue with a pro
Offline
jamiewinter wrote:
i think mine would work anyway but...
dont argue with a pro
Your second script would work, so good job on thinking of it ( ), though it could be improved upon.
Offline