Advertisement
tabr

PowerOverload_1.2.6

Aug 12th, 2022
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.32 KB | None | 0 0
  1. diff --git a/PowerOverload_1.2.4/control.lua b/PowerOverload_1.2.6/control.lua
  2. index 5a7fdb4..210e097 100644
  3. --- a/PowerOverload_1.2.4/control.lua
  4. +++ b/PowerOverload_1.2.6/control.lua
  5. @@ -52,10 +52,12 @@ script.on_event(defines.events.on_entity_destroyed,
  6.  
  7.  script.on_event(defines.events.on_tick,
  8.    function()
  9. -    local consumption_cache = {}
  10. -    update_poles("fuse", consumption_cache)
  11. -    update_poles("pole", consumption_cache)
  12. -    update_transformers()
  13. +    if (game.tick % settings.global['power-overload-update-period'].value) == 0 then
  14. +      local consumption_cache = {}
  15. +      update_poles("fuse", consumption_cache)
  16. +      update_poles("pole", consumption_cache)
  17. +      update_transformers()
  18. +    end
  19.    end
  20.  )
  21.  
  22. @@ -120,6 +122,7 @@ local function update_global_settings()
  23.      "power-overload-disconnect-different-poles",
  24.      "power-overload-on-pole-overload",
  25.      "power-overload-log-to-chat",
  26. +    "power-overload-debug-log-to-chat",
  27.      "power-overload-transformer-efficiency",
  28.    }) do
  29.      global_settings[setting] = settings.global[setting].value
  30. diff --git a/PowerOverload_1.2.4/info.json b/PowerOverload_1.2.6/info.json
  31. index 99feafa..6c75f87 100644
  32. --- a/PowerOverload_1.2.4/info.json
  33. +++ b/PowerOverload_1.2.6/info.json
  34. @@ -1,6 +1,6 @@
  35.  {
  36.      "name": "PowerOverload",
  37. -    "version": "1.2.4",
  38. +    "version": "1.2.6",
  39.      "title": "Power Overload",
  40.      "author": "Xorimuth",
  41.      "description": "Performant, semi-realistic power distribution overhaul.\nPower poles can explode if the total electrical consumption on the network is too high. Use transformers to separate networks so that subnetworks do not take more power than they can handle.",
  42. diff --git a/PowerOverload_1.2.4/locale/en/locale.cfg b/PowerOverload_1.2.6/locale/en/locale.cfg
  43. index b6a91dd..b6a9b99 100644
  44. --- a/PowerOverload_1.2.4/locale/en/locale.cfg
  45. +++ b/PowerOverload_1.2.6/locale/en/locale.cfg
  46. @@ -21,6 +21,8 @@ power-overload-on-pole-overload=When power pole is overloaded
  47.  power-overload-log-to-chat=Power pole explosion alerts in chat
  48.  power-overload-transformer-efficiency=Transformer efficiency
  49.  power-overload-max-power=Max consumption: __ENTITY____1____
  50. +power-overload-debug-log-to-chat-decrease-buffer=Debug Log to chat
  51. +power-overload-update-period=Update period
  52.  
  53.  [string-mod-setting]
  54.  power-overload-on-pole-overload-destroy=Destroy
  55. @@ -28,6 +30,7 @@ power-overload-on-pole-overload-damage=Damage
  56.  
  57.  [mod-setting-description]
  58.  power-overload-disconnect-different-poles=Prevents accidentally connecting different networks that have different maximum consumptions
  59. +power-overload-update-period=Ticks
  60.  
  61.  [overload-alert]
  62.  alert=[entity=__1__] destroyed (Consumption = __2__MW)
  63. diff --git a/PowerOverload_1.2.4/scripts/transformer.lua b/PowerOverload_1.2.6/scripts/transformer.lua
  64. index 9858d2f..47e2600 100644
  65. --- a/PowerOverload_1.2.4/scripts/transformer.lua
  66. +++ b/PowerOverload_1.2.6/scripts/transformer.lua
  67. @@ -78,6 +78,7 @@ end
  68.  
  69.  function update_transformers()
  70.    local efficiency = global.global_settings["power-overload-transformer-efficiency"]
  71. +  local debug_log_to_chat = global.global_settings["power-overload-debug-log-to-chat"]
  72.  
  73.    for i, transformer in pairs(global.transformers) do
  74.      local transformer_entity = transformer.transformer
  75. @@ -94,13 +95,17 @@ function update_transformers()
  76.          local effective_energy_out = (energy_out - buffer_size) / efficiency + buffer_size
  77.          if energy_in == buffer_size and effective_energy_out <= 0 then
  78.            buffer_size = buffer_size * 1.2
  79. -          log("Increasing buffer size to support " .. math.floor(buffer_size * 60 / 1000000) .. "MW")
  80. +          if debug_log_to_chat then
  81. +            log("Increasing buffer size to support " .. math.floor(buffer_size * 60 / 1000000) .. "MW")
  82. +          end
  83.            interface_in.electric_buffer_size = buffer_size
  84.            interface_out.electric_buffer_size = buffer_size
  85.          elseif effective_energy_out / energy_in > 0.01 and buffer_size > 1000 then
  86.            -- Shrink the buffer size if necessary
  87.            buffer_size = buffer_size * 0.99
  88. -          log("Decreasing buffer size to support " .. math.floor(buffer_size * 60 / 1000000) .. "MW")
  89. +          if debug_log_to_chat then
  90. +            log("Decreasing buffer size to support " .. math.floor(buffer_size * 60 / 1000000) .. "MW")
  91. +          end
  92.            interface_in.electric_buffer_size = buffer_size
  93.            interface_out.electric_buffer_size = buffer_size
  94.          end
  95. diff --git a/PowerOverload_1.2.4/settings.lua b/PowerOverload_1.2.6/settings.lua
  96. index b5dc037..e931cb9 100644
  97. --- a/PowerOverload_1.2.4/settings.lua
  98. +++ b/PowerOverload_1.2.6/settings.lua
  99. @@ -23,6 +23,13 @@ data:extend{
  100.      default_value = true,
  101.      order = "c"
  102.    },
  103. +  {
  104. +    type = "bool-setting",
  105. +    name = "power-overload-debug-log-to-chat",
  106. +    setting_type = "runtime-global",
  107. +    default_value = false,
  108. +    order = "ca"
  109. +  },
  110.    {
  111.      type = "double-setting",
  112.      name = "power-overload-transformer-efficiency",
  113. @@ -32,6 +39,15 @@ data:extend{
  114.      maximum_value = 1,
  115.      order = "d"
  116.    },
  117. +  {
  118. +    type = "int-setting",
  119. +    name = "power-overload-update-period",
  120. +    setting_type = "runtime-global",
  121. +    default_value = 30,
  122. +    minimum_value = 1,
  123. +    maximum_value = 600,
  124. +    order = "e"
  125. +  },
  126.  }
  127.  
  128.  order = 0
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement