mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-11 14:49:24 +02:00
Config Tab; Fixes and tweaks
This commit is contained in:
parent
d56f14ee03
commit
3eea0e663c
89
comfy_panel/config.lua
Normal file
89
comfy_panel/config.lua
Normal file
@ -0,0 +1,89 @@
|
||||
-- config tab --
|
||||
|
||||
local Tabs = require 'comfy_panel.main'
|
||||
|
||||
local functions = {
|
||||
["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,
|
||||
}
|
||||
|
||||
local function add_switch(element, switch_state, name, description_main, description)
|
||||
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}
|
||||
end
|
||||
|
||||
local build_config_gui = (function (player, frame)
|
||||
frame.clear()
|
||||
|
||||
local line_elements = {}
|
||||
local switch_label_elements = {}
|
||||
local label_elements = {}
|
||||
|
||||
line_elements[#line_elements + 1] = frame.add({type = "line"})
|
||||
|
||||
local switch_state = "right"
|
||||
if player.spectator then switch_state = "left" end
|
||||
add_switch(frame, switch_state, "comfy_panel_spectator_switch", "SpectatorMode", "Disables zoom-to-world view noise effect.\nEnvironmental sounds will be based on map view.")
|
||||
|
||||
line_elements[#line_elements + 1] = frame.add({type = "line"})
|
||||
|
||||
if global.auto_hotbar_enabled then
|
||||
local switch_state = "right"
|
||||
if global.auto_hotbar_enabled[player.index] then switch_state = "left" end
|
||||
add_switch(frame, switch_state, "comfy_panel_auto_hotbar_switch", "AutoHotbar", "Automatically fills your hotbar with placeable items.")
|
||||
line_elements[#line_elements + 1] = frame.add({type = "line"})
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
local function on_gui_click(event)
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
comfy_panel_tabs["Config"] = build_config_gui
|
||||
|
||||
|
||||
local event = require 'utils.event'
|
||||
event.add(defines.events.on_gui_click, on_gui_click)
|
14
control.lua
14
control.lua
@ -13,19 +13,19 @@ require "chatbot"
|
||||
require "commands"
|
||||
require "antigrief"
|
||||
require "player_modifiers"
|
||||
require "modules.corpse_markers"
|
||||
require "modules.floaty_chat"
|
||||
require "modules.autohotbar"
|
||||
|
||||
require "comfy_panel.main"
|
||||
require "comfy_panel.player_list"
|
||||
require "comfy_panel.group"
|
||||
require "comfy_panel.score"
|
||||
require "comfy_panel.poll"
|
||||
require "comfy_panel.admin"
|
||||
require "comfy_panel.group"
|
||||
require "comfy_panel.poll"
|
||||
require "comfy_panel.score"
|
||||
require "comfy_panel.config"
|
||||
|
||||
require "modules.autostash"
|
||||
require "modules.corpse_markers"
|
||||
require "modules.floaty_chat"
|
||||
--require "modules.autohotbar"
|
||||
--require "on_tick_schedule"
|
||||
|
||||
---- enable modules here ----
|
||||
--require "modules.the_floor_is_lava"
|
||||
|
@ -2,7 +2,7 @@
|
||||
local function on_research_finished(event)
|
||||
local research = event.research
|
||||
local force_name = research.force.name
|
||||
if research.name == "flamethrower" then
|
||||
if research.name == "military" then
|
||||
if not global.flamethrower_damage then global.flamethrower_damage = {} end
|
||||
global.flamethrower_damage[force_name] = -0.50
|
||||
game.forces[force_name].set_turret_attack_modifier("flamethrower-turret", global.flamethrower_damage[force_name])
|
||||
|
@ -28,6 +28,7 @@ local function set_hotbar(player, item)
|
||||
end
|
||||
|
||||
local function on_player_fast_transferred(event)
|
||||
if not global.auto_hotbar_enabled[event.player_index] then return end
|
||||
local player = game.players[event.player_index]
|
||||
for name, count in pairs(player.get_main_inventory().get_contents()) do
|
||||
set_hotbar(player, name)
|
||||
@ -35,17 +36,25 @@ local function on_player_fast_transferred(event)
|
||||
end
|
||||
|
||||
local function on_player_crafted_item(event)
|
||||
if not global.auto_hotbar_enabled[event.player_index] then return end
|
||||
set_hotbar(game.players[event.player_index], event.item_stack.name)
|
||||
end
|
||||
|
||||
local function on_picked_up_item(event)
|
||||
if not global.auto_hotbar_enabled[event.player_index] then return end
|
||||
set_hotbar(game.players[event.player_index], event.item_stack.name)
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
if not global.auto_hotbar_enabled[event.player_index] then return end
|
||||
set_hotbar(game.players[event.player_index], event.entity.name)
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
global.auto_hotbar_enabled = {}
|
||||
end
|
||||
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_player_fast_transferred, on_player_fast_transferred)
|
||||
event.add(defines.events.on_player_crafted_item, on_player_crafted_item)
|
||||
event.add(defines.events.on_picked_up_item, on_picked_up_item)
|
||||
|
@ -70,7 +70,7 @@ function Public.build_worm()
|
||||
unit.destroy()
|
||||
wave_defense_table.threat = wave_defense_table.threat - threat_values[worm]
|
||||
end
|
||||
|
||||
--[[
|
||||
local function get_circle_vectors(radius)
|
||||
local vectors = {}
|
||||
for x = radius * -1, radius, 1 do
|
||||
@ -84,17 +84,18 @@ local function get_circle_vectors(radius)
|
||||
end
|
||||
|
||||
local acid_nova_entities = {
|
||||
["small-biter"] = {projectile = "acid-stream-worm-small", vectors = get_circle_vectors(3), amount = 8, threat_cost = 32},
|
||||
["medium-biter"] = {projectile = "acid-stream-worm-medium", vectors = get_circle_vectors(4), amount = 8, threat_cost = 64},
|
||||
["big-biter"] = {projectile = "acid-stream-worm-big", vectors = get_circle_vectors(5), amount = 8, threat_cost = 96},
|
||||
["behemoth-biter"] = {projectile = "acid-stream-worm-behemoth", vectors = get_circle_vectors(6), amount = 8, threat_cost = 128},
|
||||
["small-biter"] = {projectile = "acid-stream-worm-small", vectors = get_circle_vectors(3), threat_cost = 32},
|
||||
["medium-biter"] = {projectile = "acid-stream-worm-medium", vectors = get_circle_vectors(4), threat_cost = 64},
|
||||
["big-biter"] = {projectile = "acid-stream-worm-big", vectors = get_circle_vectors(5), threat_cost = 96},
|
||||
["behemoth-biter"] = {projectile = "acid-stream-worm-behemoth", vectors = get_circle_vectors(6), threat_cost = 128},
|
||||
}
|
||||
|
||||
local function acid_nova(entity)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if not acid_nova_entities[entity.name] then return end
|
||||
if wave_defense_table.threat < 100000 then return end
|
||||
for _ = 1, acid_nova_entities[entity.name].amount, 1 do
|
||||
if math.random(1, 32) ~= 1 then return end
|
||||
for _ = 1, 8, 1 do
|
||||
local i = math_random(1, #acid_nova_entities[entity.name].vectors)
|
||||
entity.surface.create_entity({
|
||||
name = acid_nova_entities[entity.name].projectile,
|
||||
@ -109,7 +110,7 @@ local function acid_nova(entity)
|
||||
wave_defense_table.threat = wave_defense_table.threat - acid_nova_entities[entity.name].threat_cost
|
||||
return true
|
||||
end
|
||||
|
||||
]]
|
||||
local function shred_simple_entities(entity)
|
||||
local wave_defense_table = WD.get_table()
|
||||
if wave_defense_table.threat < 25000 then return end
|
||||
@ -159,7 +160,7 @@ local function on_entity_died(event)
|
||||
if entity.type == "unit" then
|
||||
wave_defense_table.threat = math.round(wave_defense_table.threat - threat_values[entity.name] * global.biter_health_boost, 2)
|
||||
remove_unit(entity)
|
||||
acid_nova(entity)
|
||||
--acid_nova(entity)
|
||||
else
|
||||
if entity.force.index == 2 then
|
||||
if entity.health then
|
||||
|
Loading…
x
Reference in New Issue
Block a user