
Lv.1
5202年想起黑历史赶忙来优化一下,以后不一定了
签名:“真正的不予置评,是默默走开,而不是拿着键盘像营造众人皆醉他独醒的人设,奈何文化水平又跟不上,起码的分辨能力也没有。”
在 代码三连问(最好给我直接复制粘贴的)谢谢创作节用 中回复
// 先在场景中放置一个名称为 NPC 的实体。
const npc = world.querySelector('#NPC');
npc.enableInteract = true; // 允许进行互动
npc.interactRadius = 16; // 实体的互动范围
npc.interactHint = npc.id; // 互动提示框显示实体的名称
npc.interactColor = new Box3RGBColor(1,0,1); // 互动提示的文字颜色
// 玩家与实体进行交互时触发
npc.onInteract(async({entity}) => {
const result = await entity.player.dialog({
type: Box3DialogType.TEXT, // 对话框的类型,TEXT是文本框。
title: npc.id, // 对话框标题为NPC名字,表示正在说话的是NPC
lookEye: entity, // 将相机放在玩家位置
lookTarget: npc, // 相机镜头对准NPC
content: `你好,${entity.player.name},很高兴认识你。`,
});
});2022-12-07T18:05:00 点赞:0
在 紧急求助!!! 中回复
qwq那好吧
for(let x=0; x<127; x++){
for(let z=0; z<127; z++){
voxels.setVoxel(x, 8, z, 'snow')
}}
for (const e of world.querySelectorAll('*')) {//遍历所有实体
if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
e.collides = true //开启碰撞
e.fixed = true //固定实体不被推移
e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
if (other.isPlayer) { //另一个实体是玩家
if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
other.player.directMessage('到达新的存档点') // 给玩家发消息
other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
}
}
}
)
}
}
world.onVoxelContact(({ entity, voxel, }) => {
if (!entity.isPlayer) return; // 如果碰到方块的不是玩家,则跳过
const voxelName1 = voxels.name(voxel); // 将方块id转换名称
if (voxelName1 === 'snow') {
entity.player.position = entity.player.spawnPoint
entity.poistion.y += 3
}
})2022-12-08T19:49:54 点赞:0
在 【岛三】求助 中回复
//无视评论(划掉
Math.floor(Math.random()*(5+1)) //0-5间随机整数(小数的话删掉floor)
Math.floor(Math.random()*5)+1 //1-5间随机整数
Math.floor(Math.random()*(m-n+1))+n //n-m间随机整数
//某网站原话,非本人所写,只是整理了一下qwq2022-12-09T16:31:51 点赞:0
在 萌新求助!!! 中回复
for (const e of world.querySelectorAll('*')) {//遍历所有实体
if (e.id.startsWith('通关点')) {//如果当前实体名左边部分刚好是"通关点"
e.collides = true //开启碰撞
e.fixed = true //固定实体不被推移
e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
if (other.isPlayer) { //另一个实体是玩家
if (other.player.win === true) return;
other.player.win = true;
other.player.canFly = true
}
})
}
}2022-12-09T22:06:36 点赞:0
在 岛3跑酷代码!!!求助! 中回复
world.onVoxelContact(({entity,voxel})=>{ if(!entity.isPlayer)return;//如果碰到方块的不是玩家,则跳过 constvoxelName=voxels.name(voxel);//将方块id转换名称 if(voxelName==='white_grass'){ entity.player.position.copy(entity.player.spawnPoint) entity.position.y+=2 } }); 跑酷存档点代码自己去找吧,或者给个链接
2022-12-10T18:22:51 点赞:1
在 盗码处c。,。,,。,p的证据截图(无引战,辱骂,透露隐私等行为,如遇举报,请官方核实) 中回复
码了一堆字浏览器给我闪退……
理一下经过
你和盗码是朋友
1.你申请神教创作段,盗码没同意然后拉黑了你,你很生气
2.你让别人转告她道歉,盗码喵时没回,你准备绝交
3.你等了几天,发帖了……
问题
1.”盗码师“这个号早就被封了,再拿出来说有什么意义,又不能把头像改回去
2.万一别人有事情呢?非要那么准时?
3.确实,别人拉不拉黑你是别人的自由
2022-12-10T18:39:50 点赞:3
在 【求助】穿戴配件 中回复
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/奖杯.vb',
orientation: new Box3Quaternion(0, 1, 0, 0).rotateY(Math.PI/2),
scale: new Box3Vector3(0.2, 0.2, 0.2),
offset: new Box3Vector3(0, -0.05, 0.1),
});
const handWears = entity.player.wearables(Box3BodyPart.RIGHT_HAND);
entity.player.removeWearable(handWears[0]);2022-12-11T11:05:48 点赞:0
在 【求救】怎么把一个图的代码移到另一个图去?(平板) 中回复
const checkPoints = []; // 检查点列表
const playerState = {} ; // 用于记录每个玩家的游戏状态
let bestResult = Infinity; // 最佳成绩, 用时越短越好, 所以初始化为无穷大
// 初始化检查点
world.querySelectorAll('.检查点').forEach((entity) => {
const bounds = getEntityBounds(entity); // 获取检查点的bounds(大小)
const index = parseInt(entity.id.match(/\d+/)[0]); // 计算检查点的序号
checkPoints.push({ index, bounds }); // 添加到checkPoints
entity.destroy(); // 摧毁检查点, 因为我们只需要index和bounds
});
// 根据index从大到小, 给checkPoints排序
checkPoints.sort((a, b) => a.index > b.index ? 1 : -1);
// 每个tick都检查所有玩家是否有经过存档点, 依次经过各个存档点才算跑完一圈
world.onTick(() => {
const now = new Date().valueOf(); // 获取当前时间的毫秒数
const players = world.querySelectorAll('player'); // 获取所有玩家
for (const entity of players) {
const { name } = entity.player; // 玩家昵称
const bounds = getEntityBounds(entity); // 玩家范围
const state = playerState[name]; // 玩家状态
const next喵 = state.nextCheckPoint; // 下个存档点
// 如果碰到了起点
if (checkPoints[0].bounds.intersects(bounds)) {
// 用户的下个存档点大于最大存档点, 表示跑完一圈了
if (next喵 === checkPoints.length) {
const time = (now - state.startTime) / 1000; // 所用时间转换为秒数
// 判断是否打破记录
if (time < bestResult) {
bestResult = time;
world.say(`恭喜@${name}以${time}秒的成绩打破记录!`);
} else {
world.say(`@${name}跑完一圈, 圈速${time}秒.`);
}
} else if (next喵 === 0) {
// 第一次起跑
world.say(`恭喜@${name}出发啦!`);
}
// 刷新存档点和时间
state.nextCheckPoint = 1;
state.startTime = now;
} else if (next喵 >= 0 && next喵 < checkPoints.length && checkPoints[next喵].bounds.intersects(bounds)) {
// 碰到了下个存档点, 存档点+1
state.nextCheckPoint++;
}
}
});
const spawnPoint = world.querySelector('#出生点'); // 获取出生点
const cars = world.querySelectorAll('.车'); // 获取所有车辆
// 销毁存档点和车的实体, 我们只需要mesh数据
spawnPoint.destroy();
cars.forEach((car) => car.destroy());
// 初始化玩家
world.onPlayerJoin(({entity}) => {
entity.position.copy(spawnPoint.position); // 传送到出生点
// 添加随机偏移, 避免人多的时候互相碰撞
const offset = new Box3Vector3(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
entity.position.addEq(offset.scale(3));
// 设置初始状态
playerState[entity.player.name] = {
nextCheckPoint: 0,
startTime: 0,
};
const car = randomPick(cars); // 随机选一辆车
// 设置mesh
entity.mesh = car.mesh;
entity.meshScale = car.meshScale;
// 调整mesh方向, 旋转180度
entity.meshOrientation = entity.meshOrientation.rotateY(Math.PI);
entity.player.invisible = true; // 隐藏玩家模型
// 设置速度
entity.player.walkSpeed = 0.8;
entity.player.walkAcceleration = 0.05;
entity.player.runSpeed = 2.2;
entity.player.runAcceleration = 0.08;
});
// 计算实体的绝对坐标bounds
function getEntityBounds(entity) {
const lo = entity.position.sub(entity.bounds);
const hi = entity.position.add(entity.bounds);
const bounds = new Box3Bounds3(lo, hi);
return bounds;
}
// 随机选择一个数组中的元素
function randomPick(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
2022-12-11T11:15:02 点赞:0
在 岛3代码求助 中回复
world.onVoxelContact(async({entity,voxel,x,y,z})=>{if(voxel!=voxels.id('ice')||!entity.isPlayer)return
voxels.setVoxel(x,y,z,0);await sleep(2000);voxels.setVoxel(x,y,z,'ice')})2022-12-11T15:54:13 点赞:0
在 求助!这种代码怎么写! 中回复
function 1(){
//主程序
}
world.onPlayerJoin(async({ entity }) => {
entity.defen = 0
1()
while (true){
if (defen > 100){
while(1){}
}
await sleep(1)
}
})2022-12-12T12:47:14 点赞:0