1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/locale/gen_misc/rail_grid.lua

136 lines
56 KiB
Lua
Raw Normal View History

2017-07-18 21:54:54 +02:00
mymodule = {}
local function rot_pos(pos, rot)
local ctr = {x = 15, y = 15}
return {
x = ctr.x + (pos.x - ctr.x) * rot.x - (pos.y - ctr.y) * rot.y,
y = ctr.y + (pos.x - ctr.x) * rot.y + (pos.y - ctr.y) * rot.x
}
end
local function rot_dir(dir, rot)
local cnt = 2 * math.atan2(rot.y, rot.x) / math.pi
return (dir + 2 * cnt) % 8
end
local rail_grid = {
["allway"] = {{["name"] = "curved-rail", ["position"] = {["x"] = 10, ["y"] = 4}, ["direction"] = 5}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 1}, ["direction"] = 0}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 12.5, ["y"] = 0.5}, ["direction"] = 4}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 17.5, ["y"] = 0.5}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 1}, ["direction"] = 0}, {["name"] = "curved-rail", ["position"] = {["x"] = 20, ["y"] = 4}, ["direction"] = 4}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 3}, ["direction"] = 0}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 15, ["y"] = 3}, ["direction"] = 0}, {["name"] = "curved-rail", ["position"] = {["x"] = 20, ["y"] = 6}, ["direction"] = 4}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 3}, ["direction"] = 0}, {["name"] = "curved-rail", ["position"] = {["x"] = 12, ["y"] = 6}, ["direction"] = 6}, {["name"] = "curved-rail", ["position"] = {["x"] = 12, ["y"] = 8}, ["direction"] = 4}, {["name"] = "curved-rail", ["position"] = {["x"] = 18, ["y"] = 8}, ["direction"] = 5}, {["name"] = "curved-rail", ["position"] = {["x"] = 20, ["y"] = 6}, ["direction"] = 3}, {["name"] = "curved-rail", ["position"] = {["x"] = 4, ["y"] = 10}, ["direction"] = 2}, {["name"] = "curved-rail", ["position"] = {["x"] = 6, ["y"] = 10}, ["direction"] = 2}, {["name"] = "curved-rail", ["position"] = {["x"] = 6, ["y"] = 10}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 7}, ["direction"] = 3}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 15.5, ["y"] = 6.5}, ["direction"] = 6}, {["name"] = "straight-rail", ["position"] = {["x"] = 23, ["y"] = 7}, ["direction"] = 5}, {["name"] = "curved-rail", ["position"] = {["x"] = 26, ["y"] = 10}, ["direction"] = 7}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 15.5, ["y"] = 9.5}, ["direction"] = 1}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 14.5, ["y"] = 9.5}, ["direction"] = 3}, {["name"] = "curved-rail", ["position"] = {["x"] = 24, ["y"] = 12}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 1, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 3, ["y"] = 11}, ["direction"] = 2}, {["name"] = "curved-rail", ["position"] = {["x"] = 8, ["y"] = 12}, ["direction"] = 3}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 13}, ["direction"] = 7}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 11}, ["direction"] = 5}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 13}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 11}, ["direction"] = 3}, {["name"] = "curved-rail", ["position"] = {["x"] = 22, ["y"] = 12}, ["direction"] = 6}, {["name"] = "straight-rail", ["position"] = {["x"] = 27, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 29, ["y"] = 11}, ["direction"] = 2}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 0.5, ["y"] = 12.5}, ["direction"] = 6}, {["name"] = "straight-rail", ["position"] = {["x"] = 13, ["y"] = 15}, ["direction"] = 7}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 15}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 13, ["y"] = 13}, ["direction"] = 3}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 12.5, ["y"] = 12.5}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 17, ["y"] = 13}, ["direction"] = 5}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 15}, ["direction"] = 7}, {["name"] = "straight-rail", ["position"] = {["x"] = 17, ["y"] = 15}, ["direction"] = 1}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 17.5, ["y"] = 12.5}, ["direction"] = 3}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 29.5, ["y"] = 12.5}, ["direction"] = 6}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 3, ["y"] = 15}, ["direction"] = 0}, {["na
["tshape"] = {{["name"] = "curved-rail", ["position"] = {["x"] = 4, ["y"] = 12}, ["direction"] = 3}, {["name"] = "straight-rail", ["position"] = {["x"] = 1, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 3, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 5, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 9, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 13, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 17, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 21, ["y"] = 11}, ["direction"] = 2}, {["name"] = "curved-rail", ["position"] = {["x"] = 26, ["y"] = 12}, ["direction"] = 6}, {["name"] = "straight-rail", ["position"] = {["x"] = 23, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 25, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 27, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 29, ["y"] = 11}, ["direction"] = 2}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 0.5, ["y"] = 12.5}, ["direction"] = 6}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 7.5, ["y"] = 12.5}, ["direction"] = 6}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 15}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 23, ["y"] = 15}, ["direction"] = 7}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 22.5, ["y"] = 12.5}, ["direction"] = 6}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 29.5, ["y"] = 12.5}, ["direction"] = 6}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 3, ["y"] = 15}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 9, ["y"] = 15}, ["direction"] = 5}, {["name"] = "straight-rail", ["position"] = {["x"] = 9, ["y"] = 17}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 21, ["y"] = 17}, ["direction"] = 7}, {["name"] = "straight-rail", ["position"] = {["x"] = 21, ["y"] = 15}, ["direction"] = 3}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 27, ["y"] = 15}, ["direction"] = 0}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 0.5, ["y"] = 17.5}, ["direction"] = 2}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 7.5, ["y"] = 17.5}, ["direction"] = 2}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 8.5, ["y"] = 17.5}, ["direction"] = 7}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 17}, ["direction"] = 5}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 19}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 19}, ["direction"] = 7}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 17}, ["direction"] = 3}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 21.5, ["y"] = 17.5}, ["direction"] = 5}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 22.5, ["y"] = 17.5}, ["direction"] = 2}, {["name"] = "rail-chain-signal", ["position"] = {["x"] = 29.5, ["y"] = 17.5}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 1, ["y"] = 19}, ["direction"] = 2}, {["name"] = "curved-rail", ["position"] = {["x"] = 4, ["y"] = 20}, ["direction"] = 3}, {["name"] = "straight-rail", ["position"] = {["x"] = 3, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 5, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 9, [
["straight"] = {{["name"] = "straight-rail", ["position"] = {["x"] = 1, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 3, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 5, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 9, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 13, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 17, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 21, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 23, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 25, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 27, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 29, ["y"] = 11}, ["direction"] = 2}, {["name"] = "rail-signal", ["position"] = {["x"] = 1.5, ["y"] = 12.5}, ["direction"] = 6}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 3, ["y"] = 15}, ["direction"] = 0}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 27, ["y"] = 15}, ["direction"] = 0}, {["name"] = "rail-signal", ["position"] = {["x"] = 28.5, ["y"] = 17.5}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 1, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 3, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 5, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 9, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 13, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 17, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 21, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 23, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 25, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 27, ["y"] = 19}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 29, ["y"] = 19}, ["direction"] = 2}},
["corner"] = {{["name"] = "straight-rail", ["position"] = {["x"] = 1, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 3, ["y"] = 11}, ["direction"] = 2}, {["name"] = "curved-rail", ["position"] = {["x"] = 8, ["y"] = 12}, ["direction"] = 3}, {["name"] = "rail-signal", ["position"] = {["x"] = 1.5, ["y"] = 12.5}, ["direction"] = 6}, {["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 15}, ["direction"] = 1}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 3, ["y"] = 15}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 13, ["y"] = 15}, ["direction"] = 5}, {["name"] = "straight-rail", ["position"] = {["x"] = 13, ["y"] = 17}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 17}, ["direction"] = 5}, {["name"] = "straight-rail", ["position"] = {["x"] = 15, ["y"] = 19}, ["direction"] = 1}, {["name"] = "curved-rail", ["position"] = {["x"] = 4, ["y"] = 20}, ["direction"] = 3}, {["name"] = "curved-rail", ["position"] = {["x"] = 18, ["y"] = 22}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 23}, ["direction"] = 1}, {["name"] = "curved-rail", ["position"] = {["x"] = 10, ["y"] = 26}, ["direction"] = 0}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 15, ["y"] = 27}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 27}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 29}, ["direction"] = 0}},
["ushape"] = {{["name"] = "curved-rail", ["position"] = {["x"] = 12, ["y"] = 4}, ["direction"] = 6}, {["name"] = "curved-rail", ["position"] = {["x"] = 20, ["y"] = 4}, ["direction"] = 3}, {["name"] = "straight-rail", ["position"] = {["x"] = 9, ["y"] = 7}, ["direction"] = 7}, {["name"] = "straight-rail", ["position"] = {["x"] = 23, ["y"] = 7}, ["direction"] = 1}, {["name"] = "curved-rail", ["position"] = {["x"] = 4, ["y"] = 10}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 7}, ["direction"] = 3}, {["name"] = "curved-rail", ["position"] = {["x"] = 26, ["y"] = 10}, ["direction"] = 0}, {["name"] = "rail-signal", ["position"] = {["x"] = 7.5, ["y"] = 9.5}, ["direction"] = 5}, {["name"] = "big-electric-pole", ["position"] = {["x"] = 3, ["y"] = 15}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 27, ["y"] = 15}, ["direction"] = 0}, {["name"] = "curved-rail", ["position"] = {["x"] = 26, ["y"] = 20}, ["direction"] = 5}, {["name"] = "curved-rail", ["position"] = {["x"] = 4, ["y"] = 20}, ["direction"] = 3}, {["name"] = "straight-rail", ["position"] = {["x"] = 7, ["y"] = 23}, ["direction"] = 1}, {["name"] = "straight-rail", ["position"] = {["x"] = 9, ["y"] = 23}, ["direction"] = 5}, {["name"] = "curved-rail", ["position"] = {["x"] = 12, ["y"] = 26}, ["direction"] = 7}, {["name"] = "curved-rail", ["position"] = {["x"] = 20, ["y"] = 26}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 23, ["y"] = 23}, ["direction"] = 3}}
}
local paddings = {
[2] = {{["name"] = "straight-rail", ["position"] = {["x"] = 31, ["y"] = 11}, ["direction"] = 2}, {["name"] = "straight-rail", ["position"] = {["x"] = 31, ["y"] = 19}, ["direction"] = 2}},
[4] = {{["name"] = "straight-rail", ["position"] = {["x"] = 11, ["y"] = 31}, ["direction"] = 0}, {["name"] = "straight-rail", ["position"] = {["x"] = 19, ["y"] = 31}, ["direction"] = 0}}
}
local bitmap = {[18] = {[-29] = 1, [-38] = 1, [-43] = 1, [41] = 1, [32] = 1, [27] = 1, [-4] = 1, [18] = 1, [-9] = 1, [13] = 1, [-18] = 1, [-37] = 1, [-51] = 1, [38] = 1, [33] = 1, [24] = 1, [-3] = 1, [-12] = 1, [-17] = 1, [-26] = 1, [-40] = 1, [-45] = 1, [39] = 1, [30] = 1, [-6] = 1, [-20] = 1, [2] = 1, [-25] = 1, [-34] = 1, [-39] = 1, [-48] = 1, [36] = 1, [31] = 1, [-5] = 1, [-14] = 1, [-19] = 1, [3] = 1, [-28] = 1, [-33] = 1, [-42] = 1, [42] = 1, [37] = 1, [28] = 1, [-8] = 1, [14] = 1, [-13] = 1, [9] = 1, [0] = 1, [-27] = 1, [-36] = 1, [-41] = 1, [-50] = 1, [34] = 1, [29] = 1, [-7] = 1, [15] = 1, [-16] = 1, [6] = 1, [-21] = 1, [1] = 1, [-30] = 1, [-35] = 1, [-44] = 1, [-49] = 1, [40] = 1, [35] = 1, [21] = 1, [12] = 1, [-15] = 1, [-24] = 1}, [32] = {[-18] = 1, [-24] = 1, [-12] = 1, [30] = 1, [24] = 1, [-9] = 1, [3] = 1, [-6] = 1, [-15] = 1, [33] = 1}, [-21] = {[-30] = 1, [-37] = 1, [-48] = 1, [50] = 1, [43] = 1, [32] = 1, [30] = 1, [23] = 1, [-7] = 1, [12] = 1, [-1] = 1, [-2] = 1, [5] = 1, [-9] = 1, [-27] = 1, [-38] = 1, [-45] = 1, [42] = 1, [35] = 1, [24] = 1, [17] = 1, [22] = 1, [-8] = 1, [15] = 1, [-15] = 1, [4] = 1, [-35] = 1, [45] = 1, [34] = 1, [27] = 1, [16] = 1, [9] = 1, [-18] = 1, [-36] = 1, [-43] = 1, [44] = 1, [37] = 1, [-6] = 1, [1] = 1, [-13] = 1, [6] = 1, [-24] = 1, [-33] = 1, [-44] = 1, [49] = 1, [47] = 1, [36] = 1, [29] = 1, [18] = 1, [-3] = 1, [0] = 1, [-14] = 1, [-21] = 1, [-39] = 1, [-34] = 1, [-41] = 1, [48] = 1, [41] = 1, [46] = 1, [39] = 1, [28] = 1, [21] = 1, [3] = 1, [-40] = 1, [-42] = 1, [51] = 1, [40] = 1, [33] = 1, [38] = 1, [31] = 1, [2] = 1, [-12] = 1}, [-4] = {[-36] = 1, [-45] = 1, [-9] = 1, [27] = 1, [18] = 1, [-21] = 1, [-30] = 1, [-33] = 1, [-15] = 1, [21] = 1, [-18] = 1, [0] = 1, [45] = 1, [24] = 1, [-24] = 1, [12] = 1}, [21] = {[28] = 1, [-43] = 1, [-32] = 1, [-23] = 1, [7] = 1, [-14] = 1, [0] = 1, [-5] = 1, [9] = 1, [18] = 1, [27] = 1, [36] = 1, [-44] = 1, [-17] = 1, [-24] = 1, [6] = 1, [-15] = 1, [15] = 1, [-6] = 1, [8] = 1, [17] = 1, [35] = 1, [-45] = 1, [-36] = 1, [-27] = 1, [-18] = 1, [-9] = 1, [5] = 1, [-16] = 1, [14] = 1, [-7] = 1, [16] = 1, [34] = 1, [-28] = 1, [-19] = 1, [-10] = 1, [4] = 1, [13] = 1, [-8] = 1, [31] = 1, [24] = 1, [33] = 1, [42] = 1, [-49] = 1, [-29] = 1, [-20] = 1, [-11] = 1, [3] = 1, [12] = 1, [21] = 1, [30] = 1, [39] = 1, [32] = 1, [41] = 1, [-50] = 1, [-48] = 1, [-39] = 1, [-30] = 1, [-21] = 1, [-12] = 1, [-3] = 1, [29] = 1, [40] = 1, [-51] = 1, [-42] = 1, [-33] = 1, [-31] = 1, [-22] = 1, [-13] = 1, [-4] = 1}, [-43] = {[-3] = 1, [6] = 1, [-24] = 1, [33] = 1, [-15] = 1, [3] = 1, [12] = 1, [-9] = 1, [9] = 1, [18] = 1}, [-24] = {[-33] = 1, [12] = 1, [-3] = 1, [42] = 1, [-28] = 1, [17] = 1, [-21] = 1, [24] = 1, [-39] = 1, [6] = 1, [-16] = 1, [-9] = 1, [36] = 1, [43] = 1, [-27] = 1, [18] = 1, [-20] = 1, [25] = 1, [0] = 1, [7] = 1, [48] = 1, [-15] = 1, [44] = 1, [-19] = 1, [26] = 1, [8] = 1, [15] = 1, [49] = 1, [-32] = 1, [45] = 1, [-18] = 1, [27] = 1, [-36] = 1, [9] = 1, [50] = 1, [-6] = 1, [39] = 1, [-31] = 1, [46] = 1, [-24] = 1, [21] = 1, [-17] = 1, [-42] = 1, [3] = 1, [-35] = 1, [10] = 1, [51] = 1, [-12] = 1, [33] = 1, [40] = 1, [-30] = 1, [47] = 1, [-23] = 1, [22] = 1, [-34] = 1, [11] = 1, [41] = 1, [-29] = 1, [16] = 1, [-22] = 1, [23] = 1, [30] = 1}, [-6] = {[34] = 1, [45] = 1, [52] = 1, [-49] = 1, [-42] = 1, [-47] = 1, [-40] = 1, [4] = 1, [-29] = 1, [15] = 1, [-11] = 1, [-4] = 1, [24] = 1, [35] = 1, [42] = 1, [53] = 1, [-52] = 1, [-41] = 1, [-34] = 1, [-39] = 1, [5] = 1, [-32] = 1, [12] = 1, [-21] = 1, [30] = 1, [-3] = 1, [32] = 1, [50] = 1, [-51] = 1, [-33] = 1, [2] = 1, [-31] = 1, [13] = 1, [-24] = 1, [31] = 1, [-6] = 1, [38] = 1, [33] = 1, [40] = 1, [51] = 1, [-54] = 1, [-36] = 1, [3] = 1, [-18] = 1, [21] = 1, [28] = 1, [-5] = 1, [39] = 1, [46] = 1, [41] = 1, [48] = 1, [-53] = 1, [-46] = 1, [-35] = 1, [-28] = 1, [0] = 1, [-10] = 1, [18] = 1, [-15] = 1, [29] = 1, [36] = 1, [47] = 1, [54] = 1, [49] = 1, [-45] = 1, [-38] = 1, [6] = 1, [-27] = 1, [1] = 1, [8] = 1, [-9] = 1, [-1] = 1, [-2] = 1, [37] = 1, [-50] = 1, [-48] = 1, [-37] = 1, [7] = 1, [-30] = 1,
local function build_intersection(type, origin, rot)
local surface = game.surfaces[1]
for _, v in pairs(rail_grid[type]) do
local pos = rot_pos(v.position, rot)
local dir = rot_dir(v.direction, rot)
surface.create_entity{name=v.name, position={origin.x + pos.x, origin.y + pos.y}, force="neutral", direction=dir}
end
end
-- dirs : {E, S, W, N}, array of 0/1
local function build_chunk(origin, dirs)
local surface = game.surfaces[1]
local cnt = 0
local sum = {x = 0, y = 0}
local delta = {x = 1, y = 0}
for dir, b in ipairs(dirs) do
cnt = cnt + b
sum = {x = sum.x + delta.x * b, y = sum.y + delta.y * b}
delta = {x = -delta.y, y = delta.x}
if b == 1 and paddings[dir*2] ~= nil then
-- build paddings
for _, v in pairs(paddings[dir*2]) do
surface.create_entity{name=v.name, position={origin.x + v.position.x, origin.y + v.position.y}, force="neutral", direction=v.direction}
end
end
end
if cnt == 4 then
build_intersection("allway", origin, {x = 1, y = 0})
elseif cnt == 3 then
build_intersection("tshape", origin, {x = sum.y, y = -sum.x})
elseif cnt == 2 then
if sum.x == 0 and sum.y == 0 then
build_intersection("straight", origin, {x = dirs[1], y = dirs[2]})
else
build_intersection("corner", origin, {x = (sum.y - sum.x) / 2, y = -(sum.y + sum.x) / 2})
end
elseif cnt == 1 then
build_intersection("ushape", origin, {x = -sum.x, y = -sum.y})
end
end
local function is_on_grid(gx, gy)
if bitmap[gx] and bitmap[gx][gy] == 1 then
return true
else
return false
end
end
local function find_connections(gx, gy)
local dd = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}
if is_on_grid(gx, gy) then
local c = {}
for _, d in ipairs(dd) do
if is_on_grid(gx + d[1], gy + d[2]) then
table.insert(c, 1)
else
table.insert(c, 0)
end
end
return c
else
return {0,0,0,0}
end
end
local function disable_items()
force = game.forces["player"]
force.recipes["logistic-chest-requester"].enabled = false
force.recipes["underground-belt"].enabled = false
force.recipes["fast-underground-belt"].enabled = false
force.recipes["express-underground-belt"].enabled = false
end
function mymodule.on_chunk_generated(event)
local bd_box = event.area
local surface = event.surface
local chunk_size = 32
-- assert(chunk_size == bd_box.right_bottom.x - bd_box.left_top.x)
-- assert(chunk_size == bd_box.right_bottom.y - bd_box.left_top.y)
if surface ~= game.surfaces[1] then return end
local gx = bd_box.left_top.x / 32
local gy = bd_box.left_top.y / 32
if is_on_grid(gx, gy) then
-- remove trees and resources
for _, e in pairs(surface.find_entities_filtered{area=bd_box, type="tree"}) do
e.destroy()
end
for _, e in pairs(surface.find_entities_filtered{area=bd_box, type="resource"}) do
e.destroy()
end
for _, e in pairs(surface.find_entities_filtered{area=bd_box, type="simple-entity"}) do
e.destroy()
end
build_chunk({x=gx*chunk_size, y=gy*chunk_size}, find_connections(gx, gy))
end
end
return mymodule