用户:
PlumSteven查看:8 回复:4 评论:8 创建时间:2021-08-17T16:25:31
console.clear()
world.onPlayerJoin(({entity}) =>{
entity.money = 0
entity.job = ''
entity.score = 0
})
const npc = world.querySelector('#NPC')
npc.enableInteract = true
npc.interactRadius = 3
npc.fixed = true
world.onInteract(async({entity}) => {
const selection = await entity.player.dialog({
type:Box3DialogType.SELECT,
content:`你有${entity.score}学分,入职老师需60学分`,
title:npc.id,
options:['是', '否'],
})
if (selection){
if (selection == '是'){
if (entity.score >= 60){
world.say(`${entity.name}入职老师`);
entity.job = '老师';
} else{
entity.player.directMessage('你没有足够学分!!')
}
};
}
})
有个问题,就是我选择“是”之后没了反应(score为0),谁能帮一下我
七式草莓/*
修复者:元七七
代码存在的问题:
1.“selection == '是'”应该改成“selection.value == '是'”
2.“world.onInteract(...)”应该改成“npc.onInteract(...)”,否则所有实体的互动都会显示对话框
*/
console.clear()
world.onPlayerJoin(({entity}) =>{
entity.money = 0
entity.job = ''
entity.score = 0
})
const npc = world.querySelector('#NPC')
npc.enableInteract = true
npc.interactRadius = 3
npc.fixed = true
npc.onInteract(async({entity}) => {
const selection = await entity.player.dialog({
type:Box3DialogType.SELECT,
content:`你有${entity.score}学分,入职老师需60学分`,
title:npc.id,
options:['是', '否']
})
if (selection){
if (selection.value == '是'){
if (entity.score >= 60){
world.say(`${entity.name}入职老师`);
entity.job = '老师';
} else{
entity.player.directMessage('你没有足够学分!!')
}
};
}
})点赞1
评论