用户:
豪爽的麦霸菇iPu1查看:0 回复:4 评论:0 创建时间:2022-07-10T16:14:08
BOX中如何让汽车移动???????
核心代码是这个
console.clear();//清空控制台
var biangaix = 0
globalThis.findp = (name) => world.querySelectorAll('player').reverse().find(e => e.player.name == name)
const Admin = ['1086爱编程', 'SHEL.深空.无尽', '小鸟', '可乐OωO']
var bianliang = 0
const cao = world.querySelector('.面板-前')
cao.enableInteract = true
cao.interactHint = '',
cao.interactRadius = 5
cao.onInteract(async ({ entity }) => {
bianliang = await entity.player.dialog({
type: 'input',
title: '单次推动力设置',
content: '单次推动力设置',
})
if (Number(bianliang) == NaN || Number(bianliang) == Infinity || Number(bianliang) >= 1) {
bianliang = 0
entity.player.directMessage('只能输入数字或者小于一的数')
entity.player.dialog({ //弹出对话框
type: Box3DialogType.TEXT, //对话框类型为输入框
content: `只能输入数字或者小于一的数`,
title: '系统',
});
entity.player.dialog({ //弹出对话框
type: Box3DialogType.TEXT, //对话框类型为输入框
content: `焯,搞事情?`,
title: 'SHEL.深空.无尽',
});
} else {
bianliang = Number(bianliang)
world.say(`${entity.player.name} 设置列车推动力为 ${bianliang},当前列车速度:${sudu * 30}km/h`)
}
});
world.onPlayerJoin(async ({ entity }) => {
if (Admin.includes(entity.player.name)) {
entity.player.kick = () => {
world.say('错误:将 ' + entity.player.name + " 踢出地图失败");
console.warn('错误:将 ' + entity.player.name + " 踢出地图失败");
};
}
});
require('./admin.js');
var chey = 0
var chex = 0
var chez = 0
console.clear();
world.addCollisionFilter('player', 'player');
/*(async () => {//提示代码,创作者@SHEL.深空.无尽
world.say('启动地图中')
await sleep(1000)
world.say('缓存数据中')
await sleep(1500)
world.say('地图启动正常!')
while (true){
await sleep(12000)
world.say('[系统]地图每一小时就会重启一次,不必担心卡顿')
await sleep(12000)
world.say('[系统]开完车记得把车倒回来,别人还要玩')
await sleep(12000)
world.say('[系统]地图内禁止骂人和捣乱玩家开车')
await sleep(12000)
world.say('[系统]不小心掉下车了怎么办,在车站通道找到回车按钮按下返回')
await sleep(12000)
world.say('[系统]单次推动力(挡位)最好设置成0.1')
await sleep(12000)
world.say('[系统]车组限速750km/h(挡位25)')
await sleep(12000)
world.say('[系统]不要试图开飞机,把飞机开到地底我可不管(')
await sleep(12000)
world.say('[系统]轨道两端有阻尼器,不要试图探索地图外有什么')
await sleep(12000)
world.say('[系统]开太快碰到阻尼器会被甩飞')
await sleep(12000)
world.say('[系统]有什么疑问可以在评论区提出')
await sleep(12000)
world.say('[系统]排队游玩,别抢车')
await sleep(12000)
world.say('[系统]和面板互动来设置单次推动力(挡位)')
await sleep(12000)
world.say('[系统]在服务车(最后一节车厢)装有急停按钮,关键时刻按下可急停')
}
})();*/
(async () => {
while (true){
await sleep(3600000)
while (true){
}
}
})();
(async () => {
while (true) {
await sleep(10)
if (sudu > 25) {
sudu = 24
}
else {
}
}
})();
(async () => {
while (true) {
await sleep(10)
if (chex > 15000) {
sudu = -1
}
else {
}
}
})();
(async () => {
while (true) {
await sleep(10)
if (chex < -200) {
sudu = 0.05
}
else {
}
}
})();
world.onPress(({ button, entity }) => {
if (button === Box3ButtonType.ACTION0) {
entity.player.directMessage(`当前速度${sudu * 30}km/h 挡位${sudu} y标${chey} x标${chex} z标${chez}`);
}
});
world.onPlayerJoin(({ entity }) => {
entity.state = 1;
entity.times = 1;
entity.player.cameraMode = Box3CameraMode.FPS;
console.log('setting camera mode:', entity.player.cameraMode);
});
console.log('fps mode enabled');
var sudu = 0
world.querySelectorAll('.车').forEach(async (t) => {
while (true) {
await sleep(1000);
for (t.time = 0; t.time < 18e100; t.time++) {
t.velocity.x = sudu;
//entity.position.set(chex,chey,chez)
await sleep(1);
}
await sleep(1000);
for (t.time = 0; t.time < 18e100; t.time++) {
t.velocity.x = sudu;
await sleep(1)
}
}
});
world.querySelectorAll('#检测').forEach(async (f) => {
while (true) {
await sleep(1000);
for (f.time = 0; f.time < 18e100; f.time++) {
f.velocity.x = sudu;
//entity.position.set(chex,chey,chez)
await sleep(1);
chey = f.position.y
chex = f.position.x
chez = f.position.z
}
await sleep(1000);
for (f.time = 0; f.time < 18e100; f.time++) {
f.velocity.x = sudu;
await sleep(1)
}
}
});
// 先在场景中放置一个名称为 NPC 的实体。
const npc9 = world.querySelector('.回车');
npc9.enableInteract = true; // 允许进行互动
npc9.interactRadius = 2; // 实体的互动范围
npc9.interactHint = npc9.id;
// 玩家与实体进行交互时触发
npc9.onInteract(async ({ entity }) => {
entity.position.set(chex+6,chey+3,chez)
});
// 先在场景中放置一个名称为 NPC 的实体。
const npc = world.querySelector('.加速-前');
npc.enableInteract = true; // 允许进行互动
npc.interactRadius = 2; // 实体的互动范围
npc.interactHint = npc.id;
// 玩家与实体进行交互时触发
npc.onInteract(async ({ entity }) => {
sudu += bianliang
world.say(`${entity.player.name}将汽车加速了`)
entity.player.directMessage(`当前速度${sudu * 30}km/h 挡位${sudu} y标${chey} x标${chex} z标${chez}`);
});
// 先在场景中放置一个名称为 NPC 的实体。
const npc3 = world.querySelector('.减速-前');
npc3.enableInteract = true; // 允许进行互动
npc3.interactRadius = 2; // 实体的互动范围
npc3.interactHint = npc3.id;
// 玩家与实体进行交互时触发
npc3.onInteract(async ({ entity }) => {
sudu -= bianliang
world.say(`${entity.player.name}将汽车减速了`)
entity.player.directMessage(`当前速度${sudu * 30}km/h 挡位${sudu} y标${chey} x标${chex} z标${chez}`);
});
// 先在场景中放置一个名称为 NPC 的实体。
const npc5 = world.querySelector('.急停-服务车');
npc5.enableInteract = true; // 允许进行互动
npc5.interactRadius = 2; // 实体的互动范围
npc5.interactHint = npc5.id;
// 玩家与实体进行交互时触发
npc5.onInteract(async ({ entity }) => {
sudu = 0
world.say(`${entity.player.name}将列车急停了`)
entity.player.directMessage(`当前速度${sudu} y标${chey} x标${chex} z标${chez}`);
});
// 先在场景中放置一个名称为 NPC 的实体。
const npc4 = world.querySelector('.急停-前');
npc4.enableInteract = true; // 允许进行互动
npc4.interactRadius = 2; // 实体的互动范围
npc4.interactHint = npc4.id;
// 玩家与实体进行交互时触发
npc4.onInteract(async ({ entity }) => {
sudu = 0
world.say(`${entity.player.name}将车列急停了`)
entity.player.directMessage(`当前速度${sudu} y标${chey} x标${chex} z标${chez}`);
});
const npc2 = world.querySelector('.面板-前');
npc2.enableInteract = true; // 允许进行互动
npc2.interactRadius = 2; // 实体的互动范围
npc2.interactHint = npc2.id;
// 玩家与实体进行交互时触发
npc2.onInteract(async ({ entity }) => {
entity.player.directMessage(`当前速度${sudu} y标${chey} x标${chex} z标${chez}`);
});点赞0
评论
是这个
//选中所有带有标签target的实体,并遍历循环.
world.querySelectorAll('.target').forEach((e)=>{
e.onEntityContact(({entity,other})=>{ //设置目标模型的碰撞事件.
if(!other.isPlayer){return} //防止非玩家实体参与检测.
other.mesh=entity.mesh; //设置玩家的外观.
other.meshScale=entity.meshScale; //设置玩家外观缩放比例.
other.player.invisible=true; //如果模型比玩家小,就需要隐藏玩家的皮肤.
})
})
核心代码是这个,其他的设置你就靠你自己了
点赞0
评论