猫史档案馆


【yeeee剑代码教程】

用户:指令者指令者查看:276 回复: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
    })
}


回复

上一页第 1 页 / 共 1 页下一页
治愈绾兮治愈绾兮

额,这很难吗()

点赞0


评论

你知道我不会,给整理一下,下次复制方便()

上面那个怎么用

az不是说了吗

刚发的那个


指令者指令者

第一个链接 : 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


评论

这个

你这在哪找的

https://shequ.codemao.cn/community/387107

简单来说,传入的2个参数分别表示激光的起始坐标和终点坐标,调用函数时会从起始坐标发射激光到终点坐标,还有你这为啥函数定义了2次啊

代码复制都复制错了,另外这种代码建议自己写,你这复制之后代码区会很乱,并且一些参数比如速度也调不了

https://shequ.codemao.cn/community/509079

那参数怎么写啊,写些什么进去(格式?)

类型是向量

不懂()举个例子?


乐观向上的中国球乐观向上的中国球

e

 

点赞0


评论