I want to know how to perform an action pressing a button, but when i press it again i want to do the opposite action. For example, if i pressed x button, i want to equip a gun, but if i press it again, i want to quit it.
Can you help me with that? really i need it. Thanks!
Offline
when gf clicked set [gun equipped] to [0] switch to costume [no gun] forever wait until x key pressed switch to costume [gun] set [gun equipped] to [1] wait until < not x key pressed > wait until x key pressed switch to costume [no gun] set [gun equipped] to [0] wait until < not x key pressed > endI think this should work.
Last edited by pi3 (2012-04-09 17:32:56)
Offline
Or this:
When [space v] key pressed change [i v] by (1) if<((i) mod (2))=[0]> show gun else hide gun endOr this:
When gf clicked forever if<key [space v] pressed ?> change [i v] by (1) if<((i) mod (2))=[0]> show gun else hide gun end end
Last edited by MoreGamesNow (2012-04-09 17:40:23)
Offline
More than thanks, but, i dont know how to aim that gun while having it, hehe. i want to shoot, reload when i have the gun. What i mean, is that i dont know how to make other actions with these scripts when i have the gun. When i quit it, those actions cannot be performed.
Thanks again!
Offline
Just only preform the actions when ( (i) mod [2]) = 0, like the code below. Happy scripting
when gf clicked forever if <((i) mod [2]) = [0]> point towards [mouse pointer v] if<mouse down?> broadcast [shoot v] end end
Last edited by MoreGamesNow (2012-04-09 18:25:38)
Offline
MoreGamesNow wrote:
Just only preform the actions when ((i) mod [2]) = 0
when gf clicked forever if <((i) mod [2]) = [0]> point towards [mouse pointer v] if<mouse down?> broadcast [shoot v] end end
Blocks fixed by Coolhogs
Last edited by coolhogs (2012-04-09 18:26:58)
Offline
yandro wrote:
More than thanks, but, i dont know how to aim that gun while having it, hehe. i want to shoot, reload when i have the gun. What i mean, is that i dont know how to make other actions with these scripts when i have the gun. When i quit it, those actions cannot be performed.
Thanks again!
If I have you right, you could try my biiiig codes I am a fan of big codes
(Under the 'else' codes, move all of the 'if's' out of the other if's and keep them separate. Eg at the moment it goes
if this....
if this......
if this......
when it should be:
if this
OR
if this
OR
if this)
Hope it helps a bit.
when gf clicked set [armed] to [0] forever switch to costume [armed] if <(armed) = [0]> if [x] key pressed set [armed] to [1] wait until <not [x] key pressed> else point towards [mouse pointer] if <[x] key pressed> set [armed] to 0 wait until <not [x] key pressed> if <[mouse down] and <[ammo] > 0> broadcast fire change [ammo] by [-1] wait until <not mouse down> if <[r] key pressed> set [ammo] to [10]
Offline
I ve manneged to equip and quit the gun. But i cant aim the gun cause of the other script. How can i make those variables to change the images having the gun to aiming? Im not doing an FPS, im not using a mouse. Im using images.
Offline
when gf clicked forever if <((i) mod [2]) = [0]> show // gun is pointing towards point towards [mouse pointer v] if<mouse down?> broadcast [shoot v] end else hide // gun is away end end When [space v] key pressed change [i v] by [1]That should take care of everything (I hope).
Last edited by MoreGamesNow (2012-04-09 20:55:45)
Offline