Blockland Forums > Modification Help

| and & vs || and &&?

Pages: << < (4/5) > >>

DontCare4Free:


--- Quote from: Ipquarx on March 12, 2012, 10:25:53 AM ---This is ridiculous. Absolutely ridiculous. NO. ITS NOT. YOU'RE WRONG.
== is to test if something equals something else
 =  is to SET SOMETHING to SOMETHING ELSE.

Oh my gosh.

--- End quote ---

--- Code: ---x = y

--- End code ---
sets x to y and then returns y. The while loop then checks the returned value (y) for truth. That's how simple it is. Another example would be

--- Code: ---%x = %y = %z;

--- End code ---


phflack:


--- Quote from: DontCare4Free on March 12, 2012, 11:23:44 AM ---
--- Code: ---x = y

--- End code ---
sets x to y and then returns y. The while loop then checks the returned value (y) for truth. That's how simple it is. Another example would be

--- Code: ---%x = %y = %z;

--- End code ---

--- End quote ---
so basicaly...

--- Quote from: phflack on March 11, 2012, 01:58:45 PM ---actualy, X = Y returns Y overall
so...
$a = 0;
$b = 1;
$a = $b = 2;
would set everything to 2

in your while loop example, it's returning 1 which is true, and forms the infinite loop

edit: and echo($a = "hi"); echos hi

--- End quote ---


DontCare4Free:


--- Quote from: phflack on March 12, 2012, 11:35:46 AM ---so basicaly...

--- End quote ---
Yeah. Managed to miss your post. Sorry.

Chrono:


--- Quote from: phflack on March 12, 2012, 09:31:52 AM ---true, it does stop console errors, but it doesn't change the functionality, does it?

--- End quote ---
It may in certain circumstances.

for example:

let's say player.addHealth will return the resulting health

if(isObject(player) && player.getDatablock().getName() $= "PlayerTest")

The functionality will not change, as getDatablock is strictly for returning data. In fact, you want it to short circuit because you don't want that .getdatablock returning an error if player doesn't exist.

however

if(player.getDatablock().getName() $= "PlayerTest" && player.addHealth(25) >= 80)
The player will never gain the health if they aren't the PlayerTest datablock.

Kalphiter:

Oh my gosh, even Ipquarx had to correct someone.

Pages: << < (4/5) > >>

Go to full version