用户:
YDS尹子查看:15 回复:15 评论:15 创建时间:2020-07-09T07:43:36
这次需要填写的只有user,就是你的名字。
注意事项:
1.通过在聊天区输入“%方块名”的形式设置填充方块,例如“%white”
1.1如果输入不存在的方块名,系统会告诉你的,所以不用担心~
2.右键方块设置起始点,这次没有坐标大小的问题
var user="YDS尹子";
var start={x:0,y:0,z:0};
var end={x:0,y:0,z:0};
var block="white";
function reorder(){
if(start.x>end.x){
var a=start.x;start.x=end.x;end.x=a;
}
if(start.y>end.y){
var a=start.y;start.y=end.y;end.y=a;
}
if(start.z>end.z){
var a=start.z;start.z=end.z;end.z=a;
}
}
function fill(block){
for(let i=start.x;i<=end.x;i++){for(let j=start.z;j<=end.z;j++){for(let k=start.y;k<=end.y;k++){
voxels.setVoxel(i,k,j,block);
}}}
}
world.onPlayerJoin(({entity})=>{
entity.player.build=0;
})
world.onChat(({entity,message})=>{
if(entity.player.name==user){
if(message.charAt(0)=="%"){
block=message.split('%')[1];
if(block!="air"&&voxels.id(block)==0){
world.say("The block does not exist.\nPlease choose again.");
block="white";
}else{
world.say("fill block set.")
block=block;
}
}
}
})
world.click=world.onPress(({button,entity,raycast:{voxelIndex}})=>{
if(button=="action1"&&entity.player.name==user){
if(entity.player.build==0){
start={x:voxelIndex.x,y:voxelIndex.y,z:voxelIndex.z};
entity.player.build=1;
world.say("start position set")
}else if(entity.player.build==1){
end={x:voxelIndex.x,y:voxelIndex.y,z:voxelIndex.z};
entity.player.build=0;
reorder();
world.say("end position set\nfill started.\nfilled with "+block+".")
fill(block);
world.say("fill ended.")
}
}
voxels.setVoxel(start.x,start.y,start.z,block);
voxels.setVoxel(end.x,end.y,end.z,block);
})
2020/7/9 7:36
YDS尹子升级版:可以给多人使用权限
暂时无法在控制台运行
教程:http://www.yxtnt.cn/img/fill.mp4
var user=["ZNS卿本尊","YDS尹子"];
var start={x:0,y:0,z:0};
var end={x:0,y:0,z:0};
var block="white";
function reorder(){
if(start.x>end.x){
var a=start.x;start.x=end.x;end.x=a;
}
if(start.y>end.y){
var a=start.y;start.y=end.y;end.y=a;
}
if(start.z>end.z){
var a=start.z;start.z=end.z;end.z=a;
}
}
function fill(block){
for(let i=start.x;i<=end.x;i++){for(let j=start.z;j<=end.z;j++){for(let k=start.y;k<=end.y;k++){
voxels.setVoxel(i,k,j,block);
}}}
}
world.onPlayerJoin(({entity})=>{
entity.player.build=0;
})
//我是分界线
world.onChat(({entity,message})=>{
if(user.indexOf(entity.player.name)!=-1){
if(message.charAt(0)=="%"){
block=message.split('%')[1];
if(block!="air"&&voxels.id(block)==0){
world.say("The block does not exist.\nPlease choose again.");
block="white";
}else{
world.say("fill block set.");
block=block;
}
}
}
})
//我是分界线
world.click=world.onPress(({button,entity,raycast:{voxelIndex}})=>{
if(button=="action1"&&user.indexOf(entity.player.name)!=-1){
if(entity.player.build==0){
start={x:voxelIndex.x,y:voxelIndex.y,z:voxelIndex.z};
entity.player.build=1;
world.say("start position set:");
}else if(entity.player.build==1){
end={x:voxelIndex.x,y:voxelIndex.y,z:voxelIndex.z};
entity.player.build=0;
reorder();
world.say("end position set\nfill started.\nfilled with "+block+".");
fill(block);
world.say("fill ended.");
}
}
})点赞0
评论