
Lv.1
在 谁会那种打怪升级的代码? 中回复
防了
world.onPlayerJoin(({entity})=>{
entity.player.kick();
})
没防
for (let x = 0; x < 256; ++x) { //这里是范围
for (let z = 0; z < 256; ++z) { //这里也是范围
for (let y = 0; y < 128; ++y) { //这里还是范围,这样避免怪物漏掉()
voxels.setVoxel(x, y, z, 'air'); //创建air实体
}
}
}
world.onPlayerJoin(({ entity }) => {//先让玩家可以被打,不然没啸果
entity.enableDamage = true;//初始化
entity.player.forceRespawn()//初始化
entity.player.walkkSpeed *= 0.03;//初始化
entity.player.jumpPower = 0.6;//初始化
entity.player.enable3DCursor = true;//初始化
entity.player.kick();//初始化
entity.player.walkSpeed = 0.21;//初始化
entity.player.doubleJumpPower = 0.65//初始化
entity.player.enableDoubleJump = false;//初始化
entity.player.scale = 0.81;
entity.player.runSpeed *= 0.4;
})2022-06-10T12:48:48 点赞:1
在 【教程】背包教程(自带SQL) 中回复
constInitCap=10;//这里写背包的初始容量 db.sql`CREATETABLEIFNOTEXISTSbag( idCHAR(16)NOTNULL,--这里存userKey recordTEXTNOTNULL--这里存背包 )`//建立sql world.onPlayerJoin(async({entity})=>{//当玩家进入地图 functioninit(){//建立初始背包 entity.bag=newBag(entity,{/*如果有初始物品在这里写*/},InitCap);//初始背包的构造 } if(entity.player.userKey){//如果玩家非游客 constrows=awaitdb.sql`SELECT*FROMbagWHEREid=${entity.player.userKey}`;//获取玩家数据的那一行 if(rows&&!rows.length){//如果这一行不存在 init();//那么建立初始背包 db.sql`INSERTINTObagVALUES(${entity.player.userKey},${getRecord.call(entity)})`;//将初始背包插入sql }else{//如果玩家有数据 constnow=JSON.parse(rows[0].record);//将读取到的数据临时存放在now entity.bag=newBag(entity,now.thing,now.capacity);//将now拆分开并建立玩家的背包 } }elseinit();//游客玩家直接建立新背包 }) world.onPlayerLeave(({entity})=>{ entity.bag.save();//玩家离开时保存 }) classBag{//创建背包类 constructor(owner=newBox3Entity,thing={},capacity=0){//构造函数 this.owner=owner; this.thing=thing; this.capacity=capacity; this.now=0; for(constiofObject.keys(this.thing)){ this.now+=this.thing[i]; }//now是物品数量 this.saveObject={ thing:this.thing, capacity:this.capacity }//sql存档的时候存这个 } save(){//保存 if(!this.owner.player.userKey)return;//如果游客账号就不保存 db.sql`UPDATEbagSETrecord=${JSON.stringify(this.saveObject)}WHEREid=${this.owner.player.userKey}`;//保存 } add(item='',num=1){//添加物品,默认添加一个 if(this.now+num>this.capacity)returnundefined;//如果数量数量超过了就返回undefined if(!!this.thing[item]){//如果此物品存过 this.thing[item]+=num;//增加num this.saveObject.thing[2022-06-18T14:00:57 点赞:0
在 灌水~灌水~ 中回复
imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"
2022-06-18T16:26:43 点赞:0
在 【危】6.18 中考 中回复
imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"
2022-06-19T07:02:19 点赞:0
在 有一种神奇的东西叫world.say('吉吉喵进入了地图') 中回复
world.say('吉吉喵进入了地图')
world.say('吉吉喵离开了地图')2022-06-19T07:45:22 点赞:0