Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #12  
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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:02 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.