1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-11 13:39:14 +02:00

captains can no longer open red chests in restricted areas

This commit is contained in:
danielmartin0 2024-09-15 18:10:08 +01:00
parent 1d6ce41f11
commit f10ee917d9
2 changed files with 83 additions and 109 deletions

View File

@ -2225,10 +2225,15 @@ local function event_on_gui_opened(event)
if not player then return end
if not player.valid then return end
if player.permission_group.name ~= 'restricted_area' then return end
if entity.name == 'wooden-chest' or entity.name == 'iron-chest' or entity.name == 'steel-chest' or entity.name == 'red-chest' or entity.name == 'blue-chest' then
player.opened = nil
if player.permission_group.name == 'cabin_privileged' then
if entity.name == 'red-chest' then
-- Even the captain has to wait for items to be removed from the red chests by loaders:
player.opened = nil
end
elseif player.permission_group.name == 'cabin' then
if entity.name == 'wooden-chest' or entity.name == 'iron-chest' or entity.name == 'steel-chest' or entity.name == 'red-chest' or entity.name == 'blue-chest' then
player.opened = nil
end
end
end

View File

@ -562,112 +562,92 @@ function Public.captain_tax(captain_index)
end
end
function Public.try_create_permissions_groups()
if not game.permissions.get_group('restricted_area') then
local group = game.permissions.create_group('restricted_area')
if not _DEBUG then
group.set_allows_action(defines.input_action.edit_permission_group, false)
end
group.set_allows_action(defines.input_action.import_permissions_string, false)
group.set_allows_action(defines.input_action.delete_permission_group, false)
group.set_allows_action(defines.input_action.add_permission_group, false)
group.set_allows_action(defines.input_action.admin_action, false)
group.set_allows_action(defines.input_action.cancel_craft, false)
group.set_allows_action(defines.input_action.drop_item, false)
group.set_allows_action(defines.input_action.drop_blueprint_record, false)
group.set_allows_action(defines.input_action.build, false)
group.set_allows_action(defines.input_action.build_rail, false)
group.set_allows_action(defines.input_action.build_terrain, false)
group.set_allows_action(defines.input_action.begin_mining, false)
group.set_allows_action(defines.input_action.begin_mining_terrain, false)
-- group.set_allows_action(defines.input_action.deconstruct, false) --pick up dead players
group.set_allows_action(defines.input_action.activate_copy, false)
group.set_allows_action(defines.input_action.activate_cut, false)
group.set_allows_action(defines.input_action.activate_paste, false)
group.set_allows_action(defines.input_action.upgrade, false)
group.set_allows_action(defines.input_action.deconstruct, false)
local function set_normal_permissions(group)
if not _DEBUG then
group.set_allows_action(defines.input_action.edit_permission_group, false)
end
group.set_allows_action(defines.input_action.import_permissions_string, false)
group.set_allows_action(defines.input_action.delete_permission_group, false)
group.set_allows_action(defines.input_action.add_permission_group, false)
group.set_allows_action(defines.input_action.admin_action, false)
if not CoreData.blueprint_library_allowed then
group.set_allows_action(defines.input_action.open_blueprint_library_gui, false)
group.set_allows_action(defines.input_action.grab_blueprint_record, false)
if not CoreData.blueprint_library_allowed then
group.set_allows_action(defines.input_action.open_blueprint_library_gui, false)
end
if not CoreData.blueprint_importing_allowed then
group.set_allows_action(defines.input_action.import_blueprint_string, false)
group.set_allows_action(defines.input_action.import_blueprint, false)
end
end
if not CoreData.blueprint_importing_allowed then
group.set_allows_action(defines.input_action.import_blueprint_string, false)
group.set_allows_action(defines.input_action.import_blueprint, false)
end
end
group.set_allows_action(defines.input_action.fast_entity_transfer, false)
group.set_allows_action(defines.input_action.fast_entity_split, false)
local function set_restricted_permissions(group)
set_normal_permissions(group)
group.set_allows_action(defines.input_action.cancel_craft, false)
group.set_allows_action(defines.input_action.drop_item, false)
group.set_allows_action(defines.input_action.drop_blueprint_record, false)
group.set_allows_action(defines.input_action.build, false)
group.set_allows_action(defines.input_action.build_rail, false)
group.set_allows_action(defines.input_action.build_terrain, false)
group.set_allows_action(defines.input_action.begin_mining, false)
group.set_allows_action(defines.input_action.begin_mining_terrain, false)
group.set_allows_action(defines.input_action.activate_copy, false)
group.set_allows_action(defines.input_action.activate_cut, false)
group.set_allows_action(defines.input_action.activate_paste, false)
group.set_allows_action(defines.input_action.upgrade, false)
group.set_allows_action(defines.input_action.deconstruct, false)
group.set_allows_action(defines.input_action.fast_entity_transfer, false)
group.set_allows_action(defines.input_action.fast_entity_split, false)
end
function Public.try_create_permissions_groups()
if not game.permissions.get_group('lobby') then
local group = game.permissions.create_group('lobby')
set_restricted_permissions(group)
end
if not game.permissions.get_group('crowsnest') then
local group = game.permissions.create_group('crowsnest')
set_restricted_permissions(group)
group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players
end
if not game.permissions.get_group('crowsnest_privileged') then
local group = game.permissions.create_group('crowsnest_privileged')
set_restricted_permissions(group)
group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players
group.set_allows_action(defines.input_action.fast_entity_transfer, true)
group.set_allows_action(defines.input_action.fast_entity_split, true)
end
if not game.permissions.get_group('cabin') then
local group = game.permissions.create_group('cabin')
group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players
set_restricted_permissions(group)
-- Note there is other code to prevent these players from opening chests
end
if not game.permissions.get_group('restricted_area_privileged') then
local group = game.permissions.create_group('restricted_area_privileged')
if not _DEBUG then
group.set_allows_action(defines.input_action.edit_permission_group, false)
end
group.set_allows_action(defines.input_action.import_permissions_string, false)
group.set_allows_action(defines.input_action.delete_permission_group, false)
group.set_allows_action(defines.input_action.add_permission_group, false)
group.set_allows_action(defines.input_action.admin_action, false)
if not game.permissions.get_group('cabin_privileged') then
local group = game.permissions.create_group('cabin_privileged')
group.set_allows_action(defines.input_action.deconstruct, true) --pick up dead players
set_restricted_permissions(group)
group.set_allows_action(defines.input_action.cancel_craft, false)
group.set_allows_action(defines.input_action.drop_item, false)
group.set_allows_action(defines.input_action.drop_blueprint_record, false)
group.set_allows_action(defines.input_action.build, false)
group.set_allows_action(defines.input_action.build_rail, false)
group.set_allows_action(defines.input_action.build_terrain, false)
group.set_allows_action(defines.input_action.begin_mining, false)
group.set_allows_action(defines.input_action.begin_mining_terrain, false)
-- group.set_allows_action(defines.input_action.deconstruct, false) --pick up dead players
group.set_allows_action(defines.input_action.activate_copy, false)
group.set_allows_action(defines.input_action.activate_cut, false)
group.set_allows_action(defines.input_action.activate_paste, false)
group.set_allows_action(defines.input_action.upgrade, false)
group.set_allows_action(defines.input_action.deconstruct, false)
if not CoreData.blueprint_library_allowed then
group.set_allows_action(defines.input_action.open_blueprint_library_gui, false)
group.set_allows_action(defines.input_action.grab_blueprint_record, false)
end
if not CoreData.blueprint_importing_allowed then
group.set_allows_action(defines.input_action.import_blueprint_string, false)
group.set_allows_action(defines.input_action.import_blueprint, false)
end
-- Note there is other code to prevent these players from opening chests
end
if not game.permissions.get_group('plebs') then
local group = game.permissions.create_group('plebs')
if not _DEBUG then
group.set_allows_action(defines.input_action.edit_permission_group, false)
end
group.set_allows_action(defines.input_action.import_permissions_string, false)
group.set_allows_action(defines.input_action.delete_permission_group, false)
group.set_allows_action(defines.input_action.add_permission_group, false)
group.set_allows_action(defines.input_action.admin_action, false)
if not CoreData.blueprint_library_allowed then
group.set_allows_action(defines.input_action.open_blueprint_library_gui, false)
group.set_allows_action(defines.input_action.grab_blueprint_record, false)
end
if not CoreData.blueprint_importing_allowed then
group.set_allows_action(defines.input_action.import_blueprint_string, false)
group.set_allows_action(defines.input_action.import_blueprint, false)
end
set_normal_permissions(group)
end
if not game.permissions.get_group('not_trusted') then
local group = game.permissions.create_group('not_trusted')
set_normal_permissions(group)
-- not_trusted.set_allows_action(defines.input_action.cancel_craft, false)
if not _DEBUG then
group.set_allows_action(defines.input_action.edit_permission_group, false)
end
group.set_allows_action(defines.input_action.import_permissions_string, false)
group.set_allows_action(defines.input_action.delete_permission_group, false)
group.set_allows_action(defines.input_action.add_permission_group, false)
group.set_allows_action(defines.input_action.admin_action, false)
-- not_trusted.set_allows_action(defines.input_action.drop_item, false)
group.set_allows_action(defines.input_action.disconnect_rolling_stock, false)
group.set_allows_action(defines.input_action.connect_rolling_stock, false)
@ -683,15 +663,6 @@ function Public.try_create_permissions_groups()
group.set_allows_action(defines.input_action.remove_train_station, false)
group.set_allows_action(defines.input_action.set_trains_limit, false)
group.set_allows_action(defines.input_action.set_train_stopped, false)
group.set_allows_action(defines.input_action.grab_blueprint_record, false)
if not CoreData.blueprint_library_allowed then
group.set_allows_action(defines.input_action.open_blueprint_library_gui, false)
end
if not CoreData.blueprint_importing_allowed then
group.set_allows_action(defines.input_action.import_blueprint_string, false)
group.set_allows_action(defines.input_action.import_blueprint, false)
end
end
end
@ -749,20 +720,18 @@ function Public.update_privileges(player)
if string.sub(player.surface.name, 9, 17) == 'Crowsnest' then
if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then
return Public.add_player_to_permission_group(player, 'restricted_area_privileged')
return Public.add_player_to_permission_group(player, 'crowsnest_privileged')
else
return Public.add_player_to_permission_group(player, 'restricted_area')
return Public.add_player_to_permission_group(player, 'crowsnest')
end
elseif string.sub(player.surface.name, 9, 13) == 'Cabin' then
if Public.player_privilege_level(player) >= Public.privilege_levels.OFFICER then
return Public.add_player_to_permission_group(player, 'restricted_area_privileged')
return Public.add_player_to_permission_group(player, 'cabin_privileged')
else
-- return Public.add_player_to_permission_group(player, 'restricted_area')
-- Moved to restricted_area to prevent them messing with items in the blue chests.ssd
return Public.add_player_to_permission_group(player, 'restricted_area')
return Public.add_player_to_permission_group(player, 'cabin')
end
elseif player.surface.name == CoreData.lobby_surface_name then
return Public.add_player_to_permission_group(player, 'restricted_area')
return Public.add_player_to_permission_group(player, 'lobby')
else
return Public.add_player_to_permission_group(player)
end