用户:
热情的小朋友查看:0 回复:1 评论:0 创建时间:2023-05-21T11:53:48
哈喽!我是热情的小朋友,我又出新教程了。
代码如下:
world.onPlayerJoin(({ entity }) => {
entity.player.message1 = ""; entity.player.interactTimes = 0; entity.enableInteract = true; entity.interactRadius = 2; entity.interactColor = new Box3RGBColor(1, 0, 1); // 互动提示的文字颜色
entity.interactHint = "@" + entity.player.name + "的界面";
entity.onInteract(async ({ entity, targetEntity }) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: targetEntity.player.name,
content: `玩家@ ${targetEntity.player.name}`,
options: ['和ta私聊', '退出互动']
})
if (!result || result === null) {
entity.player.directMessage('已为你自动取消互动了哦!(⌒▽⌒)');
return;
}
if (result.index == 0) {
const dialog = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "向 " + targetEntity.player.name + " 发送私聊信息",
content: `${entity.player.name},请你输入私聊内容`,
confirmText: ' 发 送 ',
placeholder: '请输入私聊内容',
});
targetEntity.player.message1 = dialog;
targetEntity.player.directMessage('收到 ' + entity.player.name + ' 向你发送的私聊信息,正在为你打开查看……')
await sleep(3000);
targetEntity.player.directMessage('正在查收 ' + entity.player.name + " 发送的私聊信息。")
entity.player.directMessage('对方已收到聊天信息了哦!“ψ(`∇´)ψ')
if (dialog) {
const dialog = targetEntity.player.dialog({
type: Box3DialogType.TEXT,
title: '玩家@ ' + entity.player.name + '和你私聊:',
content: targetEntity.player.message1,
});
}
}
})
})
