点灯游戏是一个十分有趣的智力游戏:有一行N行N列的灯,开始时全部是灭的,当你点击其中一盏灯时他的上下左右(若存在的话)状态全部改变,现在要求你在限定的时间内以最少地步数,将全部的灯点亮。
--点灯益智游戏
--作者:韩永旗
--迷你号:247312290
--全自动生成,检测
--点灯 钻石,冰砖,电石,灯灭,灯亮
local t1="点灯游戏是一个十分有趣的智力游戏:\n有一行N行N列的灯,开始时全部是灭的,\n当你点击其中一盏灯时他的上下左右(若存在的话)状态全部改变,\n现在要求你在限定的时间内以最少地步数,将全部的灯点亮。"
local P={}
local id={408,430,415,707,708}
local z1={}
local z2={}
local x0,y0,z0,x,y,z=0,0,0,0,0,0
local mid={10948,10946,10949,10947}
local id0,id6=0,0local function chack(x,y,z)
local result,id6=Block:getBlockID(x,y,z)
return id6
end
local function add(x,y,z,id0)
Block:setBlockAll(x,y,z,id0,0)
endlocal function addc(t, x, y, z)
local title=t
local x,y,z,x2,y2=x, y, z,0,0
local graphicInfo = Graphics:makeGraphicsText(title, 17, 0, 0)
local result = Graphics:createGraphicsTxtByPos(x, y, z, graphicInfo, x2, y2)
end
threadpool:wait(5)
for i=1,10 do
z1[i]=14*i-60
z2[i]={14*i-60,14*(i+1)-60}
for j=1,7 do
add(12*j-45,6,z1[i],id[1])
addc("点灯复位:#n\n("..(2+i).."×"..(2+i).. ")", 12*j-45,7,z1[i])
end
end
--print(z1)
--print(z2)
--Player:playMusic(uid,mid[2],100,1,false)
local function chack2(z0)
for k,v in ipairs(z2) do
if z0>v[1] and z0end
end
endlocal function chack1(uid,x0,y0,z0)
local i,z0=chack2(z0)
local result=Area:blockInAreaRange(id[2],{x=x0-1,y=7,z=z0+2},{x=x0-1,y=8+i,z=z0+3+i})
local y0,k=6,i
if result==0 then
else
Player:playMusic(uid,mid[4],100,1,false)
Chat:sendSystemMsg("玩家"..P[uid]..":"..(i+2).."*"..(i+2).."胜利挑战成功")
Actor:playBodyEffectById(uid,1023,1)
--等待1秒
threadpool:wait(2)
Area:fillBlockAreaRange({x=x0-1,y=y0+1,z=z0+2},{x=x0-1,y=y0+k+2,z=z0+3+k},id[2],0)
Area:replaceAreaRangeBlock({x=x0-1,y=y0+1,z=z0+2},{x=x0-1,y=y0+2+k,z=z0+3+k},id[3],id[2],0)
Area:fillBlockAreaRange({x=x0,y=y0+1,z=z0+2},{x=x0,y=y0+k+2,z=z0+3+k},id[4],0)
Chat:sendSystemMsg("游戏("..(k+2).."*"..(k+2)..")已重置")
Player:playMusic(uid,mid[2],100,1,false)
threadpool:wait(3)
Actor:stopBodyEffectById(uid,1023)
end
endlocal function add1(e)
local x0,y0,z0=math.floor(e.x),math.floor(e.y),math.floor(e.z)
local uid=e.eventobjid
if e.blockid==id[1] and y0==6 then
for k,v in ipairs(z1) do
if v==z0 then
Area:fillBlockAreaRange({x=x0-1,y=y0+1,z=z0+2},{x=x0-1,y=y0+k+2,z=z0+3+k},id[2],0)
Area:replaceAreaRangeBlock({x=x0-1,y=y0+1,z=z0+2},{x=x0-1,y=y0+2+k,z=z0+3+k},id[3],id[2],0)
Area:fillBlockAreaRange({x=x0,y=y0+1,z=z0+2},{x=x0,y=y0+k+2,z=z0+3+k},id[4],0)
Chat:sendSystemMsg("游戏("..(k+2).."*"..(k+2)..")已重置")
Player:playMusic(uid,mid[2],100,1,false)
Game:msgBox(t1,uid)
end
end
elseif e.blockid==id[4] or e.blockid==id[5] then
Player:playMusic(uid,mid[1],100,1,false)
if chack(x0-1,y0,z0)==id[2] then add(x0-1,y0,z0,id[3])
elseif chack(x0-1,y0,z0)==id[3] then add(x0-1,y0,z0,id[2])
end
if chack(x0-1,y0+1,z0)==id[2] then add(x0-1,y0+1,z0,id[3])
elseif chack(x0-1,y0+1,z0)==id[3] then add(x0-1,y0+1,z0,id[2])
end
if chack(x0-1,y0-1,z0)==id[2] then add(x0-1,y0-1,z0,id[3])
elseif chack(x0-1,y0-1,z0)==id[3] then add(x0-1,y0-1,z0,id[2])
end
if chack(x0-1,y0,z0+1)==id[2] then add(x0-1,y0,z0+1,id[3])
elseif chack(x0-1,y0,z0+1)==id[3] then add(x0-1,y0,z0+1,id[2])
end
if chack(x0-1,y0,z0-1)==id[2] then add(x0-1,y0,z0-1,id[3])
elseif chack(x0-1,y0,z0-1)==id[3] then add(x0-1,y0,z0-1,id[2])
end
chack1(uid,x0,y0,z0)
end
end
ScriptSupportEvent:registerEvent([=[Player.ClickBlock]=], add1)local function addo(e)
Player:setRevivePoint(e.eventobjid,0,8,0)
Player:setPosition(e.eventobjid,0,8,0)
Player:setAttr(e.eventobjid,23,9999)
for i=12241,12244 do
local result,successNum=Backpack:addItem(e.eventobjid,i,1)
local result = Backpack:actEquipUpByResID(e.eventobjid, i)
end
local result,successNum=Backpack:addItem(e.eventobjid,12253,10)
local result = Backpack:actEquipUpByResID(e.eventobjid, 12253)
local result,name=Player:getNickname(e.eventobjid)
P[e.eventobjid]=name
Chat:sendSystemMsg("#b#G欢迎#B"..name.."#b#Y来到#R益智点灯小游戏")
Game:msgBox(t1,uid)
end
ScriptSupportEvent:registerEvent([=[Game.AnyPlayer.EnterGame]=],addo)