2020-04-18 21:28:19 +02:00
-- config tab --
2020-04-18 21:09:11 +02:00
2020-08-22 17:20:59 +02:00
local Antigrief = require ' antigrief '
2020-08-22 18:08:39 +02:00
local Color = require ' utils.color_presets '
2020-08-22 17:20:59 +02:00
local SessionData = require ' utils.datastore.session_data '
2020-08-22 17:30:28 +02:00
local Utils = require ' utils.core '
2020-04-18 21:09:11 +02:00
local spaghett_entity_blacklist = {
2020-08-22 17:20:59 +02:00
[ ' logistic-chest-requester ' ] = true ,
[ ' logistic-chest-buffer ' ] = true ,
[ ' logistic-chest-active-provider ' ] = true
2020-04-18 21:09:11 +02:00
}
2020-08-22 20:15:56 +02:00
local function get_actor ( event , prefix , msg , admins_only )
2020-08-22 17:20:59 +02:00
local player = game.get_player ( event.player_index )
if not player or not player.valid then
return
end
2020-08-22 20:15:56 +02:00
if admins_only then
Utils.print_admins ( msg , player.name )
else
Utils.action_warning ( prefix , player.name .. ' ' .. msg )
end
2020-08-22 17:20:59 +02:00
end
2020-04-18 21:09:11 +02:00
local function spaghett_deny_building ( event )
2020-08-22 17:20:59 +02:00
local spaghett = global.comfy_panel_config . spaghett
if not spaghett.enabled then
return
end
local entity = event.created_entity
if not entity.valid then
return
end
if not spaghett_entity_blacklist [ event.created_entity . name ] then
return
end
if event.player_index then
game.players [ event.player_index ] . insert ( { name = entity.name , count = 1 } )
else
local inventory = event.robot . get_inventory ( defines.inventory . robot_cargo )
inventory.insert ( { name = entity.name , count = 1 } )
end
event.created_entity . surface.create_entity (
{
name = ' flying-text ' ,
position = entity.position ,
text = ' Spaghett Mode Active! ' ,
color = { r = 0.98 , g = 0.66 , b = 0.22 }
}
)
entity.destroy ( )
2020-04-18 21:09:11 +02:00
end
local function spaghett ( )
2020-08-22 17:20:59 +02:00
local spaghett = global.comfy_panel_config . spaghett
if spaghett.enabled then
for _ , f in pairs ( game.forces ) do
if f.technologies [ ' logistic-system ' ] . researched then
spaghett.undo [ f.index ] = true
end
f.technologies [ ' logistic-system ' ] . enabled = false
f.technologies [ ' logistic-system ' ] . researched = false
end
else
for _ , f in pairs ( game.forces ) do
f.technologies [ ' logistic-system ' ] . enabled = true
if spaghett.undo [ f.index ] then
f.technologies [ ' logistic-system ' ] . researched = true
spaghett.undo [ f.index ] = nil
end
end
end
end
local function trust_connected_players ( )
local trust = SessionData.get_trusted_table ( )
local AG = Antigrief.get ( )
local players = game.connected_players
if not AG.enabled then
for _ , p in pairs ( players ) do
trust [ p.name ] = true
end
else
for _ , p in pairs ( players ) do
trust [ p.name ] = false
end
end
2020-04-18 21:09:11 +02:00
end
local functions = {
2020-08-22 17:20:59 +02:00
[ ' comfy_panel_spectator_switch ' ] = function ( event )
if event.element . switch_state == ' left ' then
game.players [ event.player_index ] . spectator = true
else
game.players [ event.player_index ] . spectator = false
end
end ,
[ ' comfy_panel_auto_hotbar_switch ' ] = function ( event )
if event.element . switch_state == ' left ' then
global.auto_hotbar_enabled [ event.player_index ] = true
else
global.auto_hotbar_enabled [ event.player_index ] = false
end
end ,
[ ' comfy_panel_blueprint_toggle ' ] = function ( event )
if event.element . switch_state == ' left ' then
game.permissions . get_group ( ' Default ' ) . set_allows_action (
defines.input_action . open_blueprint_library_gui ,
true
)
game.permissions . get_group ( ' Default ' ) . set_allows_action ( defines.input_action . import_blueprint_string , true )
2020-08-22 18:14:04 +02:00
get_actor ( event , ' {Blueprints} ' , ' has enabled blueprints! ' )
2020-08-22 17:20:59 +02:00
else
game.permissions . get_group ( ' Default ' ) . set_allows_action (
defines.input_action . open_blueprint_library_gui ,
false
)
game.permissions . get_group ( ' Default ' ) . set_allows_action ( defines.input_action . import_blueprint_string , false )
2020-08-22 18:14:04 +02:00
get_actor ( event , ' {Blueprints} ' , ' has disabled blueprints! ' )
2020-08-22 17:20:59 +02:00
end
end ,
[ ' comfy_panel_spaghett_toggle ' ] = function ( event )
if event.element . switch_state == ' left ' then
global.comfy_panel_config . spaghett.enabled = true
2020-08-22 18:14:04 +02:00
get_actor ( event , ' {Spaghett} ' , ' has enabled spaghett mode! ' )
2020-08-22 17:20:59 +02:00
else
global.comfy_panel_config . spaghett.enabled = nil
2020-08-22 18:14:04 +02:00
get_actor ( event , ' {Spaghett} ' , ' has disabled spaghett mode! ' )
2020-08-22 17:20:59 +02:00
end
spaghett ( )
2020-09-08 15:21:03 +02:00
end ,
[ " bb_team_balancing_toggle " ] = function ( event )
if event.element . switch_state == " left " then
global.bb_settings . team_balancing = true
game.print ( " Team balancing has been enabled! " )
else
global.bb_settings . team_balancing = false
game.print ( " Team balancing has been disabled! " )
end
end ,
[ " bb_only_admins_vote " ] = function ( event )
if event.element . switch_state == " left " then
global.bb_settings . only_admins_vote = true
global.difficulty_player_votes = { }
game.print ( " Admin-only difficulty voting has been enabled! " )
else
global.bb_settings . only_admins_vote = false
game.print ( " Admin-only difficulty voting has been disabled! " )
end
end ,
2020-04-18 21:09:11 +02:00
}
2020-04-27 23:33:28 +02:00
local poll_function = {
2020-08-22 17:20:59 +02:00
[ ' comfy_panel_poll_trusted_toggle ' ] = function ( event )
if event.element . switch_state == ' left ' then
global.comfy_panel_config . poll_trusted = true
2020-08-22 18:14:04 +02:00
get_actor ( event , ' {Poll Mode} ' , ' has disabled non-trusted people to do polls. ' )
2020-08-22 17:20:59 +02:00
else
global.comfy_panel_config . poll_trusted = false
2020-08-22 18:14:04 +02:00
get_actor ( event , ' {Poll Mode} ' , ' has allowed non-trusted people to do polls. ' )
2020-08-22 17:20:59 +02:00
end
end ,
[ ' comfy_panel_poll_no_notify_toggle ' ] = function ( event )
local poll = package.loaded [ ' comfy_panel.poll ' ]
local poll_table = poll.get_no_notify_players ( )
if event.element . switch_state == ' left ' then
poll_table [ event.player_index ] = false
else
poll_table [ event.player_index ] = true
end
end
}
local antigrief_functions = {
[ ' comfy_panel_disable_antigrief ' ] = function ( event )
local AG = Antigrief.get ( )
if event.element . switch_state == ' left ' then
AG.enabled = true
2020-08-22 20:15:56 +02:00
get_actor ( event , ' {Antigrief} ' , ' has enabled the antigrief function. ' , true )
2020-08-22 17:20:59 +02:00
else
AG.enabled = false
2020-08-22 20:15:56 +02:00
get_actor ( event , ' {Antigrief} ' , ' has disabled the antigrief function. ' , true )
2020-08-22 17:20:59 +02:00
end
trust_connected_players ( )
end
2020-04-27 23:33:28 +02:00
}
2020-08-22 18:08:39 +02:00
local fortress_functions = {
[ ' comfy_panel_disable_fullness ' ] = function ( event )
2020-08-26 11:08:12 +02:00
local Fullness = package.loaded [ ' modules.check_fullness ' ]
local this = Fullness.get ( )
2020-08-22 18:08:39 +02:00
if event.element . switch_state == ' left ' then
this.fullness_enabled = true
get_actor ( event , ' {Fullness} ' , ' has enabled the inventory fullness function. ' )
else
this.fullness_enabled = false
get_actor ( event , ' {Fullness} ' , ' has disabled the inventory fullness function. ' )
end
end ,
[ ' comfy_panel_offline_players ' ] = function ( event )
local WPT = package.loaded [ ' maps.mountain_fortress_v3.table ' ]
local this = WPT.get ( )
if event.element . switch_state == ' left ' then
this.offline_players_enabled = true
get_actor ( event , ' {Offline Players} ' , ' has enabled the offline player function. ' )
else
this.offline_players_enabled = false
get_actor ( event , ' {Offline Players} ' , ' has disabled the offline player function. ' )
end
end ,
[ ' comfy_panel_collapse_grace ' ] = function ( event )
local WPT = package.loaded [ ' maps.mountain_fortress_v3.table ' ]
local this = WPT.get ( )
if event.element . switch_state == ' left ' then
this.collapse_grace = true
get_actor ( event , ' {Collapse} ' , ' has enabled the collapse function. Collapse will occur after wave 100! ' )
else
this.collapse_grace = false
get_actor (
event ,
' {Collapse} ' ,
' has disabled the collapse function. You must reach zone 2 for collapse to occur! '
)
end
end ,
[ ' comfy_panel_spill_items_to_surface ' ] = function ( event )
local WPT = package.loaded [ ' maps.mountain_fortress_v3.table ' ]
local this = WPT.get ( )
if event.element . switch_state == ' left ' then
this.spill_items_to_surface = true
get_actor (
event ,
' {Item Spill} ' ,
' has enabled the ore spillage function. Ores now drop to surface when mining. '
)
else
this.spill_items_to_surface = false
get_actor (
event ,
' {Item Spill} ' ,
' has disabled the item spillage function. Ores no longer drop to surface when mining. '
)
end
2020-08-22 20:28:24 +02:00
end ,
[ ' comfy_panel_void_or_tile ' ] = function ( event )
local WPT = package.loaded [ ' maps.mountain_fortress_v3.table ' ]
local this = WPT.get ( )
if event.element . switch_state == ' left ' then
this.void_or_tile = ' out-of-map '
2020-08-27 13:27:34 +02:00
get_actor ( event , ' {Void} ' , ' has changes the tiles of the zones to: out-of-map (void) ' )
2020-08-22 20:28:24 +02:00
else
this.void_or_tile = ' lab-dark-2 '
2020-08-27 13:27:34 +02:00
get_actor ( event , ' {Void} ' , ' has changes the tiles of the zones to: dark-tiles (flammable tiles) ' )
end
end ,
[ ' comfy_panel_trusted_only_car_tanks ' ] = function ( event )
local WPT = package.loaded [ ' maps.mountain_fortress_v3.table ' ]
local this = WPT.get ( )
if event.element . switch_state == ' left ' then
this.trusted_only_car_tanks = true
get_actor ( event , ' {Market} ' , ' has changed so only trusted people can buy car/tanks. ' , true )
else
this.trusted_only_car_tanks = false
2020-08-27 13:28:21 +02:00
get_actor ( event , ' {Market} ' , ' has changed so everybody can buy car/tanks. ' , true )
2020-08-22 20:28:24 +02:00
end
2020-08-22 18:08:39 +02:00
end
}
2020-04-18 21:09:11 +02:00
local function add_switch ( element , switch_state , name , description_main , description )
2020-08-22 17:20:59 +02:00
local t = element.add ( { type = ' table ' , column_count = 5 } )
local label = t.add ( { type = ' label ' , caption = ' ON ' } )
label.style . padding = 0
label.style . left_padding = 10
label.style . font_color = { 0.77 , 0.77 , 0.77 }
local switch = t.add ( { type = ' switch ' , name = name } )
switch.switch_state = switch_state
switch.style . padding = 0
switch.style . margin = 0
local label = t.add ( { type = ' label ' , caption = ' OFF ' } )
label.style . padding = 0
label.style . font_color = { 0.70 , 0.70 , 0.70 }
local label = t.add ( { type = ' label ' , caption = description_main } )
label.style . padding = 2
label.style . left_padding = 10
label.style . minimal_width = 120
label.style . font = ' heading-2 '
label.style . font_color = { 0.88 , 0.88 , 0.99 }
local label = t.add ( { type = ' label ' , caption = description } )
label.style . padding = 2
label.style . left_padding = 10
label.style . single_line = false
label.style . font = ' heading-3 '
label.style . font_color = { 0.85 , 0.85 , 0.85 }
return switch
2020-04-18 21:09:11 +02:00
end
2020-08-22 17:20:59 +02:00
local build_config_gui = ( function ( player , frame )
local AG = Antigrief.get ( )
2020-08-22 18:08:39 +02:00
local switch_state
local label
2020-08-22 17:20:59 +02:00
local admin = player.admin
2020-08-22 20:15:56 +02:00
frame.clear ( )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
local scroll_pane =
frame.add {
type = ' scroll-pane ' ,
horizontal_scroll_policy = ' never '
}
local scroll_style = scroll_pane.style
scroll_style.vertically_squashable = true
scroll_style.bottom_padding = 2
scroll_style.left_padding = 2
scroll_style.right_padding = 2
scroll_style.top_padding = 2
label = scroll_pane.add ( { type = ' label ' , caption = ' Player Settings ' } )
2020-08-22 17:20:59 +02:00
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = { 0.55 , 0.55 , 0.99 }
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if player.spectator then
switch_state = ' left '
end
add_switch (
2020-08-22 18:08:39 +02:00
scroll_pane ,
2020-08-22 17:20:59 +02:00
switch_state ,
' comfy_panel_spectator_switch ' ,
' SpectatorMode ' ,
' Toggles zoom-to-world view noise effect. \n Environmental sounds will be based on map view. '
)
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
if global.auto_hotbar_enabled then
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if global.auto_hotbar_enabled [ player.index ] then
switch_state = ' left '
end
add_switch (
2020-08-22 18:08:39 +02:00
scroll_pane ,
2020-08-22 17:20:59 +02:00
switch_state ,
' comfy_panel_auto_hotbar_switch ' ,
' AutoHotbar ' ,
' Automatically fills your hotbar with placeable items. '
)
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
end
if package.loaded [ ' comfy_panel.poll ' ] then
local poll = package.loaded [ ' comfy_panel.poll ' ]
local poll_table = poll.get_no_notify_players ( )
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if not poll_table [ player.index ] then
switch_state = ' left '
end
2020-08-22 18:08:39 +02:00
add_switch (
scroll_pane ,
2020-08-22 17:20:59 +02:00
switch_state ,
' comfy_panel_poll_no_notify_toggle ' ,
' Notify on polls ' ,
' Receive a message when new polls are created and popup the poll. '
)
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
end
if admin then
2020-08-22 18:08:39 +02:00
label = scroll_pane.add ( { type = ' label ' , caption = ' Admin Settings ' } )
2020-08-22 17:20:59 +02:00
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = { 0.77 , 0.11 , 0.11 }
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if game.permissions . get_group ( ' Default ' ) . allows_action ( defines.input_action . open_blueprint_library_gui ) then
switch_state = ' left '
end
2020-08-22 18:08:39 +02:00
add_switch (
scroll_pane ,
2020-08-22 17:20:59 +02:00
switch_state ,
' comfy_panel_blueprint_toggle ' ,
' Blueprint Library ' ,
' Toggles the usage of blueprint strings and the library. '
)
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if global.comfy_panel_config . spaghett.enabled then
switch_state = ' left '
end
2020-08-22 18:08:39 +02:00
add_switch (
scroll_pane ,
2020-08-22 17:20:59 +02:00
switch_state ,
' comfy_panel_spaghett_toggle ' ,
' Spaghett Mode ' ,
' Disables the Logistic System research. \n Requester, buffer or active-provider containers can not be built. '
)
if package.loaded [ ' comfy_panel.poll ' ] then
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if global.comfy_panel_config . poll_trusted then
switch_state = ' left '
end
2020-08-22 18:08:39 +02:00
add_switch (
scroll_pane ,
2020-08-22 17:20:59 +02:00
switch_state ,
' comfy_panel_poll_trusted_toggle ' ,
' Poll mode ' ,
' Disables non-trusted plebs to create polls. '
)
end
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
label = scroll_pane.add ( { type = ' label ' , caption = ' Antigrief Settings ' } )
2020-08-22 17:20:59 +02:00
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
2020-08-22 18:08:39 +02:00
label.style . font_color = Color.yellow
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if AG.enabled then
switch_state = ' left '
end
2020-08-22 18:08:39 +02:00
add_switch (
scroll_pane ,
2020-08-22 17:20:59 +02:00
switch_state ,
' comfy_panel_disable_antigrief ' ,
' Antigrief ' ,
2020-08-27 13:27:34 +02:00
' Left = Enables antigrief / Right = Disables antigrief '
2020-08-22 17:20:59 +02:00
)
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-09-08 15:21:03 +02:00
if package.loaded [ ' maps.biter_battles_v2.main ' ] then
label = scroll_pane.add ( { type = ' label ' , caption = ' Biter Battles Settings ' } )
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = Color.green
scroll_pane.add ( { type = ' line ' } )
local switch_state = " right "
if global.bb_settings . team_balancing then switch_state = " left " end
local switch = add_switch ( scroll_pane , switch_state , " bb_team_balancing_toggle " , " Team Balancing " , " Players can only join a team that has less or equal players than the opposing. " )
if not admin then switch.ignored_by_interaction = true end
scroll_pane.add ( { type = ' line ' } )
local switch_state = " right "
if global.bb_settings . only_admins_vote then switch_state = " left " end
local switch = add_switch ( scroll_pane , switch_state , " bb_only_admins_vote " , " Admin Vote " , " Only admins can vote for map difficulty. Clears all currently existing votes. " )
if not admin then switch.ignored_by_interaction = true end
scroll_pane.add ( { type = ' line ' } )
end
2020-08-22 18:08:39 +02:00
if package.loaded [ ' maps.mountain_fortress_v3.main ' ] then
label = scroll_pane.add ( { type = ' label ' , caption = ' Mountain Fortress Settings ' } )
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = Color.green
2020-08-26 11:08:12 +02:00
local Fullness = package.loaded [ ' modules.check_fullness ' ]
local full = Fullness.get ( )
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-26 11:08:12 +02:00
if full.fullness_enabled then
2020-08-22 18:08:39 +02:00
switch_state = ' left '
end
add_switch (
scroll_pane ,
switch_state ,
' comfy_panel_disable_fullness ' ,
' Inventory Fullness ' ,
2020-08-27 13:27:34 +02:00
' Left = Enables inventory fullness. \n Right = Disables inventory fullness. '
2020-08-22 18:08:39 +02:00
)
scroll_pane.add ( { type = ' line ' } )
2020-08-26 11:08:12 +02:00
local WPT = package.loaded [ ' maps.mountain_fortress_v3.table ' ]
local this = WPT.get ( )
2020-08-22 18:08:39 +02:00
switch_state = ' right '
if this.offline_players_enabled then
switch_state = ' left '
end
add_switch (
scroll_pane ,
switch_state ,
' comfy_panel_offline_players ' ,
' Offline Players ' ,
2020-08-27 13:27:34 +02:00
' Left = Enables offline player inventory drop. \n Right = Disables offline player inventory drop. '
2020-08-22 18:08:39 +02:00
)
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
if this.collapse_grace then
switch_state = ' left '
end
add_switch (
scroll_pane ,
switch_state ,
' comfy_panel_collapse_grace ' ,
' Collapse ' ,
2020-08-27 13:27:34 +02:00
' Left = Enables collapse after wave 100. \n Right = Disables collapse - you must reach zone 2 for collapse to occur. '
2020-08-22 18:08:39 +02:00
)
scroll_pane.add ( { type = ' line ' } )
switch_state = ' right '
if this.spill_items_to_surface then
switch_state = ' left '
end
add_switch (
scroll_pane ,
switch_state ,
' comfy_panel_spill_items_to_surface ' ,
' Spill Ores ' ,
2020-08-27 13:27:34 +02:00
' Left = Enables ore spillage to surface when mining. \n Right = Disables ore spillage to surface when mining. '
2020-08-22 18:08:39 +02:00
)
2020-08-22 18:14:04 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 20:28:24 +02:00
switch_state = ' right '
if this.void_or_tile then
switch_state = ' left '
end
add_switch (
scroll_pane ,
switch_state ,
' comfy_panel_void_or_tile ' ,
' Void Tiles ' ,
2020-08-27 13:27:34 +02:00
' Left = Changes the tiles to out-of-map. \n Right = Changes the tiles to lab-dark-2 '
)
scroll_pane.add ( { type = ' line ' } )
switch_state = ' right '
if this.trusted_only_car_tanks then
switch_state = ' left '
end
add_switch (
scroll_pane ,
switch_state ,
' comfy_panel_trusted_only_car_tanks ' ,
' Market Purchase ' ,
' Left = Allows only trusted people to buy car/tanks. \n Right = Allows everyone to buy car/tanks. '
2020-08-22 20:28:24 +02:00
)
scroll_pane.add ( { type = ' line ' } )
2020-08-22 18:08:39 +02:00
end
2020-08-22 17:20:59 +02:00
end
2020-08-22 18:08:39 +02:00
for _ , e in pairs ( scroll_pane.children ) do
2020-08-22 17:20:59 +02:00
if e.type == ' line ' then
e.style . padding = 0
e.style . margin = 0
end
end
2020-04-18 21:09:11 +02:00
end )
local function on_gui_switch_state_changed ( event )
2020-08-22 17:20:59 +02:00
if not event.element then
return
end
if not event.element . valid then
return
end
if functions [ event.element . name ] then
functions [ event.element . name ] ( event )
return
elseif antigrief_functions [ event.element . name ] then
antigrief_functions [ event.element . name ] ( event )
return
2020-08-22 18:08:39 +02:00
elseif fortress_functions [ event.element . name ] then
fortress_functions [ event.element . name ] ( event )
return
2020-08-22 17:20:59 +02:00
elseif package.loaded [ ' comfy_panel.poll ' ] then
if poll_function [ event.element . name ] then
poll_function [ event.element . name ] ( event )
return
end
end
2020-04-18 21:09:11 +02:00
end
2020-08-22 17:20:59 +02:00
local function on_force_created ( )
spaghett ( )
2020-04-18 21:09:11 +02:00
end
local function on_built_entity ( event )
2020-08-22 17:20:59 +02:00
spaghett_deny_building ( event )
2020-04-18 21:09:11 +02:00
end
local function on_robot_built_entity ( event )
2020-08-22 17:20:59 +02:00
spaghett_deny_building ( event )
2020-04-18 21:09:11 +02:00
end
local function on_init ( )
2020-08-22 17:20:59 +02:00
global.comfy_panel_config = { }
global.comfy_panel_config . spaghett = { }
global.comfy_panel_config . spaghett.undo = { }
global.comfy_panel_config . poll_trusted = false
global.comfy_panel_disable_antigrief = false
2020-04-18 21:09:11 +02:00
end
2020-08-22 17:20:59 +02:00
comfy_panel_tabs [ ' Config ' ] = { gui = build_config_gui , admin = false }
2020-04-18 21:09:11 +02:00
local Event = require ' utils.event '
Event.on_init ( on_init )
Event.add ( defines.events . on_gui_switch_state_changed , on_gui_switch_state_changed )
Event.add ( defines.events . on_force_created , on_force_created )
Event.add ( defines.events . on_built_entity , on_built_entity )
Event.add ( defines.events . on_robot_built_entity , on_robot_built_entity )