1
0
mirror of https://github.com/jvmguy/JvmguyScenario.git synced 2024-11-21 17:16:46 +02:00

Add OctoTile2, sometimes used in RiverWorld.

This commit is contained in:
Kevin Morgan 2023-08-23 00:08:50 -07:00
parent 1966e6548f
commit 910cc1617f

161
lib/OctoTile2.lua Normal file
View File

@ -0,0 +1,161 @@
-- Generation of 96x96 patterns
local M = {};
M.design = {
"...........................................WWWXX", --0
"...........................................WWWXX", --1
"...........................................WWWXX", --2
"...........................................WWWXX", --3
"...........................................WWWXX", --4
"...........................................WWWXX", --5
"...........................................WWWXX", --6
"...........................................WWWXX", --7
"...........................................WWWXX", --8
"...........................................WWWXX", --9
"...........................................WWWXX", --10
"...........................................WWWXX", --11
"...........................................WWWXX", --12
"...........................................WWWXX", --13
"...........................................WWWXX", --14
"...........................................WWWXX", --15
"...........................................WWWXX", --16
"...........................................WWWXX", --17
"...........................................WWWXX", --18
"...........................................WWWXX", --19
"..........................................WWXXXX", --20
".........................................WWXXXXX", --21
"........................................WWXXXXXX", --22
".......................................WWXXXXXXX", --23
"......................................WWXXXXXXXX", --24
".....................................WWXXXXXXXXX", --25
"....................................WWXXXXXXXXXX", --26
"...................................WWXXXXXXXXXXX", --27
"..........................WWWWWWWWWWXXXXXXXXXXXX", --28
"..........................WWWWWWWWWXXXXXXXXXXXXX", --29
"..........................WWXXXXXXXXXXXXXXXXXXXX", --30
"..........................WWXXXXXXXXXXXXXXXXXXXX", --31
"..........................WWXXXXXXXXXXXXXXXXXXXX", --32
"..........................WWXXXXXXXXXXXXXXXXXXXX", --33
"..........................WWXXXXXXXXXXXXXXXXXXXX", --34
"..........................WWXXXXXXXXXXXXXXXXXXXX", --35
"..........................WWXXXXXXXXXXXXXXXXXXXX", --36
"..........................WWXXXXXXXXXXXXXXXXXXXX", --37
"..........................WWXXXXXXXXXXXXXXXXXXXX", --38
".........................WWXXXXXXXXXXXXXXXXXXXXX", --39
"........................WWXXXXXXXXXXXXXXXXXXXXXX", --40
".......................WWXXXXXXXXXXXXXXXXXXXXXXX", --41
"......................WWXXXXXXXXXXXXXXXXXXXXXXXX", --42
"WWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXX", --43
"WWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXX", --44
"WWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXX", --45
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", --46
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", --47
}
M.spawnDesign = {
"...........................................WWWWW", --0
"...........................................WWWXX", --1
"...........................................WWWXX", --2
"...........................................WWWXX", --3
"...........................................WWWXX", --4
"...........................................WWWXX", --5
"...........................................WWWXX", --6
"...........................................WWWXX", --7
"...........................................WWWXX", --8
"...........................................WWWXX", --9
"...........................................WWWXX", --10
"...........................................WWWXX", --11
"...........................................WWWXX", --12
"...........................................WWWXX", --13
"...........................................WWWXX", --14
"...........................................WWWXX", --15
"...........................................WWWXX", --16
"...........................................WWWXX", --17
"...........................................WWWXX", --18
"...........................................WWWXX", --19
"..........................................WWXXXX", --20
".........................................WWXXXXX", --21
"........................................WWXXXXXX", --22
".......................................WWXXXXXXX", --23
"......................................WWXXXXXXXX", --24
".....................................WWXXXXXXXXX", --25
"....................................WWXXXXXXXXXX", --26
"...................................WWXXXXXXXXXXX", --27
"..........................WWWWWWWWWWXXXXXXXXXXXX", --28
"..........................WWWWWWWWWXXXXXXXXXXXXX", --29
"..........................WWXXXXXXXXXXXXXXXXXXXX", --30
"..........................WWXXXXXXXXXXXXXXXXXXXX", --31
"..........................WWXXXXXXXXXXXXXXXXXXXX", --32
"..........................WWXXXXXXXXXXXXXXXXXXXX", --33
"..........................WWXXXXXXXXXXXXXXXXXXXX", --34
"..........................WWXXXXXXXXXXXXXXXXXXXX", --35
"..........................WWXXXXXXXXXXXXXXXXXXXX", --36
"..........................WWXXXXXXXXXXXXXXXXXXXX", --37
"..........................WWXXXXXXXXXXXXXXXXXXXX", --38
".........................WWXXXXXXXXXXXXXXXXXXXXX", --39
"........................WWXXXXXXXXXXXXXXXXXXXXXX", --40
".......................WWXXXXXXXXXXXXXXXXXXXXXXX", --41
"......................WWXXXXXXXXXXXXXXXXXXXXXXXX", --42
"WWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXX", --43
"WWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXX", --44
"WWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXX", --45
"WXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", --46
"WXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", --47
}
function terrainFunc( design, x, y )
-- lua arrays start with 1
-- the picture is symmetric across both x and y
if (x>47) then
x = 95 - x;
end
if (y>47) then
y = 95 - y;
end
local row = design[y+1]
if (row == nil) then return nil end
local code = string.sub(row, x+1, x+1)
if (code == nil) then return nil end
if (code == 'W') then
return "water"
end
if (code == '.') then
return "out-of-map"
end
return nil
end
function M.FillTiles( design, surface, chunkArea )
-- lx,ly is the top-left of the geometric feature
local lx = math.floor(chunkArea.left_top.x/96)*96
local ly = math.floor(chunkArea.left_top.y/96)*96
local tiles = {}
for y=chunkArea.left_top.y, chunkArea.right_bottom.y do
for x=chunkArea.left_top.x, chunkArea.right_bottom.x do
local tile = terrainFunc(design, x-lx, y-ly)
if tile ~= nil then
table.insert(tiles, { name=tile, position= { x,y} })
end
end
end
if #tiles > 0 then
SetTiles( surface, tiles, true);
end
end
function M.ChunkGenerated(event)
local surface = event.surface
if surface.name == GAME_SURFACE_NAME then
local chunkArea = event.area
if (RocketSiloContains(chunkArea)) then
return
end
local design = M.design
M.FillTiles(design, surface, chunkArea)
end
end
return M;