信息#

介绍#

两个 VEX AIM 编码机器人可以连接,以便在项目期间进行通信。使用消息积木,机器人可以发送和接收信息以协调其动作。

**注意:**为了发送和接收消息,两个机器人必须同时运行处理消息的项目。

以下是所有可用块的列表:

发送消息#

发送消息块向另一个链接的机器人发送一个字符串。

发送消息 [message]

参数

描述

信息

发送给其他链接机器人的字符串。

例子

当屏幕 [pressed v] :: hat events
[Press the screen to send a message to the other robot.]
发送消息 [message]
当开始 :: hat events
[Display when a message is received.]
等到 <有消息吗?>
在屏幕上打印 [Received!]▶

发送带有数据的消息#

发送带有数据的消息块向另一个链接的机器人发送一个字符串和一个数字。

发送带有数据 [message]消息 [0]

参数

描述

信息

发送给其他关联机器人的值。该值必须是字符串。

数据

发送给另一个机器人的数字。

例子

当屏幕 [pressed v] :: hat events
[Send the current heading to the other robot.]
发送带有数据 [message]消息 (归位角度值)
当开始 :: hat events
[Turn to match the other robot's heading.]
永久循环
如果 <有消息吗?> 那么
获取带有数据的最新消息
归位至 (最新数据) 度 ▶

获取最新消息#

获取最新消息块存储从其他链接机器人接收到的最新字符串。

获取最新消息

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Display the received message.]
等到 <有消息吗?>
获取最新消息
在屏幕上打印 (最新消息)▶
当屏幕 [pressed v] :: hat events
[Send "VEXcode!" to the other robot.]
发送消息 [VEXcode!]

获取带有数据的最新消息#

获取带有数据的最新消息块存储从其他链接机器人接收到的最新字符串和数字。

获取带有数据的最新消息

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Turn to match the other robot's heading.]
永久循环
如果 <有消息吗?> 那么
获取带有数据的最新消息
归位至 (最新数据) 度 ▶
当屏幕 [pressed v] :: hat events
[Send the current heading to the other robot.]
发送带有数据 [message]消息 (归位角度值)

最新消息#

最新消息块返回上次使用获取最新消息获取带有数据的最新消息 块时存储的最新字符串。

(最新消息)

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Display the received message.]
等到 <有消息吗?>
获取最新消息
在屏幕上打印 (最新消息)▶
当屏幕 [pressed v] :: hat events
[Send "VEXcode!" to the other robot.]
发送消息 [VEXcode!]

最新数据#

最新数据块返回上次使用获取带有数据的最新消息 块时存储的最新数字。

(最新数据)

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Turn to match the other robot's heading.]
永久循环
如果 <有消息吗?> 那么
获取带有数据的最新消息
归位至 (最新数据) 度 ▶
当屏幕 [pressed v] :: hat events
[Send the current heading to the other robot.]
发送带有数据 [message]消息 (归位角度值)

有消息吗?#

消息可用吗? 块返回一个布尔值,指示其他链接机器人是否曾经在当前项目中使用过 发送消息发送带有数据的消息 块。

<有消息吗?>

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Display when a message is received.]
等到 <有消息吗?>
在屏幕上打印 [Message received!]▶
当屏幕 [pressed v] :: hat events
[Press the screen to send a message to the other robot.]
发送消息 [message]

已连接?#

**是否连接?**块返回一个布尔值,指示机器人当前是否与另一个机器人相连。

  • 真 - 该机器人与另一个机器人相连。

  • 错误 - 机器人未与其他机器人连接。

<已连接?>

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Turn off one of the linked robots to see the message change.]
永久循环
清屏
在屏幕上打印 <已连接?>▶