Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wrapPs(peripheralName)
- periTab={}
- sideTab={}
- if peripheralName==nil then
- print("Fehler")
- end
- local peripherals = peripheral.getNames()
- local i2 = 1
- for i =1, #peripherals do
- if peripheral.getType(peripherals[i])==peripheralName then
- periTab[i2]=peripheral.wrap(peripherals[i])
- sideTab[i2]=peripherals[i]
- i2=i2+1
- end
- end
- if periTab~={} then
- return periTab,sideTab
- else
- return nil
- end
- end
- mes={}
- for i=1,256 do
- mes[i]=peripheral.wrap("tileinterface_"..i+11)
- end
- container=peripheral.wrap("right")
- --mes,mesSide=wrapPs("tileinterface")
- function pullArray(me,height)
- for i=1,height do
- me.pullItem("up",i)
- end
- end
- function pushArray(me,height)
- for i=1,height do
- me.exportItem(material[i],"up",1)
- end
- end
- function scanMaterials()
- material={}
- for i=1,16 do
- if container.getStackInSlot(i)~=nil then
- material[i]={id=container.getStackInSlot(i).id,dmg=container.getStackInSlot(i).dmg}
- end
- end
- return material
- end
- function fillAll(height)
- for i=1,256 do
- pushArray(mes[i],height)
- end
- end
- function suckAll(height)
- for i=1,256 do
- pullArray(mes[i],height)
- end
- end
- function init_maze(width, height)
- local result = {}
- for y = 0, height - 1 do
- for x = 0, width - 1 do
- result[y * width + x] = 1
- end
- result[y * width + 0] = 0
- result[y * width + width - 1] = 0
- end
- for x = 0, width - 1 do
- result[0 * width + x] = 0
- result[(height - 1) * width + x] = 0
- end
- return result
- end
- function carve_maze(maze, width, height, x, y)
- local r = math.random(0, 3)
- maze[y * width + x] = 0
- for i = 0, 3 do
- local d = (i + r) % 4
- local dx = 0
- local dy = 0
- if d == 0 then
- dx = 1
- elseif d == 1 then
- dx = -1
- elseif d == 2 then
- dy = 1
- else
- dy = -1
- end
- local nx = x + dx
- local ny = y + dy
- local nx2 = nx + dx
- local ny2 = ny + dy
- if maze[ny * width + nx] == 1 then
- if maze[ny2 * width + nx2] == 1 then
- maze[ny * width + nx] = 0
- carve_maze(maze, width, height, nx2, ny2)
- end
- end
- end
- end
- function fillMaze(height)
- maze=init_maze(16,16)
- carve_maze(maze, 16, 16, 2, 2)
- for i=0, 255 do
- if maze[i]==1 then
- pushArray(mes[i+1],height)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement