3D魔方游戏制作lua迷你世界

--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)

相关推荐
CSharp精选营11 小时前
关系型 vs 非关系型:从原理到选型,一文搞定数据库核心分类
数据结构·nosql·关系型数据库·非关系型数据库·技术选型
金銀銅鐵2 天前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏
金銀銅鐵3 天前
借助 Pygame 探索最大公约数的规律
python·数学·游戏
刘马想放假4 天前
Modbus 全栈技术解析:TCP、RTU、ASCII、RTU over TCP
数据结构·网络协议
北域码匠5 天前
冒泡排序太慢?鸡尾酒排序双向优化,原生 C# 零第三方库完整代码
数据结构·排序算法·泛型·c# 算法·鸡尾酒排序·原生 c# 开发·冒泡排序优化·嵌入式算法
nujnewnehc7 天前
不会 py, 用 ai 写了个游戏辅助的感受
人工智能·游戏
jump_jump8 天前
为了重玩金庸群侠传,我研究了一下 Ruffle 怎么复活 Flash
游戏·rust·github
XIAOHEZIcode9 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
Aloys_Code10 天前
逆向一个被遗忘的DVD游戏格式:从DES加密到Rust模拟器
游戏·模拟器·retroarch·复古游戏·native32·sunplus·赤刃·钢铁风暴
金銀銅鐵10 天前
用 Python 实现 Take-Away 游戏
python·游戏