1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-07 13:31:40 +02:00

mini fixes + new admin tab

This commit is contained in:
hanakocz 2020-03-17 21:36:00 +01:00
parent 771e5e7aeb
commit 8e3c8cc1ea
6 changed files with 112 additions and 11 deletions

View File

@ -36,13 +36,13 @@ end
function Public.comfy_panel_get_active_frame(player)
if not player.gui.left.comfy_panel then return false end
if not player.gui.left.comfy_panel.tabbed_pane.selected_tab_index then return player.gui.left.comfy_panel.tabbed_pane.tabs[1].content end
return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content
return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content
end
function Public.comfy_panel_refresh_active_tab(player)
local frame = Public.comfy_panel_get_active_frame(player)
if not frame then return end
comfy_panel_tabs[frame.name](player, frame)
comfy_panel_tabs[frame.name].gui(player, frame)
end
local function top_button(player)

View File

@ -126,8 +126,8 @@ require "maps.chronosphere.main"
--require "modules.trees_grow"
--require "modules.trees_randomly_die"
--require "terrain_layouts.scrap_01"
--require "terrain_layouts.caves"
--require "terrain_layouts.scrap_01"
--require "terrain_layouts.caves"
--require "terrain_layouts.cone_to_east"
--require "terrain_layouts.biters_and_resources_east"
------

View File

@ -0,0 +1,97 @@
-- config tab for chronotrain--
local Tabs = require 'comfy_panel.main'
local functions = {
["comfy_panel_offline_accidents"] = function(event)
if game.players[event.player_index].admin then
if event.element.switch_state == "left" then
global.objective.config.offline_loot = true
else
global.objective.config.offline_loot = false
end
else
game.players[event.player_index].print("You are not admin!")
end
end,
["comfy_panel_danger_events"] = function(event)
if game.players[event.player_index].admin then
if event.element.switch_state == "left" then
global.objective.config.jumpfailure = true
else
global.objective.config.jumpfailure = false
end
else
game.players[event.player_index].print("You are not admin!")
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 global.objective.config.offline_loot then switch_state = "left" end
add_switch(frame, switch_state, "comfy_panel_offline_accidents", "Offline Accidents", "Disablesr enables dropping of inventory when player goes offline.\nTimer is 15 minutes.")
line_elements[#line_elements + 1] = frame.add({type = "line"})
if global.auto_hotbar_enabled then
local switch_state = "right"
if global.objective.config.jumpfailure then switch_state = "left" end
add_switch(frame, switch_state, "comfy_panel_danger_events", "Dangerous Events", "Disables or enables dangerous event maps\n(they require at least 2-4 capable players to survive)")
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["ChronoTrain"] = {gui = build_config_gui, admin = true}
local event = require 'utils.event'
event.add(defines.events.on_gui_click, on_gui_click)

View File

@ -141,7 +141,7 @@ local function reset_map()
global.active_surface_index = game.create_surface("chronosphere", Chrono.get_map_gen_settings()).index
else
game.forces.player.set_spawn_position({12, 10}, game.surfaces[global.active_surface_index])
global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index
global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], Chrono.get_map_gen_settings(), starting_items).index
end
local surface = game.surfaces[global.active_surface_index]

View File

@ -286,7 +286,7 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet
end
if math_abs(noise_large_caves) > 0.375 then
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if math_random(1,6) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
return
end
@ -306,9 +306,9 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet
if small_caves > -0.25 and small_caves < 0.25 then
tiles[#tiles + 1] = {name = "dirt-7", position = p}
local roll = math_random(1,1000)
if roll > 800 then
if roll > 830 then
entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p}
elseif roll > 790 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then
elseif roll > 820 and math_sqrt(p.x * p.x + p.y * p.y) > 150 then
entities[#entities + 1] = {name = worm_raffle[math_random(1 + math_floor(game.forces["enemy"].evolution_factor * 8), math_floor(1 + game.forces["enemy"].evolution_factor * 16))], position = p}
else
@ -329,7 +329,7 @@ local function process_rocky_position(p, seed, tiles, entities, treasure, planet
if math_random(1,2048) == 1 then treasure[#treasure + 1] = p end
tiles[#tiles + 1] = {name = "dirt-7", position = p}
if math_random(1,100) > 40 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
if math_random(1,100) > 50 then entities[#entities + 1] = {name = rock_raffle[math_random(1, size_of_rock_raffle)], position = p} end
return
end

View File

@ -210,7 +210,6 @@ function Public_tick.offline_players()
player_inv[3] = game.players[players[i].index].get_inventory(defines.inventory.character_guns)
player_inv[4] = game.players[players[i].index].get_inventory(defines.inventory.character_ammo)
player_inv[5] = game.players[players[i].index].get_inventory(defines.inventory.character_trash)
game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22})
local e = surface.create_entity({name = "character", position = game.forces.player.get_spawn_position(surface), force = "neutral"})
local inv = e.get_inventory(defines.inventory.character_main)
for ii = 1, 5, 1 do
@ -228,8 +227,12 @@ function Public_tick.offline_players()
inv.insert(items[item])
end
end
game.print({"chronosphere.message_accident"}, {r=0.98, g=0.66, b=0.22})
e.die("neutral")
else
e.destroy()
end
e.die("neutral")
for ii = 1, 5, 1 do
if player_inv[ii].valid then
player_inv[ii].clear()
@ -247,6 +250,7 @@ function Public_tick.offline_players()
players[#players + 1] = later[i]
end
end
objective.offline_players = players
end
end