用户:
翎with珝查看:1 回复:2 评论:1 创建时间:2023-04-10T06:48:53
大约是在3月二十几号
有一个人(betray_竹箫)在代码岛官群发了个链接
打着有去看,看则蹭
我进了那个链接
然后成为了苦力
最开始是肝亿些些建筑
然后又写了亿些些代码
当时我苦命写的电梯标识符和电梯
然后到昨天
我说多建电梯有冲突
然后Ta说了个新方案
传送
后来我又苦命的写了新的电梯代码
但是这个代码要《疯翔》出来啊
所以我把可能有BUG的代码放出来
//玩家电梯设置
world.onPlayerJoin(async ({ entity }) => {
entity.player.lifting = false
})
//权限
var admin_lift = [
'javaScript666',
'daimeng666'
]
//玩家对应的楼层坐标
var lift_Position_Gamer = [
new Box3Vector3(10, 12, 63),//1层坐标
new Box3Vector3(10, 24, 63),//2层坐标
new Box3Vector3(10, 36, 63),//3层坐标
new Box3Vector3(10, 48, 63),//4层坐标
]
//模型对应的楼层坐标
var lift_Position_Visual_Angle = [
new Box3Vector3(2.5, 12, 63),//1层坐标
new Box3Vector3(2.5, 24, 63),//2层坐标
new Box3Vector3(2.5, 36, 63),//3层坐标
new Box3Vector3(2.5, 48, 63),//4层坐标
]
world.onTick(async ({ }) => {
world.querySelectorAll("*").forEach(async (e) => {
if (e.hasTag('电梯')) {
e.interactHint = !e.hasTag('损坏') && !e.hasTag('停用') ? `${e.id}层电梯` : `${e.id}层电梯 (损坏 || 停用)`
}
})
})
world.querySelectorAll("*").forEach(async (e) => {
if (e.hasTag('电梯')) {
e.a喵Tag('可用')
e.enableInteract = true
e.interactRadius = 3
e.interactHint = !e.hasTag('损坏') && !e.hasTag('停用') ? `${e.id}层电梯` : `${e.id}层电梯 (损坏 || 停用)`
e.onInteract(async ({ entity }) => {
let lift = [];
world.querySelectorAll("*").forEach(async (t) => {
if (t.hasTag('电梯') && e.id !== t.id && !lift.includes(`${t.id}层`) && !e.hasTag('损坏')) {
lift.push(`${t.id}层`)
}
});
if (admin_lift.includes(entity.player.boxId)) {
lift.push('电梯后台')
}
lift.push('退出');
let storey = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: `${!e.hasTag('损坏') && !e.hasTag('停用') ? `${e.id}层电梯` : `${e.id}层电梯 (损坏 || 停用)`}`,
content: entity.player.lifting == false ? `你当前处于第 ${e.id} 层\n目前共有 ${admin_lift.includes(entity.player.boxId) ? lift.length - 2 : lift.length - 1} 组可用电梯\n${lift.length - 2 == 0 || lift.length - 1 == 0 ? '没有电梯可以使用' : '请问你要前往几层'}` : `当前有 ${admin_lift.includes(entity.player.boxId) ? lift.length - 2 : lift.length - 1} 组可用电梯\n你正在乘坐电梯`,
options: entity.player.lifting == false ? lift.sort() : ['退出']
});
if (!storey) return;
if (storey) {
if (storey.value == '退出') {
entity.player.cancelDialogs();
return;
} else if (storey.value == '电梯后台') {
let lift = [];
world.querySelectorAll("*").forEach(async (t) => {
if (t.hasTag('电梯')) {
lift.push(`${t.id}层电梯`)
}
});
lift.push('退出')
let storeies = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: `电梯后台`,
content: entity.player.lifting == false ? `你当前处于第 ${e.id} 层` : '你正在乘坐电梯',
options: entity.player.lifting == false ? lift.sort() : ['退出']
});
if (!storeies) return;
if (storeies) {
if (storeies.value == '退出') {
return;
} else {
let damage = false
let use = true
world.querySelectorAll("*").forEach(async (t) => {
if (t.hasTag('电梯') && t.id + '层电梯' == storeies.value) {
if (t.hasTag('损坏')) {
damage = true
} else damage = false;
if (t.hasTag('可用')) {
use = true
} else use = false
}
});
let lifts = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: `电梯后台`,
content: `你当前正在查看 ${storeies.value}\n是否损坏:${damage}\n是否可用:${use}`,
options: ['修复', '停用', '启用', '退出']
});
if (!lifts) return;
if (lifts) {
if (lifts.value == '修复') {
if (damage == true) {
world.querySelectorAll("*").forEach(async (t) => {
if (t.hasTag('电梯') && t.id + '层电梯' == storeies.value) {
if (t.hasTag('损坏')) {
damage = false
t.removeTag('损坏')
}
}
});
}
} else if (lifts.value == '启用') {
if (use == false) {
if (damage == true) return;
world.querySelectorAll("*").forEach(async (t) => {
if (t.hasTag('电梯') && t.id + '层电梯' == storeies.value) {
if (t.hasTag('停用')) {
use = true
t.removeTag('停用')
e.addTag('可用')
}
}
});
}
} else if (lifts.value == '停用') {
if (use == true) {
world.querySelectorAll("*").forEach(async (t) => {
if (t.hasTag('电梯') && t.id + '层电梯' == storeies.value) {
if (t.hasTag('可用')) {
use = false
t.removeTag('可用')
e.addTag('停用')
}
}
});
}
} else if (lifts.value == '退出') {
return;
}
}
}
}
} else {
await lift_Run(
entity,
lift_Position_Visual_Angle[parseFloat(e.id) - 1],
lift_Position_Visual_Angle[parseFloat(storey.value) - 1],
lift_Position_Gamer[parseFloat(storey.value) - 1],
Math.abs(
(parseFloat(e.id) - 1) - (parseFloat(storey.value) - 1)
)
)
}
}
})
}
})
//视角动画
async function lift_Run(entity, start_Lift, over_Lift, over_Gamer, range) {
let e = world.createEntity({
position: start_Lift,
})
let ani = e.animate([
{ position: start_Lift, duration: 1 },
{ position: start_Lift, duration: 5 },
{ position: over_Lift, duration: 1 },
], {
duration: 24 * (12 / (2 * 2)) * range,
iterations: 1,
direction: Box3AnimationDirection.NORMAL,
})
entity.player.directMessage('电梯启动')
entity.player.cameraEntity = e
entity.player.disableInputDirection = Box3InputDirection.BOTH
entity.player.showName = false
entity.player.invisible = true
entity.player.enableJump = false
entity.player.lifting = true
entity.player.fall = over_Gamer.y
ani.onFinish(async () => {
world.querySelectorAll("player").forEach(async (p) => {
if (p.player.name == entity.player.name) {
entity.player.directMessage('电梯停了')
entity.player.cameraEntity = entity
entity.position.copy(over_Gamer)
entity.player.disableInputDirection = Box3InputDirection.NONE
entity.player.showName = true
entity.player.invisible = false
entity.player.enableJump = true
entity.player.lifting = false
}
})
e.destroy()
});
};
代码有BUG(确信
BUG在电梯后台(肯定
BUG我不修了(
有问题找你们认识的大佬帮你们(