猫史档案馆


【box3代码】季节变换

用户:TobylaiTobylai查看:5 回复:15 评论:5 创建时间:2020-09-13T11:18:13


const seasons=['春','夏','秋','冬'];
const Springleaf='green_leaf';const Summerleaf='leaf_05';const Fallleaf='leaf_03';const Winterleaf='winter_leaf'
const grass=['grass','dark_grass','yellow_grass','white_grass']
async function replaceblock(a,b){for(y=0;y<128;y++){for(x=0;x<128;x++){for(z=0;z<128;z++){if(voxels.getVoxel(x,y,z)==voxels.id(a)){voxels.setVoxel(x,y,z,voxels.id(b))}}}}}
const time=2*1000;//这个2是每个季节隔几秒
(async function changeseason(){
    while(true){
        replaceblock(Winterleaf,Springleaf);replaceblock(grass[3],grass[0]);world.say(seasons[0]+'天到了');
        await sleep(time);
        replaceblock(Springleaf,Summerleaf);replaceblock(grass[0],grass[1]);world.say(seasons[1]+'天到了');
        await sleep(time);
        replaceblock(Summerleaf,Fallleaf);replaceblock(grass[1],grass[2]);world.say(seasons[2]+'天到了');
        await sleep(time);
        replaceblock(Fallleaf,Winterleaf);replaceblock(grass[2],grass[3]);world.say(seasons[3]+'天到了');
        await sleep(time)
    }
})();

体验地址:https://box3create.codemao.cn/games/e6f55634f01e58a15b4d?p=0OzP8q0K17HLqIhXVm4gQ%2BbCKRiH%2B5Tn%2Fkpghux%2BV4A4Go11TILgVndWVzdA%3D%3D


回复

上一页1 页 / 共 1下一页
该账号已停用该账号已停用

emotion_编程猫_点赞emotion_编程猫_加油emotion_编程猫_厉害了

点赞0


评论


_Rise__Rise_

dd

点赞0


评论


白篮白篮

emotion_编程猫_点赞

点赞0


评论


TobylaiTobylai

更新!

支持冬天下雪

const seasons=['春','夏','秋','冬'];
const Springleaf='green_leaf';const Summerleaf='leaf_05';const Fallleaf='leaf_03';const Winterleaf='winter_leaf'
const grass=['grass','dark_grass','yellow_grass','white_grass']
asy喵 fu喵tion replaceblock(a,b){for(y=0;y<128;y++){for(x=0;x<128;x++){for(z=0;z<128;z++){if(voxels.getVoxel(x,y,z)==voxels.id(a)){voxels.setVoxel(x,y,z,voxels.id(b))}}}}}
const time=4*1000;//这个2是每个季节隔几秒
(asy喵 fu喵tion changeseason(){
    while(true){
        world.snowSizeLo = 0;                                    // 最小直径
        world.snowSizeHi = 0;  
        replaceblock(Winterleaf,Springleaf);replaceblock(grass[3],grass[0]);world.say(seasons[0]+'天到了');
        await sleep(time);
        replaceblock(Springleaf,Summerleaf);replaceblock(grass[0],grass[1]);world.say(seasons[1]+'天到了');
        await sleep(time);
        replaceblock(Summerleaf,Fallleaf);replaceblock(grass[1],grass[2]);world.say(seasons[2]+'天到了');
        await sleep(time);
        replaceblock(Fallleaf,Winterleaf);replaceblock(grass[2],grass[3]);world.say(seasons[3]+'天到了');
        /* 雪 */
        world.snowDensity = 0.4;                                   // 雪的密度
        world.snowFallSpeed = 0.3;                                 // 下落速度
        world.snowSizeLo = 0.3;                                    // 最小直径
        world.snowSizeHi = 0.6;                                   // 最大直径
        world.snowColor = new Box3RGBAColor(1, 1, 1, 1);   // 颜色
        world.snowTexture = 'snow/snow.part';                    // 纹理
        await sleep(time)
    }
})();

解决“喵”的办法

在编辑器里,粘贴代码,按下ctrl+h,第一个框写“喵”,第二个写“nc”,然后按第二个框旁边的第二个按钮

点赞1


评论


lon江航lon江航

emotion_编程猫_点赞

点赞0


评论


TobylaiTobylai

az

点赞0


评论


Architect_皮卡awaArchitect_皮卡awa

emotion_编程猫_加油emotion_编程猫_点赞emotion_编程猫_厉害了emotion_编程猫_嗨起来emotion_雷电猴_嗯嗯

点赞0


评论


yuansyuans

let seasonDuration = 1000 * 20  // 单位是毫秒:3秒 = 3000 毫秒
async function seasonChange(){
    while(true){
        world.say('春季来临')
        world.snowTexture = 'snow/0.part'
        world.sound('audio/chat.mp3')
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('winter_leaf')){                     voxels.setVoxel(x,y,z,voxels.id('green_leaf'))                 }              }         }     } 
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('snow')){                     voxels.setVoxel(x,y,z,voxels.id('sand'))                 }              }         }     } 
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('ice')){                     voxels.setVoxel(x,y,z,voxels.id('water'))                 }              }         }     } 
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('white_grass')){                     voxels.setVoxel(x,y,z,voxels.id('grass'))                 }              }         }     } 
        await sleep(seasonDuration/2)
        world.say('夏季来临')
        world.sound('audio/chat.mp3')
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('grass')){                      voxels.setVoxel(x,y,z,voxels.id('dark_grass'))                 }             }         }     }
        await sleep(seasonDuration)
        world.say('秋季来临')
        world.sound('audio/chat.mp3')
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('green_leaf')){                     voxels.setVoxel(x,y,z,voxels.id('leaf_04'))                 }              }         }     } 
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('dark_grass')){                     voxels.setVoxel(x,y,z,voxels.id('yellow_grass'))                 }             }         }     }
        await sleep(seasonDuration-1000)
        world.say('冬季来临')
        world.sound('audio/chat.mp3')
        world.snowDensity = 0.4;                                   // 雪的密度
        world.snowFallSpeed = 0.3;                                 // 下落速度
        world.snowSizeLo = 0.3;                                    // 最小直径
        world.snowSizeHi = 0.6;                                   // 最大直径
        world.snowColor = new Box3RGBAColor(1, 1, 1, 1);   // 颜色
        world.snowTexture = 'snow/snow.part';                    // 纹理
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('yellow_grass')){                     voxels.setVoxel(x,y,z,voxels.id('white_grass'))                 }              }         }     } 
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('water')){                     voxels.setVoxel(x,y,z,voxels.id('ice'))                 }              }         }     } 
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('leaf_04')){   voxels.setVoxel(x,y,z,voxels.id('winter_leaf'))                 }              }         }     }                          
        for(y=0;y<128;y++){         for(x=0;x<128;x++){             for(z=0;z<128;z++){                 if(voxels.getVoxel(x,y,z)==voxels.id('sand')){                     voxels.setVoxel(x,y,z,voxels.id('snow'))                 }              }         }     } 
        await sleep(seasonDuration+1000)
        world.say('一年过去啦 等春天吧')
        world.sound('audio/chat.mp3')
        await sleep(seasonDuration/2)
    }
}

seasonChange() // 调用方法(使用seasonChange定义函数设置方案)我也要抄下来哦~

点赞0


评论


ZNS_哪吒ZNS_哪吒

dd

点赞0


评论


哦那咋了哦那咋了

emotion_编程猫_点赞

点赞0


评论


阳光的流熔怪Uyt5阳光的流熔怪Uyt5

点赞0


评论


难起的名字难起的名字

emotion_编程猫_点赞

点赞0


评论


IaeaIaea

666

点赞0


评论


DRboxesDRboxes

问一下,如何判断现实世界的时间?

点赞1


评论


难起的名字难起的名字

6?

点赞0


评论