require "vendor/math" channel = {} channel.tomap = love.thread.getChannel("tomap") channel.blocks = love.thread.getChannel("blocks") function generateMapBlock(mapWidth, mapHeight) local block = {} local center = math.ceil( mapWidth/2 ) local defaultWidth=8 -- Fill empty for y=1, mapHeight do local row = {} for x=1, mapWidth do table.insert(row, 0) end table.insert(block, row) end -- Draw simple road for y=1, mapHeight do for x=center-(defaultWidth/2), center+(defaultWidth/2) do block[y][x] = 1 end end return block end while true do local tomap = channel.tomap:pop() if tomap then if tomap.message == "generateblock" then channel.blocks:push(generateMapBlock( tomap.width, tomap.height )) end end end