View Single Post
  #15  
Old 12-16-2011, 09:57 PM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
Quote:
Originally Posted by callimuc View Post
You could also short the script by doing something like this

PHP Code:
function onKeyPressed(codekey) {
  if (
key == "b") {
    if (
this.boots == false) {
      
this.boots true;
      
player.chat "Boots on!";
    }
    else if (
this.boots == true) {
      
this.boots false;
      
player.chat "Boots off!";
    }
  }

OR

PHP Code:
function onKeyPressed(codekey) {
  if (
key == "b") {
    
this.boots = !this.boots//change boolean
    
player.chat "Boots "@ (this.boots"on!" "off!"); //boots are on or off
  
}

Well with the
PHP Code:
this.boots = !this.boots
is something like gunderak said. It changes the boolean (true to false or false to true). Gunderaks post might also help.

And
PHP Code:
(this.boots "on!" "off!"); 
is also very nice (in my opinion). Itīs like also checking the boolean. This example might help
PHP Code:
player.chat this.booleancheck "The boolean is true!" "The boolean is false!";

//or

this.booleancheck BooleanTrue() : BooleanFalse();
  
//if the statement is true, start the function "BooleanTrue()" else if the
  //statement is false, start the function "BooleanFalse()"

function BooleanTrue() {
  
player.chat "The boolean is true!";
}

function 
BooleanFalse() {
  
player.chat "The boolean is false!";


If there are any questions or suggestions about this just ask
Thanks. that helps a lot . I may have over thought the ! operator. But i think i understand it now.


and wow, i never knew what the ?, : meant. but now i believe i do. so to be sure i do. the ? is like saying if(whatever) and the : is like saying 'else'?



thanks everyone for the help. greatly appreciated.
Reply With Quote