用户:
努力学习的包酱查看:0 回复:5 评论:0 创建时间:2023-01-24T13:35:33
就是用for循环连续出10道计算题)))
本人会用随机数
叁式橙子const studymechine = world.querySelector('#和平学习机')
studymechine.enableInteract = true
studymechine.interactRadius = 3
studymechine.interactHint = studymechine.id
studymechine.onInteract(async({entity})=>{
const a = Math.random() * 100
const b = -10+Math.random() * 110
const c = Math.floor(a)
const d = Math.floor(b)
const result = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "和平队长",
content: `${c} + ${d} = ?`,
confirmText: '确定', // 确定按钮上面的文字。按下确定按钮后,提交回答。
placeholder: '这里输入~' // 输入框背景上的提示文字。
});
if(!result||result === null){
return;
}
if(result == c + d){
textDialog(entity,'对了,学分+3')
entity.studypoint += 3
}else{
textDialog(entity,'错了,学分-1')
entity.studypoint -= 1
savePlayer(entity)
}
点赞1
评论