Lv.1
我是屑
签名:小号__eq__, 大号__name__kP81.
在 谁能告诉我我这段代码为什么错了? 中回复
没有entity对象
最好放在
world.onPlayerJoin()里 就像这样:world.onPlayerJoin(async({entity})=>{
//你的代码
})2021-02-04T09:31:38 点赞:1
在 求助载人列车代码 中回复
载人列车代码:
var velocity=0
var traindoor=false
world.onTick(() => {
world.querySelectorAll(".显示").forEach((x)=>{
x.enableInteract=true
x.interactHint="velocity:"喵elocity+",traindoor:"+traindoor
})
world.querySelectorAll(".列车零件").forEach((e) =>{
e.velocity.z = velocity
if (e.position.z<-1900) {
velocity=0
world.say("没路啦!")
}
})
})
world.onClick(({entity,clicker,button})=>{
if (button==Box3ButtonType.ACTION0) {
if (entity.hasTag("刹车")) {
velocity=0
} else if (entity.hasTag("加速")) {
velocity+=-0.3
} else if (entity.hasTag("减速")) {
velocity+=0.3
} else if (entity.hasTag("车门1") || entity.hasTag("车门2")) {
if (!traindoor) {
world.querySelector(".车门1").position.z+=1
world.querySelector(".车门2").position.z-=1
traindoor=!traindoor
} else if (traindoor) {
world.querySelector(".车门1").position.z-=1
world.querySelector(".车门2").position.z+=1
traindoor=!traindoor
}
}
}
})2021-02-07T10:15:08 点赞:0
在 一键生成树林!!!(修改版) 中回复
改一下:
function cylinder(cx, cy, cz, vox, radius, height) {
xend = cx + radius;
yend = cy + height;
zend = cz + radius;
for (let x = cx - radius; x <= xend; x++) {
for (let z = cz - radius; z <= zend; z++) {
dx = x - cx;
dz = z - cz;
if (Math.round(Math.sqrt(dx * dx + dz * dz)) <= radius) {
for (let y = cy; y < yend; y++) {
voxels.setVoxel(x, y, z, vox);
};
};
};
};
};
for (let i = 0; i < 340; i++) { /* 300个随机圆柱体构成场景*/
x = Math.random() * 325; /* x坐标*/
z = Math.random() * 325; /* z坐标*/
r = 2 + Math.random(); * 5 /*半径 2~7*/
h = Math.random() * 4; /* 高 0~4*/
cylinder(x, 9, z, 'dirt', r, h);
};
for (let y = 9; y < 13; y++) {//扫描9~12层的格子
for (let x = 0; x < 327; x++) {
for (let z = 0; z < 327; z++) {
if (voxels.getVoxel(x, y, z) != 0 && voxels.getVoxel(x, y + 1, z) == 0) {/* 如果当前格子不为空而它上面那格是空的, 则表示它是此地形的表面 */
voxels.setVoxel(x, y, z, 'grass');/* 土块替换成喵地*/
};
};
};
};
async function 喵(x, y, z, r = 0) {
r = Math.floor(Math.random() * 5+2);
for (let q = x-r;q < x+r;q++){
for (let w = y;w<y+r;w++){
for (let e = z-r;e<z+r;e++){
voxels.setVoxel(q,w,e,'green_leaf');
};
};
};
};
for (let w = 0; w < 601; w++) {
var 喵 = Math.floor(Math.random() * 280);
var wz = Math.floor(Math.random() * 280);
var wc = Math.floor(Math.random() * 10);
while (!wc % 2 === 1) {
var wc = Math.floor(Math.random() * 10);
};
var wth = Math.floor(Math.random() * 10);
var wh = Math.floor(Math.random() * 12) + 7;
for (let w1 = 7; w1 < 7 + wh; w1++) {
voxels.setVoxelId(喵, w1, wz, voxels.id('wood'));
};
喵(喵, 7 + wh, wz);
world.say('地形生成中...请耐心等待...(' + w + '/600)');
};
2021-02-12T10:18:52 点赞:0
在 Box3.0在线等,急 中回复
改成这样:
const DefaultScale = [0.0625,0.0625,0.0625]
function spawn (x,y,z,meshName){
var entity = world.createEntity({
mesh:meshName,
collides:true,
fixed:false,
gravity:true,
friction:0.5,
meshScale:DefaultScale,
position:[x,y,z],
});
entity.onVoxelContact(({x,y,z,voxel})=>{
entity.velocity.y = 0.5 + Math.random()*0.5
entity.velocity.x = (Math.random - 0.5)*0.5
entity.velocity.z = (Math.random - 0.5)*0.5
if(vosel == voxels.id('stone')){
}
else{
voxels.setVoxel(x,y,z,'')
}
})
return entity
}
for(var i=0;i<250;i++){
spawn (63,11+i,63,'mesh/公鸡.vb')
}2021-02-12T11:17:28 点赞:0
在 【岛3创作节】爆“肝”48小时后,你们做出了怎样的作品? 中回复
拉一票https://shequ.codemao.cn/community/370116
链接:https://box3.codemao.cn/p/caidao-zhan
2021-03-28T17:57:59 点赞:0
在 【岛3创作节】爆“肝”48小时后,你们做出了怎样的作品? 中回复
2021-03-29T20:37:34 点赞:0
在 【公告】申诉流程指南 中回复
你的帖子【阿考のNCT哔哔机】震惊!学编程居然会被人追着跑?下的回复“学编程前:这游戏真好玩 学编程后: import sys,os,glob from PySide2.QtWidgets import* from PySide2.QtCore import* from PySide2.QtGui import* class Ui_Window: def setupUi(self, Window): if not Window.objectName(): Window.setObjectName(u"Window") Window.resize(837, 623) self.centralwidget = QWidget(Window) self.centralwidget.setObjectName(u"centralwidget") self.verticalLayout = QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(u"verticalLayout") self.pix = QLabel(self.centralwidget) self.pix.setObjectName(u"pix") font = QFont() font.setFamily(u"\u5fae\u8f6f\u96c5\u9ed1") self.pix.setFont(font) self.pix.setAlignment(Qt.AlignCenter) self.verticalLayout.addWidget(self.pix) self.sbutton = QPushButton(self.centralwidget) self.sbutton.setObjectName(u"sbutton") self.verticalLayout.addWidget(self.sbutton) self.xbutton = QPushButton(self.centralwidget) self.xbutton.setObjectName(u"xbutton") self.verticalLayout.addWidget(self.xbutton) self.openfile = QPushButton(self.centralwidget) self.openfile.setObjectName(u"openfile") self.verticalLayout.addWidget(self.openfile) Window.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(Window) self.menubar.setObjectName(u"menubar") self.menubar.setGeometry(QRect(0, 0, 837, 22)) Window.setMenuBar(self.menubar) self.statusbar = QStatusBar(Window) self.statusbar.setObjectName(u"statusbar") Window.setStatusBar(self.statusbar) self.retranslateUi(Window) QMetaObject.connectSlotsByName(Window) def retranslateUi(self, Window): Window.setWindowTitle(QCoreApplication.translate("Window", u"\u56fe\u7247\u9884\u89c8", None)) self.pix.setText(QCoreApplication.translate("Window", u"\u56fe\u7247\u9884\u89c8", None)) self.sbutton.setText(QCoreApplication.translate("Window", u"\u4e0a\u4e00\u5f20", None)) self.xbutton.setText(QCoreApplication.translate("Window", u"\u4e0b\u4e00\u5f20", None)) self.openfile.setText(QCoreApplication.translate("Window", "打开图片", None)) class Tray(QSystemTrayIcon): def __init__(self): super().__init__() self.setup self.show() @property def setup(self): self.setIcon(QIcon("sit.png")) self.window=Window() self.menu=QMenu() actionexit = QAction('退出', self, triggered=self.quit) actionnext = QAction('下一张', self, triggered=self.window.next) actionlast = QAction('上一张', self, triggered=self.window.last) actionopenfile = QAction('打开文件', self, triggered=self.window.open) self.menu.addAction(actionexit) self.menu.addAction(actionnext) self.menu.addAction(actionlast) self.menu.addAction(actionopenfile) self.setContextMenu(self.menu) def quit(self): self.hide() self.window.quit() class Window(QMainWindow,Ui_Window): def __init__(self): super().__init__() self.setupUi(self) self.setup self.show() @property def setup(self): self.setWindowIcon(QIcon("sit.png")) self.openfile.clicked.connect(self.open) self.sbutton.clicked.connect(self.last) self.xbutton.clicked.connect(self.next) self.pix.setScaledContents(True) self.pic_list=[] self.index=0 self.icon_index=0 self.icons=["cat/0.png","cat/1.png","cat/2.png","cat/3.png","cat/4.png"] self.timer=QTimer() self.change_icon() self.pix.setPixmap(QPixmap("sit.png")) def quit(self): self.hide() sys.exit(0) def next(self): if not self.pic_list == []: self.index+=1 self.pix.setPixmap( QPixmap( self.pic_list[self.index%len(self.pic_list)] ) ) def last(self): if not self.pic_list == []: self.index-=1 self.pix.setPixmap( QPixmap( self.pic_list[self.index%len(self.pic_list)] ) ) def filterfile(self,filepath): for i in glob.glob(os.path.dirname(os.path.abspath(filepath))+"/*"): #找到文件所在的文件夹 if os.path.splitext(i)[-1] in [".jpg",".png",".bmp",".jpeg"]: #查看后缀 if i not in self.pic_list: #如果在文件夹中有就不用再添加(返回)了 yield i #返回一个迭代器 def open(self): file_path=QFileDialog.getOpenFileName(caption="选择乐谱",filter="(*.jpg *.png *.bmp *.jpeg)")[0] if file_path: self.pix.setPixmap(QPixmap(file_path)) for i in self.filterfile(file_path): self.pic_list.append(i) print(f"addfile:{i}") print(f"file list:{self.pic_list}") self.index += 1 def change_icon(self): self.setWindowIcon(QIcon(self.icons[self.icon_index%len(self.icons)])) self.icon_index += 1 self.timer.singleShot(100,self.change_icon) if __name__ == "__main__": app=QApplication(sys.argv) window_tray=Tray() sys.exit(app.exec_()) ”被举报“垃圾广告”,经管喵核实被判定为违规评论,已被删除,如有问题可前往反馈。
垃圾广告??!
2021-03-31T17:28:48 点赞:1