Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If All Candles Inactive, Fade To Black Script?
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#15
RE: If All Candles Inactive, Fade To Black Script?

In languages like AngelScript, C/C++, Java, C#, etc, there's only the == comparison operator.
They make an important distinction between the assignment operator (=), and the comparison operator (==). Assignment is used to assign values to variables, like in:
PHP Code: (Select All)
int remainingPuzzlePieces 5

In almost every case, it is an error to use the = operator in an if-statement. For example, if you wrote:
PHP Code: (Select All)
if (remainingPuzzlePieces 3)
{
    
// do something ...


it would NOT check if the value is 3, but it would assign the value of 3 to the variable, instead, the whole assignment expression would evaluate to true or false, in a language-specific way. For example in C++, the whole remainingPuzzlePieces = 3 thing would evaluate to the number 3, as if you've written if(3); and in C++ any non-zero value is treated as true - so it transforms to if(true), which means that it will always execute.
I'm not sure how AngelScript treats this case, but you could write a simple function to check.

Now, those were all so-called statically typed languages. In dynamically typed languages, values can easily "transform" into one another. You can put a string into a variable that held a float, or an int, things like that. This is common in scripting languages, often used with games, but it's not the case with AngelScript.
Both the == and === operators appear in the languages of this other kind, and they have a slightly different meaning.

For example, in PHP, unlike in AngelScript:
5 == "5" evaluates to true ("5" is converted (cast) to 5, and then they are compared)
5 === "5" returns false, since the left one is a number 5, and the right one is a string (text) "5"; but
5 === 5 evaluates to true.

So, === of PHP is more akin to == in AngelScript. It takes type information into consideration.
(This post was last modified: 05-05-2013, 12:32 AM by TheGreatCthulhu.)
05-05-2013, 12:22 AM
Find


Messages In This Thread
RE: If All Candles Inactive, Fade To Black Script? - by TheGreatCthulhu - 05-05-2013, 12:22 AM



Users browsing this thread: 1 Guest(s)