doing anything 'per loop' is not a very effective way to code, frame rate drops will result in everything running slower
Instead, think of everything happening according to time elapsed, irrelevant of your frame/loop rate
Sync On : Sync Rate 60
Backdrop On
global WeaponRate as integer
global WeaponTimer as integer
WeaponRate = 250 // fire rate in milliseconds, 250 = 4 shots per second
WeaponTimer=timer()
do
WeaponControl()
sync
loop
function WeaponControl()
if mouseclick()&&1
if Timer()-WeaponTimer=>WeaponRate
// Do stuff to shoot your gun
text screen width()/2,screen height()-50,"BANG!"
WeaponTimer=timer()
endif
endif
endfunction
You can also implement locking/unlocking of states. Something like
Global WeaponLock as boolean
function WeaponControl()
if mouseclick()&&1
if Timer()-WeaponTimer=>WeaponRate and WeaponLock=0
// Do stuff to shoot your gun
text screen width()/2,screen height()-50,"BANG!"
WeaponTimer=timer()
WeaponLock=1
endif
else
if timer()-WeaponTimer=>WeaponRate then WeaponLock=0
endif
endfunction
This will lock/unlock the weapon according to the left mouse button status. However it also abides by the '4 shots per second' rule, so even if you mash the button you can't make it shoot faster than that