用户:指令者查看:13 回复:5 评论:13 创建时间:2023-01-10T19:07:27
1 npc函数
function npc(selector, fn, interactHint, interactRadius, interactColor) {
const Npc = world.querySelector(selector);
Npc.enableInteract = 1;
Npc.interactHint = interactHint ?? Npc.id.split('-')[0]
Npc.interactRadius = interactRadius ?? 3;
Npc.interactRadius = interactRadius ?? new Box3RGBColor(0, 0, 0);
Npc.onInteract(async ({ entity }) => {
await fn(entity)
})
}
2 对话框函数
async function textDialog(entity, title, content) {
return await entity.player.dialog({
type: Box3DialogType.TEXT,
title,
content
})
}第一个链接 : https://shequ.codemao.cn/wiki/forum/516075
第二个链接 : https://shequ.codemao.cn/community/468571
点赞0
评论
治愈绾兮这才对啦()
function npc(selector, fn, interactHint, interactRadius, interactColor) {
let Npc = world.querySelector(selector);
Npc.enableInteract = true;
Npc.interactHint = interactHint ?? Npc.id.split('-')[0]
Npc.interactRadius = interactRadius ?? 3;
Npc.interactColor = interactColor?? new Box3RGBColor(0, 0, 0);
Npc.onInteract(async ({ entity }) => {
await fn(entity)
})
}
async function textDialog(entity, title, content) {
return await entity.player.dialog({
type: Box3DialogType.TEXT,
title,
content,
})
}点赞0
评论
function addlaser(start,end){
const Quat = new Box3Quaternion(0,0,0,1);
function addlaser(start,end){
const distance = start.distance(end);
const laser = world.createEntity({
mesh: 'mesh/激光.vb',
meshScale: [0.0625*distance,0.0625,0.0625],
gravity: false,
collides: false,
fixed: true,
position: start.lerp(end,0.5),
})
const d = start.sub(end);
laser.meshOrientation = Quat.rotateX(Math.atan2(d.y,Math.sqrt(d.x**2+d.z**2))).rotateY(Math.atan2(d.z,d.x));
const points = [];
for(let i=0;i<distance;i+=0.1){
points.push({
lo: start.lerp(end,0.1*distance*i),
hi: start.lerp(end,0.1*distance*i),
})
}
world.onTick(()=>{
points.forEach((e)=>{
world.searchBox(e).forEach((e)=>{
if(e.isPlayer){
e.hurt(100);
}
})
})
})
}
}点赞0
评论