用户:
三宝六查看:3 回复:10 评论:3 创建时间:2022-12-08T11:58:06
这是我的代码,有错误吗?这还是在用户手册粘贴过来的,编辑器尽然报错!!!!
else if (npc.id == '小卖部老板') { //如果实体名是'小卖部老板'
npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc问你想买哪些商品
const goodsList = ['薯片', '可乐', '糖果'] //货品列表
const priceList = [7, 5, 4] //价格列表
const selection = await entity.player.dialog({
type: Box3DialogType.SELECT, //对话框类型为选择框
content: `你有${entity.money}元, 想买点什么呢?`,
title: npc.id, //对话框左上角显示NPC名字
options: ['薯片 (7元)', '可乐 (5元)', '糖果 (4元)'], //选项
})
})
}
七叶寂照秘密主promax要复制的话给我关注
代码附上
for (const npc of world.querySelectorAll('.NPC')) {
npc.enableInteract = true
npc.interactRadius = 3 //这里是交互范围
npc.interactHint = npc.id
npc.interactColor.set(0, 0, 1) //蓝色
if (npc.id == '小卖部老板') { //如果实体名是'小卖部老板'
npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc问你想买哪些商品
const goodsList = ['薯片', '可乐', '糖果'] //货品列表
const priceList = [7, 5, 4] //价格列表
const selection = await entity.player.dialog({
type: Box3DialogType.SELECT,
content: `你有${entity.money}元, 想买点什么呢?`,
title: npc.id,
options: ['薯片 (7元)', '可乐 (5元)', '糖果 (4元)'], //选项
})
})
}
}
评论区一堆码渣
点赞0
评论