mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-27 16:47:13 +09:00
Nuking forrests with remoteMap no longer produces lagspikes
This commit is contained in:
1 parent
dd9130dc8b
commit
72d5f06381
2 files changed
+17
-9
No files matched your search
@@ -26,18 +26,27 @@ function write_file(data)
|
|||||||
must_write_initstuff = false
|
must_write_initstuff = false
|
||||||
writeout_initial_stuff()
|
writeout_initial_stuff()
|
||||||
end
|
end
|
||||||
|
stringsToWriteNextTick = stringsToWriteNextTick .. data .. '\n'
|
||||||
game.write_file("remoteMap.txt", data, true)
|
-- game.write_file("remoteMap.txt", data, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function dump_cached_writes()
|
||||||
|
game.write_file("remoteMap.txt", stringsToWriteNextTick, true)
|
||||||
|
end
|
||||||
|
|
||||||
function complain(text)
|
function complain(text)
|
||||||
print(text)
|
if false then -- only print during development
|
||||||
game.forces["player"].print(text)
|
print(text)
|
||||||
|
game.forces["player"].print(text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local todo_next_tick = {}
|
local todo_next_tick = {}
|
||||||
function on_tick(event)
|
function on_tick(event)
|
||||||
|
dump_cached_writes()
|
||||||
|
stringsToWriteNextTick = ''
|
||||||
if #todo_next_tick > 0 then
|
if #todo_next_tick > 0 then
|
||||||
print("on_tick executing "..#todo_next_tick.." stored callbacks")
|
complain("on_tick executing "..#todo_next_tick.." stored callbacks")
|
||||||
for _,func in ipairs(todo_next_tick) do
|
for _,func in ipairs(todo_next_tick) do
|
||||||
func()
|
func()
|
||||||
end
|
end
|
||||||
@@ -45,10 +54,8 @@ function on_tick(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function writeout_objects(surface, area)
|
function writeout_objects(surface, area)
|
||||||
--if my_client_id ~= 1 then return end
|
--if my_client_id ~= 1 then return end
|
||||||
header = "objects "..area.left_top.x..","..area.left_top.y..";"..area.right_bottom.x..","..area.right_bottom.y..": "
|
|
||||||
line = ''
|
line = ''
|
||||||
for idx, ent in pairs(surface.find_entities(area)) do
|
for idx, ent in pairs(surface.find_entities(area)) do
|
||||||
if area.left_top.x <= ent.position.x and ent.position.x < area.right_bottom.x and area.left_top.y <= ent.position.y and ent.position.y < area.right_bottom.y then
|
if area.left_top.x <= ent.position.x and ent.position.x < area.right_bottom.x and area.left_top.y <= ent.position.y and ent.position.y < area.right_bottom.y then
|
||||||
@@ -99,6 +106,7 @@ script.on_event(defines.events.on_tick, on_tick)
|
|||||||
script.on_event(defines.events.on_biter_base_built, on_some_entity_created) --entity
|
script.on_event(defines.events.on_biter_base_built, on_some_entity_created) --entity
|
||||||
script.on_event(defines.events.on_built_entity, on_some_entity_created) --created_entity
|
script.on_event(defines.events.on_built_entity, on_some_entity_created) --created_entity
|
||||||
script.on_event(defines.events.on_robot_built_entity, on_some_entity_created) --created_entity
|
script.on_event(defines.events.on_robot_built_entity, on_some_entity_created) --created_entity
|
||||||
|
script.on_event(defines.events.on_player_rotated_entity, on_some_entity_created) --created_entity
|
||||||
|
|
||||||
script.on_event(defines.events.on_entity_died, on_some_entity_deleted) --entity
|
script.on_event(defines.events.on_entity_died, on_some_entity_deleted) --entity
|
||||||
script.on_event(defines.events.on_player_mined_entity, on_some_entity_deleted) --entity
|
script.on_event(defines.events.on_player_mined_entity, on_some_entity_deleted) --entity
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
{
|
{
|
||||||
"name": "remoteMap",
|
"name": "remoteMap",
|
||||||
"title": "Clusterio remote map",
|
"title": "Clusterio remote map",
|
||||||
"version": "2.0.0",
|
"version": "2.1.0",
|
||||||
"date": "18-11-2017",
|
"date": "18-11-2017",
|
||||||
"author": "Danielv123",
|
"author": "Danielv123",
|
||||||
"dependencies": ["base >= 0.15"],
|
"dependencies": ["base >= 0.15"],
|
||||||
"factorio_version": "0.16",
|
"factorio_version": "0.16",
|
||||||
"description": "Clusterio plugin for external mapping and possibly building?"
|
"description": "Clusterio plugin for external mapping and soon also building. Mobile factorio confirmed"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user