用户:Fliere_tammy查看:10 回复:10 评论:10 创建时间:2020-06-02T12:32:57
1.pvp代码
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true;
entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {
if (button !== 'action0' || !hitEntity) {
return;
}
hitEntity.velocity.x += direction.x;
hitEntity.velocity.y += 0.5;
hitEntity.velocity.z += direction.z;
hitEntity.hurt(20 * Math.random() + 5, {
attacker: entity,
});
});
});
world.onDie(({ entity, attacker }) => {
if (attacker) {
world.say(attacker.player.name + ' killed ' + entity.player.name)
}
entity.player.forceRespawn();
});
2.$执行代码
world.onChat(({entity,message})=>{
if(entity&&['管喵名字'].indexOf(entity.player.name)!=-1&&message.charAt(0)=='$'){
try{
world.say('<~ '+eval(message.split('$')[1]))}catch(err){
world.say('Error:'+err)
}
};
3.回血代码
world.onPress(({button,entity})=>{
if(button=='crouch'){
if(entity.hp>=300){
return;
}
entity.hp+=10;
}
})
4.发光代码
world.querySelectorAll('player').forEach((x) => {if (x.player.name == "Tammy_fliere_小号") {x.player.emissive = 2}});
5.玩家的大小
world.querySelectorAll('player').forEach((x) => {if (x.player.name == "Tammy_fliere_小号") {x.player.scale = 20}})
4.5.3.都是可以改数值的