-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2a3958
commit ad1a3d9
Showing
9 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--[[ | ||
Dump changed tiles | ||
Unlike dump_mapview, this one dumps an array of single tiles. This is less | ||
space efficient than the chunked format for normal exports, but nmore | ||
efficient for many small updates such as what happens when robots build concrete. | ||
]] | ||
|
||
local clusterio_api = require("modules/clusterio/api") | ||
|
||
local function dump_tiles(tiles) | ||
local map_data = {} | ||
for _, tilePosition in pairs(tiles) do | ||
local tile = game.surfaces[1].get_tile(tilePosition) | ||
local map_color = tile.prototype.map_color | ||
table.insert(map_data, tilePosition.x) | ||
table.insert(map_data, tilePosition.y) | ||
table.insert(map_data, string.format("%02x%02x%02x%02x", map_color.r, map_color.g, map_color.b, map_color.a)) | ||
end | ||
|
||
clusterio_api.send_json("gridworld:tile_data", { | ||
type = "pixels", | ||
data = table.concat(map_data, ";"), | ||
layer = "tiles_", | ||
}) | ||
end | ||
|
||
return dump_tiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
local dump_entities = require("modules/gridworld/map/dump_entities") | ||
local dump_tiles = require("modules/gridworld/map/dump_tiles") | ||
|
||
local function on_nth_tick() | ||
if global.gridworld.map.added_entities_to_update or (global.gridworld.map.removed_entities_to_update and #global.gridworld.map.removed_entities_to_update > 0) then | ||
dump_entities(global.gridworld.map.added_entities_to_update, global.gridworld.map.removed_entities_to_update) | ||
global.gridworld.map.added_entities_to_update = nil | ||
global.gridworld.map.removed_entities_to_update = {} | ||
end | ||
if global.gridworld.map.tiles_to_update ~= nil then | ||
dump_tiles(global.gridworld.map.tiles_to_update) | ||
global.gridworld.map.tiles_to_update = nil | ||
end | ||
end | ||
|
||
return on_nth_tick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
local function on_tile_changed(event) | ||
local tiles = event.tiles | ||
if global.gridworld.map.tiles_to_update == nil then | ||
global.gridworld.map.tiles_to_update = {} | ||
end | ||
for _, tile in pairs(tiles) do | ||
table.insert(global.gridworld.map.tiles_to_update, tile.position) | ||
end | ||
end | ||
|
||
return on_tile_changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters