用户:Tobylai查看: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)
}
})();
更新!
支持冬天下雪
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
评论
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
评论