用户:
HC洛天依查看:18 回复:11 评论:18 创建时间:2020-05-13T18:27:41
就是这样,如下图。还有本来应该是这样子的。编程猫跟我说清楚。
world.command=world.createEntity()
world.command.id='命令'
function runCmd(cmd){
w=cmd.split(' ')
if(w[0]=='/kill'){
finder=0
world.querySelectorAll('player').forEach((m)=>{if(m.player.name==w[1]){finder=m}})
if(!finder==0){finder.hurt(finder.hp,{attacker:world.command,});world.say(`玩家 ${w[1]} 已被击杀`)}
else{world.say(`ERROR:NO PLAYER NAMED ${w[1]}`)}
}else if(w[0]=='/hurt'){
finder=0
world.querySelectorAll('player').forEach((m)=>{if(m.player.name==w[1]){finder=m}})
try{
if(!finder==0){finder.hurt(parseInt(w[2]),{attacker:world.command,});world.say(`玩家 ${w[1]} 已被伤害`)}else{world.say(`ERROR:NO PLAYER NAMED ${w[1]}`)}}catch{world.say('ERROR:Fail')}
}else if(w[0]=='/hp'){
finder=0
world.querySelectorAll('player').forEach((m)=>{if(m.player.name==w[1]){finder=m}})
try{
if(!finder==0){finder.hp=parseInt(w[2]);world.say(`玩家 ${w[1]} 血量已设置`)}else{world.say(`ERROR:NO PLAYER NAMED ${w[1]}`)}}catch{world.say('ERROR:Fail')}
}else if(w[0]=='/tpto'){
finder3=0
world.querySelectorAll('*').forEach((m)=>{
if(m.isPlayer){ if(m.player.name==w[1]){finder3=m}}
else if(m.id==w[1]){finder3=m}
})
finder4=0
world.querySelectorAll('*').forEach((m)=>{
if(m.isPlayer){ if(m.player.name==w[2]){finder4=m}}
else if(m.id==w[2]){finder4=m}
})
if(!finder3==0){
try{finder3.position.set(finder4.position.x,finder4.position.y+5,finder4.position.z)
}catch{world.say('ERROR:Fail');return};
world.say(`玩家 ${w[1]} 已被传送`)
}
else{world.say(`ERROR:NO PLAYER NAMED ${w[1]}`)}
}else{
world.say(`ERROR:NO COMMAD CALLED "${w[0]}"`)
}
}
点赞0
评论