用户:
福小然查看:1 回复:5 评论:1 创建时间:2021-05-19T20:23:36
那一天,我打开编辑器,
正想Ctrl+V,
粘贴我从大佬哪复制的存档代码,
可——
为什么总报错!
会的请打在评论区,万分感谢!
AB骉Alobokworld.onPlayerJoin(({ entity }) => { entity.player.enable3DCursor = true // 开启方块光标 })
world.onPress(({ raycast, button }) => { if (button === Box3ButtonType.ACTION0) { const pos = raycast.voxelIndex // 射线指到的方块位置 voxels.setVoxel(pos.x, pos.y, pos.z, '') } }) world.onPlayerJoin(({ entity }) => { entity.player.enable3DCursor = true // 开启方块光标 })
world.onPress(({ raycast, button }) => { if (button === Box3ButtonType.ACTION0) { const pos = raycast.voxelIndex.add(raycast.normal) // 射线指到的方块位置加上被选中的面的法线向量 voxels.setVoxel(pos.x, pos.y, pos.z, 'stone') } }) const voxelList = ['stone', 'dirt', 'grass', 'lava01'] // 可选方块
world.onPlayerJoin(({ entity }) => { entity.selected = 0 // 当前选定方块的序号 entity.player.enable3DCursor = true // 开启方块光标 })
world.onPress(({ entity, raycast, button }) => { if (button === Box3ButtonType.ACTION0) { const vox = voxelList[entity.selected] const pos = raycast.voxelIndex.add(raycast.normal) // 射线指到的方块位置加上被选中的面的法线向量 voxels.setVoxel(pos.x, pos.y, pos.z, vox) } else if (button === Box3ButtonType.ACTION1) { entity.selected = (entity.selected + 1) % voxelList.length const vox = voxelList[entity.selected] entity.player.directMessage(`当前选定"${vox}"`) } }) world.onPlayerJoin(({ entity }) => { entity.player.enable3DCursor = true // 开启方块光标 entity.selected = 'stone' // 玩家当前选定dirt方块 })
world.onPress(async ({ entity, raycast, button }) => { if (button === Box3ButtonType.ACTION0) { const pos = raycast.voxelIndex.add(raycast.normal) // 射线指到的方块位置加上被选中的面的法线向量 voxels.setVoxel(pos.x, pos.y, pos.z, entity.selected) } else if (button === Box3ButtonType.ACTION1) { const selection = await entity.player.dialog({ type: Box3DialogType.SELECT, content: '选择方块类型', options: ['stone','dirt','grass','lava01','snow'], }) if (selection) { entity.selected = selection.value // 更新玩家当前选定方块 } } })
点赞0
评论