
--3D魔方
--星空露珠工作室
--核心脚本来自负负
--1:xy 2:yx 3:xz 4:zx 5:yz 6:zy
--4000,0-3 3995-0,3
local trn={
{{5,2},{3,1},{1,2},{1,3},{4,0},{2,2}},
{{3,0},{5,3},{1,3},{1,2},{2,3},{4,1}},
{{4,2},{2,1},{1,1},{1,0},{3,3},{5,1}},
{{2,0},{4,3},{1,0},{1,1},{5,0},{3,2}},
{{6,0},{1,3},{2,2},{2,3},{5,2},{3,0}},
{{1,2},{6,1},{2,3},{2,2},{3,1},{5,3}},
{{5,1},{3,2},{2,1},{2,0},{1,0},{6,2}},
{{3,3},{5,0},{2,0},{2,1},{6,3},{1,1}},
{{6,2},{1,1},{3,2},{3,3},{2,0},{4,2}},
{{1,0},{6,3},{3,3},{3,2},{4,3},{2,1}},
{{2,2},{4,1},{3,1},{3,0},{1,3},{6,1}},
{{4,0},{2,3},{3,0},{3,1},{6,0},{1,2}},
{{5,0},{3,3},{4,2},{4,3},{6,2},{1,0}},
{{3,2},{5,1},{4,3},{4,2},{1,1},{6,3}},
{{6,1},{1,2},{4,1},{4,0},{3,0},{5,2}},
{{1,3},{6,0},{4,0},{4,1},{5,3},{3,1}},
{{2,3},{4,0},{5,2},{5,3},{6,1},{1,3}},
{{4,1},{2,2},{5,3},{5,2},{1,2},{6,0}},
{{6,3},{1,0},{5,1},{5,0},{4,2},{2,0}},
{{1,1},{6,2},{5,0},{5,1},{2,1},{4,3}},
{{4,3},{2,0},{6,2},{6,3},{5,1},{3,3}},
{{2,1},{4,2},{6,3},{6,2},{3,2},{5,0}},
{{5,3},{3,0},{6,1},{6,0},{2,2},{4,0}},
{{3,1},{5,2},{6,0},{6,1},{4,1},{2,3}}}

