用户:
豹2a7查看:3 回复:5 评论:3 创建时间:2022-06-18T18:15:39
咋办,这是代码
// 先在场景中放置一个名称为 NPC 的实体。
const npc = world.querySelector('#电脑');
npc.enableInteract = true; // 允许进行互动
npc.interactRadius = 1000; // 实体的互动范围
npc.interactHint = npc.id; // 互动提示框显示实体的名称
npc.interactColor = new Box3RGBColor(1,0,1); // 互动提示的文字颜色
// 玩家与实体进行交互时触发
npc.onInteract(async({entity}) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT, //对话框类型为选择框
content: `${entity.player.name}`,
title: `控制⾯板(管喵专用)`,
options: ['幽灵模式', '管喵特权', '服务器强制崩溃重启'],
});
if (selection) { //确保对话框不是点击x关闭
if (selection.value === '幽灵模式') {
if (entity.player.name == '豹2[密苏里](DYZ)') {
entity.player.spectator = !entity.player.spectator;
} else {
entity.player.dialog({ //弹出对话框
type: Box3DialogType.TEXT, //对话框类型为纯⽂本
content: `你不是管喵`,
title: '系统',
})
}
}
if (selection.value === '服务器强制崩溃重启') {
if (entity.player.name === '豹2[密苏里](DYZ)') {
const selection = await entity.player.dialog({
type: Box3DialogType.SELECT, //对话框类型为选择框
content: `真的确定要重启服务器吗?`,
title: `控制⾯板`,
options: ['是', '否'],
})
if (selection) {
if (selection.value === '是') {
world.say('作者 豹2 使用了while循环')
world.say('服务器已强制崩溃即将重启')
while(1){}
}
}
} else {
entity.player.dialog({ //弹出对话框
type: Box3DialogType.TEXT, //对话框类型为纯⽂本
content: `你不是管喵`,
title: '系统',
})
}
}
if (selection.value === '管喵特权') {
if (entity.player.name === '豹2[密苏里](DYZ)' || entity.player.name === '全能代码师' ) {
const code = await entity.player.dialog({ //弹出对话框
type: Box3DialogType.INPUT, //对话框类型为输入框
content: `请输入指令`,
title: '系统',
});
try {
world.say('~>' + eval(code));
} catch (err) {
world.say('⚠Error⚠:' + err);
}
} else {
entity.player.dialog({ //弹出对话框
type: Box3DialogType.TEXT, //对话框类型为纯⽂本
content: `你不是管喵`,
title: '系统',
})
}
}
}
}
);

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%8A%A0%E6%B2%B9.gif"alt="emotion_编程猫_加油"
点赞0
评论