mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-01 13:08:05 +02:00
chronotrain fixes + reset game button
This commit is contained in:
parent
b652800f65
commit
59bd2907ea
@ -1,6 +1,7 @@
|
|||||||
-- config tab for chronotrain--
|
-- config tab for chronotrain--
|
||||||
|
|
||||||
local Chrono_table = require 'maps.chronosphere.table'
|
local Chrono_table = require 'maps.chronosphere.table'
|
||||||
|
local Chrono = require 'maps.chronosphere.chrono'
|
||||||
|
|
||||||
local functions = {
|
local functions = {
|
||||||
["comfy_panel_offline_accidents"] = function(event)
|
["comfy_panel_offline_accidents"] = function(event)
|
||||||
@ -28,10 +29,37 @@ local functions = {
|
|||||||
game.players[event.player_index].print("You are not admin!")
|
game.players[event.player_index].print("You are not admin!")
|
||||||
end
|
end
|
||||||
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
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function add_switch(element, switch_state, name, description_main, description)
|
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
|
local label
|
||||||
label = t.add({type = "label", caption = "ON"})
|
label = t.add({type = "label", caption = "ON"})
|
||||||
label.style.padding = 0
|
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 = t.add({type = "label", caption = description_main})
|
||||||
label.style.padding = 2
|
label.style.padding = 2
|
||||||
label.style.left_padding= 10
|
label.style.left_padding= 10
|
||||||
label.style.minimal_width = 120
|
label.style.minimal_width = 130
|
||||||
label.style.font = "heading-2"
|
label.style.font = "heading-2"
|
||||||
label.style.font_color = {0.88, 0.88, 0.99}
|
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}
|
label.style.font_color = {0.85, 0.85, 0.85}
|
||||||
end
|
end
|
||||||
|
|
||||||
local build_config_gui = (function (frame)
|
local build_config_gui = (function (_, frame)
|
||||||
local objective = Chrono_table.get_table()
|
local objective = Chrono_table.get_table()
|
||||||
local switch_state
|
local switch_state
|
||||||
frame.clear()
|
frame.clear()
|
||||||
@ -71,16 +99,29 @@ local build_config_gui = (function (frame)
|
|||||||
|
|
||||||
switch_state = "right"
|
switch_state = "right"
|
||||||
if objective.config.offline_loot then switch_state = "left" end
|
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"})
|
line_elements[#line_elements + 1] = frame.add({type = "line"})
|
||||||
|
|
||||||
if objective.auto_hotbar_enabled then
|
|
||||||
switch_state = "right"
|
switch_state = "right"
|
||||||
if objective.config.jumpfailure then switch_state = "left" end
|
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)")
|
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"})
|
line_elements[#line_elements + 1] = frame.add({type = "line"})
|
||||||
end
|
|
||||||
|
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)
|
end)
|
||||||
|
|
||||||
|
@ -144,6 +144,7 @@ local function reset_map()
|
|||||||
render_train_hp()
|
render_train_hp()
|
||||||
game.reset_time_played()
|
game.reset_time_played()
|
||||||
Locomotive.create_wagon_room()
|
Locomotive.create_wagon_room()
|
||||||
|
Event_functions.mining_buffs(nil)
|
||||||
if objective.game_won then
|
if objective.game_won then
|
||||||
game.print({"chronosphere.message_game_won_restart"}, {r=0.98, g=0.66, b=0.22})
|
game.print({"chronosphere.message_game_won_restart"}, {r=0.98, g=0.66, b=0.22})
|
||||||
end
|
end
|
||||||
@ -359,7 +360,6 @@ local function on_init()
|
|||||||
game.surfaces["nauvis"].clear()
|
game.surfaces["nauvis"].clear()
|
||||||
reset_map()
|
reset_map()
|
||||||
Chrono.init_setup()
|
Chrono.init_setup()
|
||||||
Event_functions.mining_buffs(nil)
|
|
||||||
--if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end
|
--if game.surfaces["nauvis"] then game.delete_surface(game.surfaces["nauvis"]) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,15 +149,15 @@ end
|
|||||||
local function fusion_buy()
|
local function fusion_buy()
|
||||||
local objective = Chrono_table.get_table()
|
local objective = Chrono_table.get_table()
|
||||||
if objective.upgradechest[11] and objective.upgradechest[11].valid then
|
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})
|
inv.insert({name = "fusion-reactor-equipment", count = 1})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function mk2_buy()
|
local function mk2_buy()
|
||||||
local objective = Chrono_table.get_table()
|
local objective = Chrono_table.get_table()
|
||||||
if objective.upgradechest[13] and objective.upgradechest[13].valid then
|
if objective.upgradechest[12] and objective.upgradechest[12].valid then
|
||||||
local inv = objective.upgradechest[13].get_inventory(defines.inventory.chest)
|
local inv = objective.upgradechest[12].get_inventory(defines.inventory.chest)
|
||||||
inv.insert({name = "power-armor-mk2", count = 1})
|
inv.insert({name = "power-armor-mk2", count = 1})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user