1.上面-黄
2.左面-绿
3.后面-红
4.右面-蓝
5.前面-橙
6.下面-白
模型快速制作,请阅读下一篇
local ids={4000,3999,3998,3997,3996,3995}local x0,y0,z0=0,9,0--起点坐标
--黄,绿,红,蓝,橙,白
--魔方数据
local cft={{
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}}}
,{
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}}}
,{
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}}}}
local x,y,z=0,0,0
--游戏开始,生成魔方
local function Go(e)
for x=0,2 do
for y=0,2 do
for z=0,2 do
Block:destroyBlock(Px0+x,y0+y,z0+z,false)
Block:setBlockAll(x0+x,y0+y,z0+z,ids1,0)
end
end
end
end
ScriptSupportEvent:registerEvent(=\[Game.Start=],Go)
--刷新魔方
local function Re()
local str=''
for x=1,3 do
str=str..'\n'
for y=1,3 do
str=str..'\n'
for z=1,3 do
str=str..'('..cftx4-yz1..','.. cftx4-yz2..'),'
Block:setBlockAll(x0+z-1,y0+x-1,z0+y-1,idscft\[x4-yz1],cftx4-yz2)
end
end
end
print("打印\n"..str)
end
--旋转
local rc={1,0}
local function Ton(a,e,b)
rc1=cfta\[1]a\[2]a\[3]1
rc2=cfta\[1]a\[2]a\[3]2
cfta\[1]a\[2]a\[3]1=trncft\[a\[4]a\[5]a\[6]1*4+cfta\[4]a\[5]a\[6]2-3]b1
cfta\[1]a\[2]a\[3]2=trncft\[a\[4]a\[5]a\[6]1*4+cfta\[4]a\[5]a\[6]2-3]b2
cfta\[4]a\[5]a\[6]1=trncft\[a\[7]a\[8]a\[9]1*4+cfta\[7]a\[8]a\[9]2-3]b1
cfta\[4]a\[5]a\[6]2=trncft\[a\[7]a\[8]a\[9]1*4+cfta\[7]a\[8]a\[9]2-3]b2
cfta\[7]a\[8]a\[9]1=trncft\[a\[10]a\[11]a\[12]1*4+cfta\[10]a\[11]a\[12]2-3]b1
cfta\[7]a\[8]a\[9]2=trncft\[a\[10]a\[11]a\[12]1*4+cfta\[10]a\[11]a\[12]2-3]b2
cfta\[10]a\[11]a\[12]1=trnrc\[1*4+rc2-3]b1
cfta\[10]a\[11]a\[12]2=trnrc\[1*4+rc2-3]b2
rc1=cfte\[1]e\[2]e\[3]1
rc2=cfte\[1]e\[2]e\[3]2
cfte\[1]e\[2]e\[3]1=trncft\[e\[4]e\[5]e\[6]1*4+cfte\[4]e\[5]e\[6]2-3]b1
cfte\[1]e\[2]e\[3]2=trncft\[e\[4]e\[5]e\[6]1*4+cfte\[4]e\[5]e\[6]2-3]b2
cfte\[4]e\[5]e\[6]1=trncft\[e\[7]e\[8]e\[9]1*4+cfte\[7]e\[8]e\[9]2-3]b1
cfte\[4]e\[5]e\[6]2=trncft\[e\[7]e\[8]e\[9]1*4+cfte\[7]e\[8]e\[9]2-3]b2
cfte\[7]e\[8]e\[9]1=trncft\[e\[10]e\[11]e\[12]1*4+cfte\[10]e\[11]e\[12]2-3]b1
cfte\[7]e\[8]e\[9]2=trncft\[e\[10]e\[11]e\[12]1*4+cfte\[10]e\[11]e\[12]2-3]b2
cfte\[10]e\[11]e\[12]1=trnrc\[1*4+rc2-3]b1
cfte\[10]e\[11]e\[12]2=trnrc\[1*4+rc2-3]b2
end
--d m: 0左中右 1上中下 2前中后
--m: 0顺时针 1逆时针 从左后下方
local function Re0(d,i,m)
if (d==0)and(m==0) then
Ton({1,3,1+i,3,3,1+i,3,1,1+i,1,1,1+i},{1,2,1+i,2,3,1+i,3,2,1+i,2,1,1+i},6)
elseif (d==0)and(m==1) then
Ton({1,1,1+i,3,1,1+i,3,3,1+i,1,3,1+i},{2,1,1+i,3,2,1+i,2,3,1+i,1,2,1+i},5)
elseif (d==1)and(m==0) then
Ton({3-i,3,1,3-i,3,3,3-i,1,3,3-i,1,1},{3-i,2,1,3-i,3,2,3-i,2,3,3-i,1,2},4)
elseif (d==1)and(m==1) then
Ton({3-i,1,1,3-i,1,3,3-i,3,3,3-i,3,1},{3-i,1,2,3-i,2,3,3-i,3,2,3-i,2,1},3)
elseif (d==2)and(m==0) then
Ton({1,3-i,1,1,3-i,3,3,3-i,3,3,3-i,1},{1,3-i,2,2,3-i,3,3,3-i,2,2,3-i,1},2)
else
Ton({3,3-i,1,3,3-i,3,1,3-i,3,1,3-i,1},{2,3-i,1,3,3-i,2,2,3-i,3,1,3-i,2},1)
end
Re()
end
--d m: 0左中右 1上中下 2前中后
--m: 0顺时针 1逆时针 从左后下方
local function input(e)
if e.content=="0" then Go(e) --复原
elseif e.content=="1" then Re0(1,0,0) --上
elseif e.content=="2" then Re0(1,2,0) --下
elseif e.content=="3" then Re0(0,0,0) --前
elseif e.content=="4" then Re0(0,2,0) --后
elseif e.content=="5" then Re0(2,2,0) --左
elseif e.content=="6" then Re0(2,0,0) --右
elseif e.content=="7" then Re0(1,0,1) --上
elseif e.content=="8" then Re0(1,2,1) --下
elseif e.content=="9" then Re0(0,0,1) --前
elseif e.content=="10" then Re0(0,2,1) --后
elseif e.content=="11" then Re0(2,2,1)--左
elseif e.content=="12" then Re0(2,0,1) --右
elseif e.content=="13" then Re0(0,1,0) --中_前后
elseif e.content=="14" then Re0(1,1,0) --中_上下
elseif e.content=="15" then Re0(2,1,0) --中_左右
elseif e.content=="16" then Re0(0,1,1) --中_前后
elseif e.content=="17" then Re0(1,1,1) --中_上下
elseif e.content=="18" then Re0(2,1,1) --中_左右
end
end
ScriptSupportEvent:registerEvent(=\[Player.InputContent=], input)