Anywho, made this for myself mostly, but figured others out there might like it too. Do what you will with it; if orzelek uses it I'd be honored and maybe he could stick my username in a corner of a file somewhere....or not
![Smile :)](./images/smilies/icon_e_smile.gif)
Dreadicon did all the worka nd I integrated it already.Neemys wrote:@orzelek
I'm Building-Platform author, is there something I could add in my mod to help with the support of RSO with my mod or you have taken care of everything ?
Platform incompatible with angel+bob ? Because of space needed or because some building aren't blocked ?
Code: Select all
require("config")
local blocksize=6
local blockThreshold=straightWorldPlatformsThreshold
local blocksizem1=blocksize-1
local platformName = "building-platform"
function straightWorldPlatforms(surface, leftTop, rightBottom)
local lt = leftTop
local rb = rightBottom
if surface == nil then
return
end
for y0=lt.y,rb.y-1,blocksize do
for x0=lt.x,rb.x-1,blocksize do
--Check all blocks for platforms
local replaceBlocks = false
local blockCount = 0
for y1=y0,y0+blocksizem1 do
for x1=x0,x0+blocksizem1 do
local tileObj = surface.get_tile(x1,y1)
if tileObj ~= nil and tileObj.valid then
local tile=tileObj.name
if tile == platformName then
blockCount = blockCount + 1
end
if blockCount > (blocksize * blocksize) * blockThreshold then
replaceBlocks = true
break
end
end
end
if replaceBlocks == true then break end
end
--if enough platforms are found, replace the blocks
if replaceBlocks then
local tiles={}
for y=y0,y0+blocksizem1 do
for x=x0,x0+blocksizem1 do
table.insert(tiles,{name=platformName,position={x,y}})
end
end
surface.set_tiles(tiles)
end
end
end
end