mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
The plugin syncs more than inventories now (settings, appearance, recipe notifications), so name it for what it does. The package becomes @clusterio/plugin-player_sync and every inventory_sync identifier follows. A migration entrypoint renames the inventory_sync config fields, including load_plugin, and the inventory view permission. The plugin moves inventories.json in the database directory to player_sync.json and storage.inventory_sync in saves to storage.player_sync itself, and closes dialogs left open under the old GUI names on startup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.3 KiB
Lua
39 lines
1.3 KiB
Lua
local compat = require("modules/clusterio/compat")
|
|
|
|
local can_enter_vehicle = {
|
|
[defines.controllers.character] = true,
|
|
[defines.controllers.god] = true,
|
|
[defines.controllers.editor] = true,
|
|
}
|
|
|
|
if defines.controllers.remote then
|
|
-- Does not exist in 1.1, so we need this nil check
|
|
can_enter_vehicle[defines.controllers.remote] = true
|
|
end
|
|
|
|
local v2_surface_platform = compat.version_ge("2.0.0")
|
|
|
|
--- @param player LuaPlayer
|
|
--- @param record table
|
|
return function(player, record)
|
|
if record.vehicle and record.vehicle.valid and can_enter_vehicle[player.controller_type] then
|
|
player.teleport(record.vehicle.position, record.vehicle.surface)
|
|
player.driving = true
|
|
|
|
-- Teleport to safe location if unable to enter vehicle
|
|
local character = player.character
|
|
if not player.driving and character and player.controller_type == defines.controllers.character then
|
|
local safe_position = record.vehicle.surface.find_non_colliding_position(
|
|
character.name, player.position, 32, 1/8
|
|
)
|
|
if safe_position then
|
|
player.teleport(safe_position, player.surface)
|
|
end
|
|
end
|
|
elseif v2_surface_platform and record.surface and record.surface.platform and can_enter_vehicle[player.controller_type] then
|
|
player.enter_space_platform(record.surface.platform)
|
|
elseif record.surface and record.position then
|
|
player.teleport(record.position, record.surface)
|
|
end
|
|
end
|