猫史档案馆


【box3求助】谁会做随机出口算题的代码

用户:努力学习的包酱努力学习的包酱查看:0 回复:5 评论:0 创建时间:2023-01-24T13:35:33


就是用for循环连续出10道计算题)))

本人会用随机数


回复

上一页1 页 / 共 1下一页
努力学习的包酱努力学习的包酱

ddd

点赞0


评论


努力学习的包酱努力学习的包酱

ddd

点赞0


评论


萌新大佬萌新大佬

先随机两个数,运算得到结果并存起来,向玩家询问,然后判断输入是否与结果一样

点赞0


评论


叁式橙子叁式橙子

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


评论


屑格子awa屑鸽子屑格子awa屑鸽子

emm.......定义两个随机数变量, 再让它们相加, 在对比玩家输入

点赞0


评论