mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Expand compat to 0.17 (#711)
This commit is contained in:
1 parent
87746edbf5
commit
ff9ba0271f
8 files changed
+138
-89
No files matched your search
@@ -2,8 +2,7 @@ local compat = require("modules/clusterio/compat")
|
||||
|
||||
--- @param no_early_return boolean? True to always setup data
|
||||
return function(no_early_return)
|
||||
local script_data = compat.script_data()
|
||||
local inventory_sync = script_data.inventory_sync
|
||||
local inventory_sync = compat.script_data.inventory_sync
|
||||
if inventory_sync and not no_early_return then
|
||||
return inventory_sync
|
||||
end
|
||||
@@ -17,6 +16,6 @@ return function(no_early_return)
|
||||
inventory_sync.finished_downloads = inventory_sync.finished_downloads or {}
|
||||
inventory_sync.active_uploads = inventory_sync.active_uploads or {}
|
||||
|
||||
script_data.inventory_sync = inventory_sync
|
||||
compat.script_data.inventory_sync = inventory_sync
|
||||
return inventory_sync
|
||||
end
|
||||
@@ -360,7 +360,7 @@ end
|
||||
-- Upload inventory when a player leaves the game. Triggers on restart after crash if player was online during crash.
|
||||
inventory_sync.events[defines.events.on_pre_player_left_game] = function(event)
|
||||
-- for some reason, on_pre_player_left_game gets called before on_server_startup so script_data isn't ready yet
|
||||
if not compat.script_data().inventory_sync then
|
||||
if not compat.script_data.inventory_sync then
|
||||
log("ERROR: script data for inventory sync is not defined")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -33,8 +33,7 @@ end
|
||||
--- @param no_early_return boolean?
|
||||
--- @return table
|
||||
local function get_script_data(no_early_return)
|
||||
local script_data = compat.script_data()
|
||||
local research_sync = script_data.research_sync
|
||||
local research_sync = compat.script_data.research_sync
|
||||
if research_sync and not no_early_return then
|
||||
return research_sync
|
||||
end
|
||||
@@ -56,7 +55,7 @@ local function get_script_data(no_early_return)
|
||||
}
|
||||
end
|
||||
|
||||
script_data.research_sync = research_sync
|
||||
compat.script_data.research_sync = research_sync
|
||||
return research_sync
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user