猫史档案馆


ZhaiQianYi

ZhaiQianYi

Lv.1

获赞:9收藏:0浏览:33作品收藏:0
回复帖子评论
上一页1 页 / 共 1下一页

【神岛新春特别活动】跨过2022,又回到了……2022? 中回复

噫?雷电猴呢?

2023-01-07T14:35:13 点赞:0

【神岛暑期活动第一弹】全民创作节比赛结束~ 中回复

新编辑器为什么不能配音乐

 

 

2023-07-25T14:30:06 点赞:1

【神岛暑期活动第一弹】全民创作节比赛结束~ 中回复

https://box3.codemao.cn/e/b48156fe68876a25b8e6

谁合作

2023-07-25T14:38:03 点赞:1

SQL的跑酷啊啊啊 中回复

拿去  这是记录xyz的

console.clear()
async function initTable() {
    return await db.sql`
        CREATE TABLE IF NOT EXISTS "player" (
            "x" INT NOT NULL,
            "y" INT NOT NULL,
            "z" INT NOT NULL,
            "userKey" CHAR(16) PRIMARY KEY UNIQUE NOT NULL
        )
    `;
}
console.clear()
async function saveUser(user) {
    await db.sql`
        INSERT INTO "player" (
            "x",
            "y",
            "z",
            "userKey"
        ) VALUES (
            ${user.x},
            ${user.y},
            ${user.z},
            ${user.player.userKey}
        )
        ON CONFLICT("userKey")
        DO UPDATE SET
            "x"=excluded."x",
            "y"=excluded."y",
            "z"=excluded."z"
    `
}
console.clear()
async function loadUser(user) {
    const [data] = await db.sql`SELECT * FROM "player" WHERE "userKey"=${user.player.userKey} LIMIT 1`
    if (data) {
        user.x = data.x
        user.y = data.y
        user.z = data.z
        user.position = [user.x,user.y,user.z]
    }
    else {
        saveUser(user)
    }
}
console.clear()
async function poll(fn, msg) {
    while (true) {
        try {
            return await fn()
        } catch (e) {
            const m = e.message
            if (m.includes('timeout')) {
                world.say('数据库出错 检查结果 :启动超时,请联系官方进行修复 &&&&& timeout')
            }
        }
        await sleep(2000) 
    }
}
console.clear()
poll(initTable, '等待主数据库启动...')
world.onPlayerJoin(({ entity }) => {
    loadUser(entity)
})
console.clear()
for (const e of world.querySelectorAll('*')) {
    if (e.id.startsWith('存档点')) {
        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 
                    other.x = Math.ceil(other.position.x)
                    other.y = Math.ceil(other.position.y)
                    other.z = Math.ceil(other.position.z)
                    saveUser(other)
                }
            }
        })
    }
}

2024-01-29T16:16:50 点赞:1

普通版本岛三创作端一直崩!一直进不去(官方还有没有注意普通版本啊! 中回复

就问大众化的商城和迁移什么时候搞出来

 

2024-01-30T14:49:07 点赞:0