mrudat / factorio-batterypack Goto Github PK
View Code? Open in Web Editor NEWhttps://mods.factorio.com/mod/BatteryPack
https://mods.factorio.com/mod/BatteryPack
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.