At 4/19/08 05:52 PM, RiotFlash wrote:
health<100 means health is less than 100.
health>100 means health is greater than 100
health==100 means health equals 100
health<=100 means health is less than or equal to 100
health>=100 means health is greater than or equal to 100
!health==100 means health is not 100.
I agree you did go a little of topic here, and it wasn't a well covered tutorial on the whole.
!health==100 can also be written as health!=100. ! means not. You also failed to cover && and ||, which you may as well do if you start talking about useful things.
&& means and. This is used to create an if statement that will only function if all the statements are true, for example:
if(health==100 && speed<10){
speed ++;
}
This will increase the speed by one if health is full and speed is less than 10. These can be used as many times as you like to make extremely long functions.
|| means or. This is used to create an if statement that will function if either of the statements are true, for example:
if(health==100 || speed>10){
speed = 10;
}
This will set the speed to 10 if health is full or if speed is above 10. It will also execute if more than one of these are true.
That should cover && and || well enough...