Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 12-16-2011, 10:25 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by khortez View Post
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.
__________________
Reply With Quote
  #17  
Old 12-16-2011, 10:59 PM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
Ahh, gonna take me some time to master that. thanks again
Reply With Quote
  #18  
Old 12-17-2011, 12:59 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
Oh, and whats the syntax for ?
Reply With Quote
  #19  
Old 12-18-2011, 12:11 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by khortez View Post
Oh, and whats the syntax for ?
PHP Code:
statement b
If statement is true, do a else do b;
__________________
Reply With Quote
  #20  
Old 12-18-2011, 12:22 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by khortez View Post
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;

__________________
Reply With Quote
  #21  
Old 12-18-2011, 12:53 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
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?
Reply With Quote
  #22  
Old 12-18-2011, 01:10 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by khortez View Post
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.
__________________
Reply With Quote
  #23  
Old 12-18-2011, 03:41 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
Right the basics. well thanks again.
Reply With Quote
Reply


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 02:50 AM.


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