Giter VIP home page Giter VIP logo

factorio-batterypack's People

Contributors

mrudat avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

factorio-batterypack's Issues

Conflicts with Schall's Primary Battery

Hi mrudat, I love this Factorio mod, but noticed it doesn't play nice with Schall's batteries, which come fully charged. I've edited your code to make the exception. Would you consider adding it to your mod (I'll make a PR if you give me permission), or doing something similar? It would make my life playing with friends a little easier.

diff --git a/data-updates.lua b/data-updates.lua
index 04ef564..81238bf 100644
--- a/data-updates.lua
+++ b/data-updates.lua
@@ -75,6 +75,24 @@ function BatteryPack.process_battery(old_battery_equipment, new_things)
     return
   end

+  local function set_item_fuel_properties(item, fuel_value, burnt_result)
+    item.fuel_category = BatteryPack.fuel_category
+    item.burnt_result = burnt_result
+    item.fuel_value = fuel_value
+    -- TODO same as nuclear fuel, but perhaps could be better?
+    item.fuel_acceleration_multiplier = 2.5
+    item.fuel_top_speed_multiplier = 1.15
+    -- batteries are clean, we already paid for the pollution wherever the power was generated
+    item.fuel_emissions_multiplier = 0.0
+  end
+
+  -- batteries from "SchallPrimaryBattery" come already charged, so handle them specially
+  if old_battery_equipment.name:match("^primary%-battery%-equipment") then
+    set_item_fuel_properties(old_battery_item, buffer_capacity, nil)
+    table.insert(new_things, old_battery_item)
+    return
+  end
+
   local technology_list = BatteryPack.find_technologies_for_item(old_battery_item_name)
   local start_enabled = true
   if next(technology_list) then
@@ -114,15 +132,9 @@ function BatteryPack.process_battery(old_battery_equipment, new_things)
       "equipment-name." .. old_battery_equipment_name
     }
   }
+
   battery_item.placed_as_equipment_result = battery_equipment_name
-  battery_item.fuel_category = BatteryPack.fuel_category
-  battery_item.burnt_result = old_battery_item_name
-  battery_item.fuel_value = buffer_capacity
-  -- TODO same as nuclear fuel, but perhaps could be better?
-  battery_item.fuel_acceleration_multiplier = 2.5
-  battery_item.fuel_top_speed_multiplier = 1.15
-  -- batteries are clean, we already paid for the pollution wherever the power was generated
-  battery_item.fuel_emissions_multiplier = 0.0
+  set_item_fuel_properties(battery_item, buffer_capacity, old_battery_item_name)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.