-
Notifications
You must be signed in to change notification settings - Fork 1
/
MusicScript.min.lua
1 lines (1 loc) · 2.01 KB
/
MusicScript.min.lua
1
Player:notifyGameInfo2Self(0,"点击任意方块开始生成音乐")Player:notifyGameInfo2Self(0,"生成起点为房主坐标")MusicBlock={bass=690,alto=691,high=692,drum=693,elec=694,synt=695,defaultBlock=667,rhythm=0,nowBlockPos={x=0,y=0,z=0}}function MusicBlock:create(music)local a,b=Actor:getFaceYaw(0)local c=""if b>-45 and b<=45 then c="Z-"elseif b>45 and b<=135 then c="X-"elseif b>135 and b<=180 or b<=-135 and b>-180 then c="Z+"elseif b<=-45 and b>-135 then c="X+"else c="X+"end;local function d(e)if c=="Z-"then self.nowBlockPos.z=self.nowBlockPos.z-1 elseif c=="X-"then self.nowBlockPos.x=self.nowBlockPos.x-1 elseif c=="X+"then self.nowBlockPos.x=self.nowBlockPos.x+1 elseif c=="Z+"then self.nowBlockPos.z=self.nowBlockPos.z+1 end end;local a,f,g,h=Actor:getPosition(0)self.nowBlockPos={x=f,y=g,z=h}local i=self.nowBlockPos;for j,k in pairs(music)do i=self.nowBlockPos;if c=="X+"then Block:setBlockAll(i.x,i.y,i.z,702,self.rhythm*4)elseif c=="Z+"then Block:setBlockAll(i.x,i.y,i.z,702,self.rhythm*4+2)elseif c=="Z-"then Block:setBlockAll(i.x,i.y,i.z,702,self.rhythm*4+3)elseif c=="X-"then Block:setBlockAll(i.x,i.y,i.z,702,self.rhythm*4+1)end;d()if k[5]~=-1 then if k[1]==0 then Block:setBlockAll(i.x,i.y,i.z,self.bass,k[2])elseif k[1]==1 then Block:setBlockAll(i.x,i.y,i.z,self.alto,k[2])elseif k[1]==2 then Block:setBlockAll(i.x,i.y,i.z,self.high,k[2])end;if k[3]==0 then Block:setBlockAll(i.x,i.y+1,i.z,self.drum,k[4])elseif k[3]==1 then Block:setBlockAll(i.x,i.y+1,i.z,self.elec,k[4])elseif k[3]==2 then Block:setBlockAll(i.x,i.y+1,i.z,self.synt,k[4])else error("DataError! at "..j)end else Block:replaceBlock(self.defaultBlock,i.x,i.y,i.z,0)end;d()threadpool:wait(0.01)Player:setPosition(0,i.x,i.y,i.z)end;Player:setPosition(0,f,g,h)Player:notifyGameInfo2Self(0,"#G音乐生成完成!")end;HasCreated=false;function CreateMusic(l)if HasCreated~=true then HasCreated=true;MusicBlock:create(music)else Player:notifyGameInfo2Self(0,"#R音乐已经生成过了!")end end;ScriptSupportEvent:registerEvent([=[Player.ClickBlock]=],CreateMusic)