From Test-Scratch-Wiki
清单第 () 项项目 () | |
清單第 (1 v) 項項目\( [list v] \) :: list) | |
类别 | 清单类积木 |
形狀 | 椭圆形积木 |
加入於 | 1.3 |
The Item () of () 积木 is a 清单类积木 and a 椭圆形积木. The block reports the value of the specified entry in a specified 清单.
用法示例
When a certain 项目 in a list must be recalled, this block can be used.
Some common uses for the Item () of () block:
- Reporting an object
詢問 [Which item would you like on our menu today?] 並等待 變數 [cost v] 改變 (清單第 (詢問的答案) 項項目\( [food costs v] \) :: list) 說出 (字串組合 (字串組合 [We'll be making your ] 和 (清單第 (詢問的答案) 項項目\( [food names v] \) :: list)) 和 [ in a minute.])
- Recalling part of a record
詢問 [What highscore would you like to know?] 並等待 說出 (字串組合 (字串組合 (字串組合 [Highscore ] 和 (詢問的答案)) 和 [ is: ]) 和 (清單第 (詢問的答案) 項項目\( [highscores v] \) :: list))
- Comparing different items
如果 <(清單第 (1 v) 項項目\( [collection v] \) :: list) = (清單第 (1 v) 項項目\( [pack v] \) :: list)> 那麼 說出 [I already have this item in my pack.] (3) 秒 end
应用
- Main article: List of Block Workarounds
The text options of this block can be worked around by dropping Reporter blocks into the dropdown-value menu.
Random
(清單第 (random v) 項項目\( [list v] \) :: list)
chooses a random item in the list. Thus, it can be replicated with the following code:
(清單第 (隨機取數 (1) 到 (清單 [list v] 的項目數 :: list)) 項項目\( [list v] \) :: list)
This also gives the ability to use lists as a workaround for the 随机取数 () 到 () block.
Last
"Last" gives the last item of the selected list.
(清單第 (last v) 項項目\( [list v] \) :: list)
Its replica is:
(清單第 (清單 [list v] 的項目數 :: list) 項項目\( [list v] \) :: list) // only if length of list > 0
参见
— the version for 字串s
Zho:变数类积木 | |
Zho:清单类积木 |
()
• 新增项目 () () • 删除第 () 项 () • 添加 () 为第 () 项 • 替换第 () 项于 () 成 () • 清单第 () 项项目 () • 清单 () 的项目数 • 清单 () 包含 () • 清单 () 显示 • 清单 () 隐藏更多积木… |