Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Looking for opinons. (https://forums.graalonline.com/forums/showthread.php?t=134265266)

Crow 12-16-2011 10:25 PM

Quote:

Originally Posted by khortez (Post 1678190)
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'?

Pretty much, yes.

khortez 12-16-2011 10:59 PM

Ahh, gonna take me some time to master that. thanks again :)

khortez 12-17-2011 12:59 AM

Oh, and whats the syntax for ?

Chompy 12-18-2011 12:11 AM

Quote:

Originally Posted by khortez (Post 1678232)
Oh, and whats the syntax for ?

PHP Code:

statement b

If statement is true, do a else do b;

salesman 12-18-2011 12:22 AM

Quote:

Originally Posted by khortez (Post 1678232)
Oh, and whats the syntax for ?

?: is a ternary operator (meaning that it is an operator that takes 3 arguments). By itself, the question mark is not a valid operator.

e.g.
PHP Code:

temp.result SOME_CONDITION temp.temp.b

is equivalent to
PHP Code:

if (SOME_CONDITION) {
  
temp.result temp.a;
} else {
  
temp.result temp.b;



khortez 12-18-2011 12:53 AM

PHP Code:

player.chat "Boots" SPC  (this.boots "on!" "off!"); 

in a script like that, i can see where true is defined, but...


PHP Code:

 player.chat "Boots "@ ((this.boots = !this.boots)? "on!" "off!"); 

where exactly was it defined in this?

salesman 12-18-2011 01:10 AM

Quote:

Originally Posted by khortez (Post 1678368)
PHP Code:

player.chat "Boots" SPC  (this.boots "on!" "off!"); 

in a script like that, i can see where true is defined, but...


PHP Code:

 player.chat "Boots "@ ((this.boots = !this.boots)? "on!" "off!"); 

where exactly was it defined in this?

in some languages, the entire assignment operation [e.g. (this.boots = !this.boots)] returns a value: the value of the left hand side of the equation after the assignment takes place.

In other words, the value of
PHP Code:

(this.boots = !this.boots

is equal to the value of this.boots after it is set to !this.boots

edit: I wouldn't worry about all of these little "shortcuts" right now. They make your code less clear, and as someone who is still learning, it is better to be as straight forward as possible.

khortez 12-18-2011 03:41 AM

Right the basics. well thanks again. :D


All times are GMT +2. The time now is 08:24 PM.

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