mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-03-03 14:42:27 +02:00
Some cleanup and a fix for the soft mode miner autodecon.
This commit is contained in:
parent
2de868850b
commit
32330e2385
@ -443,7 +443,6 @@ end)
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.on_gui_text_changed, function(event)
|
||||
NotepadOnGuiTextChange(event)
|
||||
SharedElectricityPlayerGuiValueChange(event)
|
||||
end)
|
||||
|
||||
|
||||
|
@ -10,14 +10,15 @@ end
|
||||
|
||||
function OarcAutoDeconOnTick()
|
||||
if (global.depleted_miners_check and (#global.depleted_miners_check > 0)) then
|
||||
for i,entry in pairs(global.depleted_miners_check) do
|
||||
if ((not entry.miner) or (not entry.miner.valid)) then
|
||||
for i,miner in pairs(global.depleted_miners_check) do
|
||||
if ((not miner) or (not miner.valid)) then
|
||||
table.remove(global.depleted_miners_check, i)
|
||||
|
||||
elseif (game.tick > (entry.tick+2)) then
|
||||
|
||||
if (entry.miner.status == defines.entity_status.no_minable_resources) then
|
||||
entry.miner.order_deconstruction(entry.miner.force)
|
||||
else
|
||||
if (#miner.surface.find_entities_filtered{area = {{miner.position.x-3, miner.position.y-3},
|
||||
{miner.position.x+3, miner.position.y+3}},
|
||||
type = "resource", limit = 1} == 0) then
|
||||
miner.order_deconstruction(miner.force)
|
||||
end
|
||||
table.remove(global.depleted_miners_check, i)
|
||||
end
|
||||
@ -35,9 +36,8 @@ function OarcAutoDeconOnResourceDepleted(event)
|
||||
{event.entity.position.x+1, event.entity.position.y+1}},
|
||||
name = {"burner-mining-drill", "electric-mining-drill"}}
|
||||
|
||||
|
||||
for i,v in pairs(nearby_miners) do
|
||||
table.insert(global.depleted_miners_check, {miner=v, tick=game.tick})
|
||||
table.insert(global.depleted_miners_check, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -40,7 +40,6 @@ OARC_STORE_PLAYER_ITEMS =
|
||||
["artillery-targeting-remote"] = {cost = 500, count = 1, play_time_locked=true},
|
||||
},
|
||||
|
||||
|
||||
["Capsules/Mines"] = {
|
||||
["land-mine"] = {cost = 20, count = 10, play_time_locked=false},
|
||||
["defender-capsule"] = {cost = 20, count = 10, play_time_locked=false},
|
||||
|
@ -17,7 +17,6 @@ function SharedChestInitItems()
|
||||
global.shared_electricity_inputs = {}
|
||||
global.shared_electricity_outputs = {}
|
||||
|
||||
global.shared_electricity_player_limits = {}
|
||||
global.shared_chests_combinators = {}
|
||||
global.shared_items = {}
|
||||
|
||||
@ -664,20 +663,6 @@ function CreateSharedItemsGuiTab(tab_container, player)
|
||||
|
||||
AddLabel(scrollFrame, "elec_avail_info", "[color=acid]Current electricity available: " .. string.format("%.3f", global.shared_energy_stored/1000000) .. "MJ[/color] [color=" .. rate_color .. "](" .. energy_add_str .. " " .. energy_sub_str ..")[/color]", my_longer_label_style)
|
||||
|
||||
if ((global.shared_electricity_player_limits ~= nil) and
|
||||
(global.shared_electricity_player_limits[player.name] ~= nil)) then
|
||||
|
||||
local limit_mw_nice = string.format("%.3fMW", (global.shared_electricity_player_limits[player.name]*60 / 1000000))
|
||||
|
||||
AddLabel(scrollFrame, "elec_limit_info", "Limit sharing amount (".. limit_mw_nice .."): ", my_longer_label_style)
|
||||
scrollFrame.add{type="textfield",
|
||||
tooltip="Limit how much energy you are sharing with others!\nThis is in Joules/tick so you it is multiplied by 60 to get Watts.",
|
||||
name="energy_share_limit_input",
|
||||
numeric=true,
|
||||
allow_negative=false,
|
||||
text=global.shared_electricity_player_limits[player.name]}
|
||||
end
|
||||
|
||||
AddSpacerLine(scrollFrame)
|
||||
AddLabel(scrollFrame, "share_items_title_msg", "Shared Items:", my_label_header_style)
|
||||
|
||||
@ -692,27 +677,4 @@ function CreateSharedItemsGuiTab(tab_container, player)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function SharedElectricityPlayerGuiValueChange(event)
|
||||
|
||||
if (event.element.name ~= "energy_share_limit_input") then return end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
if (player ~= nil) and (global.shared_electricity_player_limits ~= nil) then
|
||||
if (event.element.text == "") then
|
||||
event.element.text = 0
|
||||
end
|
||||
if (tonumber(event.element.text) > (SHARED_ELEC_INPUT_BUFFER_SIZE/2)) then
|
||||
event.element.text = SHARED_ELEC_INPUT_BUFFER_SIZE/2
|
||||
end
|
||||
|
||||
global.shared_electricity_player_limits[player.name] = tonumber(event.element.text)
|
||||
event.element.text = global.shared_electricity_player_limits[player.name]
|
||||
|
||||
local limit_mw_nice = string.format("%.3fMW", (global.shared_electricity_player_limits[player.name]*60 / 1000000))
|
||||
event.element.parent.elec_limit_info.caption = "Limit sharing amount (".. limit_mw_nice .."): "
|
||||
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user