PDA

View Full Version : Ammo Variable


linx
11-08-2009, 12:56 AM
Ok so i'm trying to make it so if the variable named ammo=0 then the character cannot shoot anymore, but you cannot put in an if else statement "if ammo=0"
so what do i do?

Edit: Nevermind Got it to work :P

Chris101b
11-08-2009, 01:39 AM
Okay, I made a world that shows you how to do this. ALl you need to do is tell the variable that when "x < 0" then do nothing. If else, do "method". Make sure you put it in a "While a key is pressed" like mine instead of a "When a key is typed" (To change it, add a "When a key is typed" action to the events and right click on it. Click on "change to" and then "While a key is typed").

When you do this, add your method to the "Begin" section of that event. This will make it so that if you press the button a bunch of times, the method won't keep happening over and over by itself.

In a program like yours (I imagine a shooting game) it is always best to tell the program to stop doing the method if the counter is LESS THAN 0 instead of EQUAL TO 0. This will be a good fail safe if something goes wrong and the counter skips 0 because of some glitch. If that happens, the person will be able to shoot forever without having to reload since the counter (from that point on) will never be equal to zero again.

linx
11-08-2009, 01:43 AM
thanks for the help :), probably another really basic question but how do i get alice to ask a question? I'm trying to make it so when a player approaches the crate it asks them if they want to look inside.

Chris101b
11-08-2009, 01:58 AM
Click on the box and go to its methods. Drag "Box Say" into the main programing box and type in whatever you want it to say.

linx
11-08-2009, 02:08 AM
Nono, in the world functions it has a function that says...
"ask user for yes or no"
But i cannot drag that into a code box, so what to do?

Chris101b
11-08-2009, 04:07 AM
Lol, sorry.

Okay, to do this, click on the box and make a variable for it (Make sure it is a Boolean). Then drag it into wherever you want to use it. When it asks you to choose yes or no, just press any of them. Now go to list of items and click on "world". Go to its functions and find "Ask user for yes or no" and drag that into the yes or no spot in the boolean variable that you just placed in your world. I will post an example if this is confusing you.

linx
11-08-2009, 08:25 PM
Thanks, that worked perfectly :).

My last question would be how to make a bullet shoot from the tip of the revolver (no matter what direction it's pointed in), and how to shoot multiple bullets.

Chris101b
11-08-2009, 08:40 PM
Make the bullets vehicle to the revolver. Then when you press the fire button, the bullets move out of the gun. In each shooting method, have the bullets vehicle to the entire world, travel a certain distance, vehicle to the gun again, and then move to the gun again. The best way to do this is to put the bullet where you want it to shoot out from and then drop a dummy at the bullet. Then tell the dummy to vehicle to the gun. From now on have the bullets "move to" and "orient to" the dummy so that they can then be re-fired in exactly the same way. If you want an example, just tell me and I will gladly make one.

linx
11-08-2009, 08:50 PM
I'd love an example :) , thanks for all your help Chris

Chris101b
11-09-2009, 01:44 AM
(15 minutes later)
Okay I am making it now. Stupid Alice froze so I am going to have to make it again:(

(10 minutes later)

Ok WOW!!! It froze again! Forget it, I will do it tomorrow lol, kind of getting tired over here. Haha, I will post it here tomorrow.

linx
11-09-2009, 07:06 PM
It's fine, i already had to turn the project in :P

Thanks for all your help, i probably wont be using Alice much as it's just very annoying to work with, but 3.0 Looks like itll be a lot better.