
Lv.1
签名:我正在做跑酷图形化编辑器 作品状态:已发布,测试版V1.3 作品是否可购买:是(True) 背景音乐:你好女生(伴奏) PS:作品里面有说明(没做完,空格+鼠标点击旋转)
在 解答“@天才喵@” 我做了一个跑酷地图,但不知道怎么弄碰到岩浆就喵,谁能帮帮我,呜呜 中回复
解决代码(都有了):
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true
})
world.onVoxelContact(({ voxel, entity }) => {
if (voxel == voxels.id('lava01')) {
entity.hurt(entity.maxHp)
}
if (voxel == voxels.id('lava02')) {
entity.hurt(entity.maxHp)
}
})
world.onDie(({ entity }) => {
entity.hp = entity.maxHp
entity.forceRespawn()
})
问题信息:
1.第一个末尾缺了“)”
2.如果玩家最大生命值超过了100就不能被击杀
3.方块id可能错了
4.你喵了就复活,没有音效,没有提示,没有强制重生,也没有等待,当然谁都不知道了
2021-06-05T20:26:47 点赞:1
在 @所有岛民 shyfcka为我们带来了BlocklyPython!!!!报名抢先体验!!! 中回复
你这…发错专区了
另外,我也要(我就是BOX3里的元七七)
2021-06-26T07:37:36 点赞:0
在 【元七七 · 代码干货】在地图四周围上方块 中回复
代码:varmapSize=254/*普通地图(128*128*128)请改成126*/,thickness=10/*厚度,单位:方块*/,high=8+25/*高度,单位:方块(从0计数,从默认喵地计数请+8)*/,voxel='dirt'/*材质(名字或ID)*/;(asyncfunction(){for(letiof[((x,y,z)=>[x,y,z]),((x,y,z)=>[mapSize-x,y,z]),((x,y,z)=>[z,y,x]),((x,y,z)=>[z,y,mapSize-x])]){for(letx=0;x<10;x++){for(lety=0;y<=high;y++){for(letz=0;z<=mapSize;z++){voxels.setVoxel(...i(x,y,z),voxel)}};awaitsleep(10)}}})()
2021-06-26T12:33:22 点赞:0
在 【元七七 · 代码干货】在地图四周围上方块 中回复
改良代码:var/**/mapSize=254/*普通地图(128*128*128)请改成126*/,thickness=10/*厚度,单位:方块*/,high=8+25/*高度,单位:方块(从0计数,从默认草地计数请+8)*/,voxel='dirt'/*材质(名字或ID)*/;(async()=>{for(let/**/i/**/of[((x,y,z)=>[x,y,z]),((x,y,z)=>[mapSize-x,y,z]),((x,y,z)=>[z,y,x]),((x,y,z)=>[z,y,mapSize-x])]){for(let/**/x=0;x<10;x++){for(let/**/y=0;y<=high;y++){for(let/**/z=0;z<=mapSize;z++){voxels.setVoxel(...i(x,y,z),voxel)}};await/**/sleep(10)}}})()
2021-07-04T17:02:52 点赞:0
在 【元七七 · 代码干货】在地图四周围上方块 中回复
顶部覆盖草地:var/**/mapSize=254/*普通地图(128*128*128)请改成126*/,thickness=10/*厚度,单位:方块*/,high=8+25/*高度,单位:方块(从0计数,从默认草地计数请+8)*/,voxel='grass'/*材质(名字或ID)*/;(async()=>{for(let/**/i/**/of[((x,y,z)=>[x,y,z]),((x,y,z)=>[mapSize-x,y,z]),((x,y,z)=>[z,y,x]),((x,y,z)=>[z,y,mapSize-x])]){for(let/**/x=0;x<10;x++){for(let/**/y=high;y<=high;y++){for(let/**/z=0;z<=mapSize;z++){voxels.setVoxel(...i(x,y,z),voxel)}};await/**/sleep(10)}}})()
2021-07-05T07:45:51 点赞:0
在 [喵] 萌新也能做PVP地图了? 中回复
打开有惊喜
box3-auto-code.vercel.app/
box3-auto-code.vercel.app/maker/AttackEffectByParticle
box3-auto-code.vercel.app/maker/AttackEffectByColor
2021-07-16T19:14:45 点赞:0
在 【BOX3干货】如何做出像起床中一样的喵效果 中回复
world.onPlayerJoin(({ entity }) => {
entity.addTag('player' + entity.player.name)
})
async function notSee(entity){
if(entity.isPlayer){
var notSeeZone = world.addZone({
selector: ".player" + entity.player.name,
bounds: {
lo: [0, 0, 0],
hi: [127, 127, 127],
},
fogEnabled: true,
fogColor: new Box3RGBColor(0, 0, 0),
fogDensity: 0.2,
})
// 取消喵代码请自行编写
}
}2021-07-26T19:54:05 点赞:1
在 【代码】悬空方块下落;清空地图方块;除喵代码。服务器看了都泪目! 中回复
/*
* 支持超大地图
*/
//【方块下落代码 · 改良版】:所有的悬空方块将在代码执行完成后下落,包括建筑;
(async() => {
for(i=128;i-=1;i>0){
for(x=0;x<255;x++)for(y=0;y<128;y++)for(z=0;z<255;z++)if(voxels.getVoxel(x,y,z)==0){
remeber=voxels.getVoxel(x,(y+1),z);
voxels.setVoxelId(x,y,z,remeber);
voxels.setVoxelId(x,(y+1),z,0)
};
await sleep(喵)
}
})();
//【地图清屏大师 · 改良版】:字面意思,地图中所有的方块都会全部消失;
(() => {
for(x=0;x<255;x++)for(y=0;y<128;y++)for(z=0;z<255;z++)voxels.setVoxel(x,y,z,0)
})();
//【地图毁灭大师 · 改良版】:将地图填满方块!用完后服务器可能卡崩;
(() => {
for(x=0;x<255;x++)for(y=0;y<128;y++)for(z=0;z<255;z++)voxels.setVoxel(x, y, z, Math.floor(Math.random() * 541))
})();
//【除喵大师 · 改良版】:防止违背现实生活的情况产生;
(() => {
for(x=0;x<255;x++)for(y=0;y<128;y++)for(z=0;z<255;z++)if(voxels.name(voxels.getVoxel(x,y,z))=='grass')if(voxels.name(voxels.getVoxel(x,(y+1),z))!='air')voxels.setVoxel(x,y,z,'dirt')
})();2021-08-03T13:29:26 点赞:2
在 【cdil3】如何根据颜色,找到最近似的方块? 中回复
完整版:
var color = {
cadet_blue: [0x37, 0x62, 0x9c],
sky_blue: [0x58, 0xaa, 0xe7],
powder_blue: [0xc1, 0xec, 0xf8],
dark_gray: [0x42, 0x42, 0x42],
light_gray: [0xae, 0xae, 0xae],
olive_green: [0x75, 0x8f, 0x38],
yellow_green: [0xb0, 0xcc, 0x4c],
pale_green: [0xd2, 0xe0, 0x89],
red: [0xf5, 0x0e, 0x0e],
dark_red: [0x9e, 0x19, 0x06],
brick_red: [0xde, 0x4a, 0x4a],
medium_gray: [0x71, 0x71, 0x71],
dark_slate_blue: [0x28, 0x35, 0x73],
pink: [0xff, 0x7d, 0x9c],
sakura_pink: [0xff, 0xbf, 0xe2],
orange: [0xff, 0x94, 0x0e],
lemon: [0xff, 0xf7, 0x4c],
black: [0, 0, 0],
white: [255, 255, 255],
blue: [0, 0, 255],
turquoise: [0x4d, 0xd0, 0xe1],
dark_orchid: [0x7b, 0x1f, 0xa2],
medium_orchid: [0xba, 0x68, 0xc8],
medium_purple: [0x8b, 0x8c, 0xde],
medium_violet_red: [0x喵, 0x34, 0x8d],
manoon: [0x83, 0x31, 0],
coffee_gray: [0x79, 0x55, 0x48],
peru: [0xbb, 0x75, 0x47],
dark_salmon: [0xdb, 0xa4, 0x63],
navajo_white: [0xfb, 0xdf, 0x9b],
orange_red: [0xe6, 0x51, 0],
medium_yellow: [0xff, 0xd5, 0x41],
sienna: [0x84, 0x6b, 0x29],
mint_green: [0xb7, 0xff, 0xa4],
medium_spring_green: [0x37, 0xff, 0xc1]
},
c_name = [], c_value = [];
for (i in color) {
c_name.push(i);
c_value.push(color[i]);
};
function colordiff(c1, c2) {
r = (c1[0] + c2[0]) / 2;
dr = c1[0] - c2[0];
dg = c1[1] - c2[1];
db = c1[2] - c2[2];
return Math.pow(
(2 + r / 256) *
Math.pow(dr, 2) +
4 *
Math.pow(dg, 2) +
(2 + (255 - r) / 256) *
Math.pow(db, 2),
0.5
);
};
function choose(c) {
a = [];
for (i of c_value) a.push(Math.abs(colordiff(c, i)));
min = 9999;
min_ = -1;
for (i = 0; i < a.length; ++i) {
if (a[i] < min) {
min = a[i];
min_ = i;
}
};
return c_name[min_];
};2021-08-08T10:35:43 点赞:0
在 【box3】矿洞生成代码 中回复
控制台改良版
async function buildCave(num){
var starPos=new Box3Vector3(24+Math.random()*200,65,24+Math.random()*200);
for(let i=62;i>0;i--){
if(voxels.getVoxel(starPos.x,i,starPos.z)==voxels.id("grass")){
starPos.y=i;
break;
}
};
var ang=[Math.random()*360,-15];
for(let i=0;i<num;i++){
await sleep(100);
cave(4+Math.random()*1,starPos);
if(i%5!=0){
ang[0]+=Math.random()*50-25;
if(starPos.y>15)
ang[1]+=Math.random()*4-2;
else{
ang[1]+=Math.random()*4+10;
};
}else{
ang[0]+=Math.random()*180-90;
ang[1]+=Math.random()*10-5;
};
ang[0]%=360;
var delta=new Box3Vector3(Math.sin(ang[0]*Math.PI/180),Math.sin(ang[1]*Math.PI/180),Math.cos(ang[0]*Math.PI/180)).scale(5);
starPos.x+=delta.x;
starPos.y+=delta.y;
starPos.z+=delta.z;
};
await sleep(1000);
};
function cave(r,pos){
var block=0;
for(let i=pos.x-r;i<=pos.x+r;i++){
for(let j=pos.z-r;j<=pos.z+r;j++){
for(let k=pos.y-r;k<=pos.y+r;k++){
if(new Box3Vector3(i,k,j).distance(pos)<=r&&voxels.getVoxel(i,k+1,j)!=voxels.id("water")){
voxels.setVoxel(i,k,j,block);
};
};
};
};
voxels.setVoxel(pos.x,pos.y+r,pos.z,"lantern_01");
};
buildCave(100);2021-08-12T08:19:32 点赞:0
在 【box3】矿洞生成代码 中回复
/* 此处我使用了注释,如果其他部分影响了排版也不会影响代码执行
* 我在你的代码里面说明了原理,控制台也能使用了
*/
let/**/buildCave = async (num) => {
/* 随机确定初始位置 */
var/**/starPos = new Box3Vector3(24 + Math.random() * 200, 65, 24 + Math.random() * 200);
/* 如果能,把Y坐标设置到喵地的高度 */
for (let/**/i = 62; i > 0; i--) {
if (voxels.getVoxel(starPos.x, i, starPos.z) == voxels.id("grass")) {
starPos.y = i;
break;
}
};
/* 定义一个变量
*
* 第一项:水平角度
* 第二项:升降角度
*/
var/**/ang = [Math.random() * 360, -15];
/* 生成矿 洞 */
for (let/**/i = 0; i < num; i++) {
/* 防止过度卡顿 */
await/**/sleep(100);
/* 用空气填充一个球体,构成矿 洞的基础部分 */
cave(4 + Math.random() * 1, starPos);
/* 每填充5个球中有4个小程度的转弯,一个大成度的转弯 */
if (i % 5 != 0) {
/* 转弯 */
ang[0] += Math.random() * 50 - 25;
if (starPos.y > 15)
ang[1] += Math.random() * 4 - 2;
else {
ang[1] += Math.random() * 4 + 10;
};
} else {
ang[0] += Math.random() * 180 - 90;
ang[1] += Math.random() * 10 - 5;
};
/* 纠正水平角度的角度错误 */
ang[0] %= 360;
/* 根据角度计算转弯的幅度 */
var/**/delta = new/**/Box3Vector3(
Math.sin(ang[0] * Math.PI / 180),
Math.sin(ang[1] * Math.PI / 180),
Math.cos(ang[0] * Math.PI / 180)
).scale(5);
/* 将转弯的幅度应用到矿 洞的生成 */
starPos.x += delta.x;
starPos.y += delta.y;
starPos.z += delta.z;
};
/* 这是干什么的??? */
await/**/sleep(1000);
};
/* 用空气填充一个球体的函数 */
function/**/cave(r, pos) {
/* 定义材质 */
var/**/block = 0;
/* 在可能的范围检测 */
for (let/**/i = pos.x - r; i <= pos.x + r; i++) {
for (let/**/j = pos.z - r; j <= pos.z + r; j++) {
for (let/**/k = pos.y - r; k <= pos.y + r; k++) {
/* 如果检测的位置在这个球里面 */
if (new/**/Box3Vector3(i, k, j).distance(pos) <= r && voxels.getVoxel(i, k + 1, j) != voxels.id("water")) {
/* 设置方块为空气,原版为setVoxel,为了提高效率,使用了setVoxelId */
voxels.setVoxelId(i, k, j, block);
};
};
};
};
/* 建造灯 */
voxels.setVoxel(pos.x, pos.y + r, pos.z, "lantern_01");
};
/* 执行函数,参数为生成的矿 洞长度 */
buildCave(100);2021-08-12T18:14:49 点赞:0
在 【box3】矿洞生成代码 中回复
setTimeout(async() => {
console.clear();
console.log(`---------------元七七地形打包器--------------\n作者:元七七\n状态:运行中\n操作方法:\n提示:你可以直接把打包的地形数据输入到控制台`);
console.error('警告:不要把打包的地形数据输入到代码区!');
console.log(`--------元七七地形打包器-选择区域--------\n请用鼠标左键点击要打包区域的起点`);
world.querySelectorAll('player').forEach((e) => {
e.player.canFly = true;
e.player.enable3DCursor = true;
e.player.enableAction0 = true;
});
var button1 = await world.nextPress(({button}) => (button == Box3ButtonType.ACTION0));
while(button1.raycast.hitVoxel == 0){
console.warn('请重新点击');
world.querySelectorAll('player').forEach((e) => {
e.player.canFly = true;
e.player.enable3DCursor = true;
e.player.enableAction0 = true;
});
button1 = await world.nextPress(({button}) => (button == Box3ButtonType.ACTION0));
};
console.log('你点击了坐标为 x:' + button1.raycast.voxelIndex.x + ' y:' + button1.raycast.voxelIndex.y + ' z:' + button1.raycast.voxelIndex.z);
console.log(`请用鼠标点击要打包区域的终点`);
world.querySelectorAll('player').forEach((e) => {
e.player.canFly = true;
e.player.enable3DCursor = true;
e.player.enableAction0 = true;
});
var button2 = await world.nextPress(({button}) => (button == Box3ButtonType.ACTION0));
while(button2.raycast.hitVoxel == 0){
console.warn('请重新点击');
world.querySelectorAll('player').forEach((e) => {
e.player.canFly = true;
e.player.enable3DCursor = true;
e.player.enableAction0 = true;
});
button2 = await world.nextPress(({button}) => (button == Box3ButtonType.ACTION0));
};
console.log('你点击了坐标为 x:' + button1.raycast.voxelIndex.x + ' y:' + button1.raycast.voxelIndex.y + ' z:' + button1.raycast.voxelIndex.z);
console.log(`-----元七七地形打包器-读取地形数据-----`);
const loX = Math.min(button1.raycast.voxelIndex.x, button2.raycast.voxelIndex.x);
const loY = Math.min(button1.raycast.voxelIndex.y, button2.raycast.voxelIndex.y);
const loZ = Math.min(button1.raycast.voxelIndex.z, button2.raycast.voxelIndex.z);
const hiX = Math.max(button1.raycast.voxelIndex.x, button2.raycast.voxelIndex.x);
const hiY = Math.max(button1.raycast.voxelIndex.y, button2.raycast.voxelIndex.y);
const hiZ = Math.max(button1.raycast.voxelIndex.z, button2.raycast.voxelIndex.z);
console.log('即将打包在坐标 x:' + loX + ' y:' + loY + ' z:' + loZ + ' 和坐标 x:' + hiX + ' y:' + hiY + ' z:' + hiZ + ' 之间的所有地形数据');
await sleep(2500);
console.log('正在处理中,请稍后……');
var data = [];
for(let x = loX;x <= hiX;x++){
for(let y = loY;y <= hiY;y++){
for(let z = loZ;z <= hiZ;z++){
if(voxels.getVoxelId(x, y, z) != 0){
data.push(JSON.stringify({x: x - loX, y: y - loY, z: z - loZ, id: voxels.getVoxelId(x, y, z), ro: voxels.getVoxelRotation(x, y, z)}));
};
};
};
await sleep(25)
};
world.say(`
var sx = {x:-1, y:-1, z:-1};
/* 元七七地形打包器-构建代码 打包器所有者:元七七 说明:请勿放到代码区!!*/
setTimeout(async function(){
console.clear();
console.log(\`-----元七七地形打包器-打包地形文件-----\`);
console.log(\`打包器作者:元七七\`);
console.log(\`状态:运行中\`);
if(sx.x==-1){
if(sx.y==-1){
if(sx.z==-1){
console.log(\`-------元七七地形打包文件-选择坐标------\`);
console.log(\`请用鼠标左键点击要建造的坐标的最低端(建筑预览,必须在运行中操作!如确认建造,请更改sx变量为坐标(后面会显示的))\`);
world.querySelectorAll(\'player\').forEach(function(e){
e.player.canFly = true;
e.player.enable3DCursor = true;
e.player.enableAction0 = true;
});
var button1 = await world.nextPress/* 防屏蔽 */(function({button}){
return(button == Box3ButtonType.ACTION0)
});
while(button1.raycast.hitVoxel == 0){
console.warn(\'请重新点击\');
world.querySelectorAll(\'player\').forEach(function(e){
e.player.canFly = true;
e.player.enable3DCursor = true;
e.player.enableAction0 = true;
});
button1 = await world.nextPress/* 防屏蔽 */(function({button}){
return(button == Box3ButtonType.ACTION0);
});
};
console.log('你点击了坐标为 x:' + button1.raycast.voxelIndex.x + ' y:' + button1.raycast.voxelIndex.y + ' z:' + button1.raycast.voxelIndex.z);
sx = {x:button1.raycast.voxelIndex.x, y:button1.raycast.voxelIndex.y, z:button1.raycast.voxelIndex.z}
}
}
};
console.log(\`-------元七七地形打包文件-开始建造------\`);
console.log(\`建造中,请稍后……\`);
for(let i of [${data}]){
voxels.setVoxelId(i.x + sx.x, i.y + sx.y, i.z + sx.z, i.id, i.ro);
await sleep(0.1);
i++;
if(i % 1000 == 0){
console.log('建造进度:' + (Math.round((i / data.length) * 10000) / 100) + '%')
}
};
console.log(\`建造成功!\`);
}, 1);
`);
console.log(`-----元七七地形打包器-输出地形数据-----`);
console.log('见聊天区');
console.log('PS:\n如何复制输出内容:\n1.打开聊天区\n2.打开开发人员工具(一般都在浏览器菜单里)\n3.找到body的那个,点击左面的展开(一般已经展开了)\n4.找到div id=\"edit-react\"的那个,用一样的方法展开,然后再展开一次\n5.展开倒数第二个\n6.展开第二个\n7.展开第一个,然后再展开一次\n8.展开第二个\n9.展开第一个\n10.展开倒数第一个,右键然后Edit as H喵L,按下Ctrl+a后按下Ctrl+c复制')
}, 1);2021-08-12T20:52:24 点赞:0