From Test-Scratch-Wiki

Revision as of 04:56, 3 April 2018 by Dnowba (talk | contribs) (Created page with "{{:Eng:() and () (block)/translate}}{{Zho/积木 |名 = () 且 () |sb = <>且<> |类别 = 运算类积木 |形狀 = 菱形积木 }...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Translate: - English - Türkçe - 中文 
() 且 ()
<>且<>
类别 运算类积木
形狀 菱形积木

The () and () 积木 is an 运算类积木 and a 菱形积木. The block joins two boolean blocks so they both have to be true to return true. If they are both true, the block returns true; if they are not all true or none true, it returns false.

This block can be stacked inside itself, which can be used to test more conditions.

用法示例

This block is used for checking if two or more conditions are true at the same time. Some cases of this are:

  • Lose health if "I'm touching the fire and I do not have my shield up."
重複無限次 
  如果 <<碰到顏色 [#f48302] ?> 且 <<(造型编号) = [2]> 不成立>> 那麼 
    變數 [lives v] 改變 (-1)
  end
end
  • Say a button is clicked if the mouse is touching it and the mouse is down.
重複無限次 
  說出 <<滑鼠鍵被按下?> 且 <碰到 [滑鼠游標 v] ?>>
end

Workaround

Main article: List of Block Workarounds


This block can be replicated with the following code:

<<<<condition1> 不成立> 或 <<condition2> 不成立>> 不成立>

Another way to replicate this block is:

變數 [and v] 設為 [false]
如果 <condition1> 那麼 
  如果 <condition2> 那麼 
    變數 [and v] 設為 [true]
  end
end

参见