用户:
13661555450查看:323 回复:6 评论:36 创建时间:2022-08-19T14:55:08
右键放置,左键点燃,使用记得导入模型,诸位听我一句劝:”此物威力甚大,请谨慎使用“
由23332808编写
async function tnt(x,y,z){
const e=world.createEntity({
mesh:"mesh/TNT.vb",
meshScale:[1/16,1/16,1/16],
collides:true,
gravity:false,
friction:1.5,
position:[x,y,z],
})
e.enableDamage=true
e.fixed=true
e.maxHp=1
e.hp=1
e.addTag("TNT")
e.showHealthBar=false
e.onTakeDamage(async()=>{e.enableDamage=false
e.gravity=true
e.fixed=false
for(i=0;i<3;i++){
e.meshEmissive = 1
await sleep(500)
e.meshEmissive = 0
await sleep(500)}
const bounds = new Box3Bounds3(new Box3Vector3(e.position.x-4,e.position.y-4,e.position.z-4), new Box3Vector3(e.position.x+4,e.position.y+4,e.position.z+4))
world.searchBox(bounds).forEach((entityInBounds) => {
entityInBounds.hurt(10,{attacker:"TNT"})
var direction = entityInBounds.position.sub(e.position)
if(direction.x>0){entityInBounds.velocity.x+=1}else{entityInBounds.velocity.x-=1}
if(direction.y>0){entityInBounds.velocity.y+=1}else{entityInBounds.velocity.y-=1}
if(direction.z>0){entityInBounds.velocity.z+=1}else{entityInBounds.velocity.z-=1}
})
sphere("air",e.position.x,e.position.y,e.position.z,3)
e.destroy()})}
world. onPress(({button, raycast: { voxelIndex, normal}}) =>{
if (button == Box3ButtonType.ACTION1){
let v = voxelIndex.add(normal)
tnt(Math.round(v.x)+0.5,v.y+0.5,Math.round(v.z)+0.5)}})
world.onclick(({entity,button})=>{
if(entity.hasTag("TNT")&&button=="action1){
entity.hurt(1)
})
145安全大脑提示您:请勿随意尝喵坛中来源非官方的代码!此代码安全等级为:潜在危险
点赞0
评论
此物品安全等级为:危险
你是个人才
路卡提醒您,请勿随意相信145安全大脑的任何信息!此信息安全等级为:不可信
。你们这是怼上了
Star提醒您,请勿随意相信路卡的任何信息!此信息安全等级为:未侦测安全,未知,实体横行(划掉)
电电提醒您,请勿相信star的任何信息!否则我们无法保证你的安全!
派对客提醒您,请勿相信电电的任何信息!一起来开派对吧 =)
=(
有图我可以帮忙吗
你还活着!喆都给我首页了,你还不给?
论两个预言家
我不可能死
既然没死还不快给()
给啥
AB骉Alobok我的报错:
作者你看看哪里错了 代码:
点赞0
评论
(就这个)
可能复制的时候出问题了,你在action1后加一个双引号
需要改的太多,我发一个改进版帖子,行吗
只有亿点点要改
还是
那个括号有问题
(地下的)
没事,我自己改一下
async function tnt(x,y,z){
const e=world.createEntity({
mesh:"mesh/TNT.vb",
meshScale:[1/16,1/16,1/16],
collides:true,
gravity:false,
friction:1.5,
position:[x,y,z],
})
e.enableDamage=true
e.fixed=true
e.maxHp=1
e.hp=1
e.addTag("TNT")
e.showHealthBar=false
e.onTakeDamage(async()=>{e.enableDamage=false
e.gravity=true
e.fixed=false
for(i=0;i<3;i++){
e.meshEmissive = 1
await sleep(500)
e.meshEmissive = 0
await sleep(500)}
const bounds = new Box3Bounds3(new Box3Vector3(e.position.x-4,e.position.y-4,e.position.z-4), new Box3Vector3(e.position.x+4,e.position.y+4,e.position.z+4))
world.searchBox(bounds).forEach((entityInBounds) => {
entityInBounds.hurt(10,{attacker:"TNT"})
var direction = entityInBounds.position.sub(e.position)
if(direction.x>0){entityInBounds.velocity.x+=1}else{entityInBounds.velocity.x-=1}
if(direction.y>0){entityInBounds.velocity.y+=1}else{entityInBounds.velocity.y-=1}
if(direction.z>0){entityInBounds.velocity.z+=1}else{entityInBounds.velocity.z-=1}
})
sphere("air",e.position.x,e.position.y,e.position.z,3)
e.destroy()})}
world. onPress(({button, raycast: { voxelIndex, normal}}) =>{
if (button == Box3ButtonType.ACTION1){
let v = voxelIndex.add(normal)
tnt(Math.round(v.x)+0.5,v.y+0.5,Math.round(v.z)+0.5)}})
world.onClick(({entity,button})=>{
if(entity.hasTag("TNT")&&button=="action1"){
entity.hurt(1)
}})
function sphere(vox, cx, cy, cz, radius){
let xend = cx+radius
let yend = cy+radius
let zend = cz+radius
for(let x=cx-radius;x<=xend;x++){
for(let y=cy-radius;y<=yend;y++){
for(let z=cz-radius;z<=zend;z++){
let dx = x-cx;
let dy = y-cy;
let dz = z-cz;
if(Math.round(Math.sqrt(dx*dx+dy*dy+dz*dz)) <= radius){
voxels.setVoxel(x,y,z,vox)
}
}}}
}点赞0
评论
介个亚子就没问题了
众所周知,attacker的类型是Box3Entity.......
不影响,不影响
但是还是报错……
不是,我都测试过了,没毛病啊?
……
可能你多打了一个}
没有啊
……
报错拿来