diff --git a/maps/chronosphere/config_tab.lua b/maps/chronosphere/config_tab.lua index f1bae7b7..e18f9af1 100644 --- a/maps/chronosphere/config_tab.lua +++ b/maps/chronosphere/config_tab.lua @@ -1,6 +1,7 @@ -- config tab for chronotrain-- local Chrono_table = require 'maps.chronosphere.table' +local Chrono = require 'maps.chronosphere.chrono' local functions = { ["comfy_panel_offline_accidents"] = function(event) @@ -20,10 +21,37 @@ local functions = { local objective = Chrono_table.get_table() if game.players[event.player_index].admin then if event.element.switch_state == "left" then - objective.config.jumpfailure = true - else - objective.config.jumpfailure = false - end + objective.config.jumpfailure = true + else + objective.config.jumpfailure = false + end + else + game.players[event.player_index].print("You are not admin!") + end + end, + + ["comfy_panel_game_lost"] = function(event) + local objective = Chrono_table.get_table() + if game.players[event.player_index].admin then + local frame = event.element.parent.parent + if event.element.switch_state == "left" then + if not objective.game_lost then + game.auto_save("chronotrain_before_manual_reset" .. math.random(1,1000)) + end + frame["comfy_panel_game_lost_confirm_table"].visible = true + else + frame["comfy_panel_game_lost_confirm_table"].visible = false + end + else + game.players[event.player_index].print("You are not admin!") + end + end, + ["comfy_panel_game_lost_confirm"] = function(event) + local objective = Chrono_table.get_table() + if game.players[event.player_index].admin then + if event.element.switch_state == "left" then + Chrono.objective_died() + end else game.players[event.player_index].print("You are not admin!") end @@ -31,7 +59,7 @@ local functions = { } local function add_switch(element, switch_state, name, description_main, description) - local t = element.add({type = "table", column_count = 5}) + local t = element.add({type = "table", column_count = 5, name = name .. "_table"}) local label label = t.add({type = "label", caption = "ON"}) label.style.padding = 0 @@ -48,7 +76,7 @@ local function add_switch(element, switch_state, name, description_main, descrip label = t.add({type = "label", caption = description_main}) label.style.padding = 2 label.style.left_padding= 10 - label.style.minimal_width = 120 + label.style.minimal_width = 130 label.style.font = "heading-2" label.style.font_color = {0.88, 0.88, 0.99} @@ -60,7 +88,7 @@ local function add_switch(element, switch_state, name, description_main, descrip label.style.font_color = {0.85, 0.85, 0.85} end -local build_config_gui = (function (frame) +local build_config_gui = (function (_, frame) local objective = Chrono_table.get_table() local switch_state frame.clear() @@ -71,16 +99,29 @@ local build_config_gui = (function (frame) switch_state = "right" if 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.") + add_switch(frame, switch_state, "comfy_panel_offline_accidents", "Offline Accidents", "Disables or enables dropping of inventory when player goes offline.\nTimer is 15 minutes.") line_elements[#line_elements + 1] = frame.add({type = "line"}) - if objective.auto_hotbar_enabled then - switch_state = "right" - if 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 + switch_state = "right" + if 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"}) + + switch_state = "right" + if objective.game_lost then switch_state = "left" end + add_switch(frame, switch_state, "comfy_panel_game_lost", "Reset Run", "Marks game as lost and starts countdown for map reset (Use with caution!)") + + switch_state = "right" + if objective.game_lost then switch_state = "left" end + add_switch(frame, switch_state, "comfy_panel_game_lost_confirm", "Confirm Reset Run", "But really you want to reset?\n(Previous button triggered autosave)") + frame["comfy_panel_game_lost_confirm_table"].visible = false + + line_elements[#line_elements + 1] = frame.add({type = "line"}) + + + end) diff --git a/maps/chronosphere/main.lua b/maps/chronosphere/main.lua index f67bb634..3d13b30d 100644 --- a/maps/chronosphere/main.lua +++ b/maps/chronosphere/main.lua @@ -144,6 +144,7 @@ local function reset_map() render_train_hp() game.reset_time_played() Locomotive.create_wagon_room() + Event_functions.mining_buffs(nil) if objective.game_won then game.print({"chronosphere.message_game_won_restart"}, {r=0.98, g=0.66, b=0.22}) end @@ -359,7 +360,6 @@ local function on_init() game.surfaces["nauvis"].clear() reset_map() Chrono.init_setup() - Event_functions.mining_buffs(nil) --if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end end diff --git a/maps/chronosphere/upgrades.lua b/maps/chronosphere/upgrades.lua index 067cbe75..34328a07 100644 --- a/maps/chronosphere/upgrades.lua +++ b/maps/chronosphere/upgrades.lua @@ -149,15 +149,15 @@ end local function fusion_buy() local objective = Chrono_table.get_table() if objective.upgradechest[11] and objective.upgradechest[11].valid then - local inv = objective.upgradechest[14].get_inventory(defines.inventory.chest) + local inv = objective.upgradechest[11].get_inventory(defines.inventory.chest) inv.insert({name = "fusion-reactor-equipment", count = 1}) end end local function mk2_buy() local objective = Chrono_table.get_table() - if objective.upgradechest[13] and objective.upgradechest[13].valid then - local inv = objective.upgradechest[13].get_inventory(defines.inventory.chest) + if objective.upgradechest[12] and objective.upgradechest[12].valid then + local inv = objective.upgradechest[12].get_inventory(defines.inventory.chest) inv.insert({name = "power-armor-mk2", count = 1}) end end