
Lv.1
一个普通的编程小白
签名:阿巴阿巴阿巴 这年头谁在社区混() 快来你岛
在 【求助】双斜杠 中回复
还有一个补充一下
~> const a=/a/;a
<~ /a/
这是什么牛马啊啊啊对象不是因该返回[Object object]吗????
2022-05-20T15:34:10 点赞:0
在 【地图招聘】马云编程猫招人一起做图了,有兴趣的快来看看吧!!! 中回复
萌新大佬_两年半_代码师_https://box3.codemao.cn/u/mxdlorzorz地下城通过了,俩超1k,带一个呗
2022-05-27T09:18:32 点赞:0
在 【水】岛三的案子-2 中回复
————————————————————————密封线———————————————————————— 上一期(https://shequ.cod喵/community/463184)的答案是: 我,跟尹子聊天的时候起了冲突,我开了他的enableDamage并让他hurt了100,并抢走了他的头套。尹子死后不甘心,于是假装红色方块流了一地。 那么这一期也同样是一个很水的案子,大家不妨来看看 尹子竟然消失了! 可以看见,聊天框里有尹子,但是我们却看不见他! 嫌疑人1:SKQA路卡_把名玩没了 口供:我只不过在挂机而已,而且编程猫皮肤我也有,干啥惦记着尹子啊? 嫌疑人2:萌新大佬 口供:尹子变消失了,对我也没好处啊,而且我像是会干那种事的人吗?我当时就是在和尹子讨论代码,切了一下屏,尹子就消失了! 嫌疑人3:Kindheit 口供:我就是个大建筑屑啊!我连代码都不会,甚至都没有控制台权限,怎么可能干这种事! 大家来猜一猜谁是罪魁祸首吧!有能力者可以尝试一下复原作案代码
2022-06-01T16:07:51 点赞:0
在 【教程】背包教程(自带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[item]+=num;//保存对象也要同步 }else{//如果没存过 this.thing[item]=num;//直接赋值 this.saveObject.thing[item]=num;//直接赋值 } this.now+=num;//物品的数量也要喵回物品数量 } del(item='',num=1){//删除物品,默认减少一个 if(!this.thing[item])returnNaN;//如果此物品不存在直接返回NaN(NotaNumber) if(this.thing[item]<num)returnundefined;//如果不够减就返回undefuned this.thing[item]-=num;//减去相应的量 this.saveObject.thing[item]-=num;//同步保存对象 this.now-=num;//当前物品数也要减 returnthis.thing[item];//返回数量 } setCap(cap=0){//设置容量 if(cap<this.now)returnundefined;//如果背包里的物品比目标容量多则返回undefiend this.capacity=cap;//直接设置容量 returnthis.capacity;//返回值 } asyncshow(){//对玩家展示背包 varop=[]; for(constiofObject.keys(this.thing)){ op.push(`${i}×${this.thing[i]}`); }//将物品×数量放进选项列表 constp=awaitthis.owner.player.dialog({//建立对话框 type:Box3DialogType.SELECT, title:'背包',//具体细节如标题,内容等自己改 content:'以下是你的背包', options:op, }); returnthis.thing[Object.keys(this.thing)[op.indexOf(p)]];//返回选择了的物品 } } 代码👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆
2022-06-02T11:56:03 点赞:0
在 【教程】背包教程(自带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[item]+=num;//保存对象也要同步 }else{//如果没存过 this.thing[item]=num;//直接赋值 this.saveObject.thing[item]=num;//直接赋值 } this.now+=num;//物品的数量也要喵回物品数量 } del(item='',num=1){//删除物品,默认减少一个 if(!this.thing[item])returnNaN;//如果此物品不存在直接返回NaN(NotaNumber) if(this.thing[item]<num)returnundefined;//如果不够减就返回undefuned this.thing[item]-=num;//减去相应的量 this.saveObject.thing[item]-=num;//同步保存对象 this.now-=num;//当前物品数也要减 returnthis.thing[item];//返回数量 } setCap(cap=0){//设置容量 if(cap<this.now)returnundefined;//如果背包里的物品比目标容量多则返回undefiend this.capacity=cap;//直接设置容量 returnthis.capacity;//返回值 } asyncshow(){//对玩家展示背包 varop=[]; for(constiofObject.keys(this.thing)){ op.push(`${i}×${this.thing[i]}`); }//将物品×数量放进选项列表 constp=awaitthis.owner.player.dialog({//建立对话框 type:Box3DialogType.SELECT, title:'背包',//具体细节如标题,内容等自己改 content:'以下是你的背包', options:op, }); returnthis.thing[Object.keys(this.thing)[op.indexOf(p)]];//返回选择了的物品 } }
2022-06-02T11:56:41 点赞:0
在 【教程】背包教程(自带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[item]+=num;//保存对象也要同步 }else{//如果没存过 this.thing[item]=num;//直接赋值 this.saveObject.thing[item]=num;//直接赋值 } this.now+=num;//物品的数量也要喵回物品数量 } del(item='',num=1){//删除物品,默认减少一个 if(!this.thing[item])returnNaN;//如果此物品不存在直接返回NaN(NotaNumber) if(this.thing[item]<num)returnundefined;//如果不够减就返回undefuned this.thing[item]-=num;//减去相应的量 this.saveObject.thing[item]-=num;//同步保存对象 this.now-=num;//当前物品数也要减 returnthis.thing[item];//返回数量 } setCap(cap=0){//设置容量 if(cap<this.now)returnundefined;//如果背包里的物品比目标容量多则返回undefiend this.capacity=cap;//直接设置容量 returnthis.capacity;//返回值 } asyncshow(){//对玩家展示背包 varop=[]; for(constiofObject.keys(this.thing)){ op.push(`${i}×${this.thing[i]}`); }//将物品×数量放进选项列表 constp=awaitthis.owner.player.dialog({//建立对话框 type:Box3DialogType.SELECT, title:'背包',//具体细节如标题,内容等自己改 content:'以下是你的背包', options:op, }); returnthis.thing[Object.keys(this.thing)[op.indexOf(p)]];//返回选择了的物品 } }
2022-06-02T11:58:09 点赞:0
在 【教程】背包教程(自带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[item]+=num;//保存对象也要同步 }else{//如果没存过 this.thing[item]=num;//直接赋值 this.saveObject.thing[item]=num;//直接赋值 } this.now+=num;//物品的数量也要喵回物品数量 } del(item='',num=1){//删除物品,默认减少一个 if(!this.thing[item])returnNaN;//如果此物品不存在直接返回NaN(NotaNumber) if(this.thing[item]<num)returnundefined;//如果不够减就返回undefuned this.thing[item]-=num;//减去相应的量 this.saveObject.thing[item]-=num;//同步保存对象 this.now-=num;//当前物品数也要减 returnthis.thing[item];//返回数量 } setCap(cap=0){//设置容量 if(cap<this.now)returnundefined;//如果背包里的物品比目标容量多则返回undefiend this.capacity=cap;//直接设置容量 returnthis.capacity;//返回值 } asyncshow(){//对玩家展示背包 varop=[]; for(constiofObject.keys(this.thing)){ op.push(`${i}×${this.thing[i]}`); }//将物品×数量放进选项列表 constp=awaitthis.owner.player.dialog({//建立对话框 type:Box3DialogType.SELECT, title:'背包',//具体细节如标题,内容等自己改 content:'以下是你的背包', options:op, }); returnthis.thing[Object.keys(this.thing)[op.indexOf(p)]];//返回选择了的物品 } }
2022-06-02T11:59:17 点赞:0
在 【教程】背包教程(自带SQL) 中回复
c喵tInitCap=10;//这里写背包的初始容量 db.sql`CREATETABLEIFNOTEXISTSbag( idCHAR(16)NOTNULL,--这里存userKey recordTEXTNOTNULL--这里存背包 )`//建立sql world.onPlayerJoin(async({entity})=>{//当玩家进入地图 functioninit(){//建立初始背包 entity.bag=newBag(entity,{/*如果有初始物品在这里写*/},InitCap);//初始背包的构造 } if(entity.player.userKey){//如果玩家非游客 c喵trows=awaitdb.sql`SELECT*FROMbagWHEREid=${entity.player.userKey}`;//获取玩家数据的那一行 if(rows&&!rows.length){//如果这一行不存在 init();//那么建立初始背包 db.sql`INSERTINTObagVALUES(${entity.player.userKey},${getRecord.call(entity)})`;//将初始背包插入sql }else{//如果玩家有数据 c喵tnow=JSON.parse(rows[0].record);//将读取到的数据临时存放在now entity.bag=newBag(entity,now.thing,now.capacity);//将now拆分开并建立玩家的背包 } }elseinit();//游客玩家直接建立新背包 }) world.onPlayerLeave(({entity})=>{ entity.bag.save();//玩家离开时保存 }) classBag{//创建背包类 c喵tructor(owner=newBox3Entity,thing={},capacity=0){//构造函数 this.owner=owner; this.thing=thing; this.capacity=capacity; this.now=0; for(c喵tiofObject.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[item]+=num;//保存对象也要同步 }else{//如果没存过 this.thing[item]=num;//直接赋值 this.saveObject.thing[item]=num;//直接赋值 } this.now+=num;//物品的数量也要加 returnthis.thing[item];//返回物品数量 } del(item='',num=1){//删除物品,默认减少一个 if(!this.thing[item])returnNaN;//如果此物品不存在直接返回NaN(NotaNumber) if(this.thing[item]<num)returnundefined;//如果不够减就返回undefuned this.thing[item]-=num;//减去相应的量 this.saveObject.thing[item]-=num;//同步保存对象 this.now-=num;//当前物品数也要减 returnthis.thing[item];//返回数量 } setCap(cap=0){//设置容量 if(cap<this.now)returnundefined;//如果背包里的物品比目标容量多则返回undefiend this.capacity=cap;//直接设置容量 returnthis.capacity;//返回值 } asyncshow(){//对玩家展示背包 varop=[]; for(c喵tiofObject.keys(this.thing)){ op.push(`${i}×${this.thing[i]}`); }//将物品×数量放进选项列表 c喵tp=awaitthis.owner.player.dialog({//建立对话框 type:Box3DialogType.SELECT, title:'背包',//具体细节如标题,内容等自己改 content:'以下是你的背包', opti喵:op, }); returnthis.thing[Object.keys(this.thing)[op.indexOf(p)]];//返回选择了的物品 } }
2022-06-02T12:00:42 点赞:0
在 【教程】背包教程(自带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[item]+=num;//保存对象也要同步 }else{//如果没存过 this.thing[item]=num;//直接赋值 this.saveObject.thing[item]=num;//直接赋值 } this.now+=num;//物品的数量也要加 returnthis.thing[item];//返回物品数量 } del(item='',num=1){//删除物品,默认减少一个 if(!this.thing[item])returnNaN;//如果此物品不存在直接返回NaN(NotaNumber) if(this.thing[item]<num)returnundefined;//如果不够减就返回undefuned this.thing[item]-=num;//减去相应的量 this.saveObject.thing[item]-=num;//同步保存对象 this.now-=num;//当前物品数也要减 returnthis.thing[item];//返回数量 } setCap(cap=0){//设置容量 if(cap<this.now)returnundefined;//如果背包里的物品比目标容量多则返回undefiend this.capacity=cap;//直接设置容量 returnthis.capacity;//返回值 } asyncshow(){//对玩家展示背包 varop=[]; for(constiofObject.keys(this.thing)){ op.push(`${i}×${this.thing[i]}`); }//将物品×数量放进选项列表 constp=awaitthis.owner.player.dialog({//建立对话框 type:Box3DialogType.SELECT, title:'背包',//具体细节如标题,内容等自己改 content:'以下是你的背包', options:op, }); returnthis.thing[Object.keys(this.thing)[op.indexOf(p)]];//返回选择了的物品 } }
2022-06-03T09:50:20 点赞:0
在 【教程】背包教程(自带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[item]+=num;//保存对象也要同步 }else{//如果没存过 this.thing[item]=num;//直接赋值 this.saveObject.thing[item]=num;//直接赋值 } this.now+=num;//物品的数量也要加 returnthis.thing[item];//返回物品数量 } del(item='',num=1){//删除物品,默认减少一个 if(!this.thing[item])returnNaN;//如果此物品不存在直接返回NaN(NotaNumber) if(this.thing[item]<num)returnundefined;//如果不够减就返回undefuned this.thing[item]-=num;//减去相应的量 this.saveObject.thing[item]-=num;//同步保存对象 this.now-=num;//当前物品数也要减 returnthis.thing[item];//返回数量 } setCap(cap=0){//设置容量 if(cap<this.now)returnundefined;//如果背包里的物品比目标容量多则返回undefiend this.capacity=cap;//直接设置容量 returnthis.capacity;//返回值 } asyncshow(){//对玩家展示背包 varop=[]; for(constiofObject.keys(this.thing)){ op.push(`${i}×${this.thing[i]}`); }//将物品×数量放进选项列表 constp=awaitthis.owner.player.dialog({//建立对话框 type:Box3DialogType.SELECT, title:'背包',//具体细节如标题,内容等自己改 content:'以下是你的背包', options:op, }); returnthis.thing[Object.keys(this.thing)[op.indexOf(p)]];//返回选择了的物品 } }
2022-06-03T09:51:17 点赞:0
在 如图,请问这是什么编程语言? 中回复
我:这不c++嘛,喵哪里来的C语法,喵这if后面不接括号是啥,作者你写错了吧,喵这来了个冒号加pass这是把python拉进来了??不是吧我丢,这html里面注释了js????哦我想通了,你在整活
2022-06-06T07:53:41 点赞:1