From 567f00f2a4d0decc2fa6df60fe5e79cf294ecdf0 Mon Sep 17 00:00:00 2001 From: Sirenfal Date: Tue, 25 Apr 2017 20:02:02 -0400 Subject: [PATCH] * Update to 1.1 for release --- .../constants.lua | 6 +- .../control.lua | 722 ++++++------- .../data.lua | 8 +- .../entity/localized-charging-pole/bright.png | Bin .../localized-charging-pole/powered.png | Bin .../localized-charging-pole/unpowered.png | Bin .../projectile/induction-charge-beam.png | Bin .../graphics/icons/electric-locomotive.png | Bin .../icons/localized-charging-pole.png | Bin .../graphics/technology/electric-trains.png | Bin .../info.json | 19 +- .../locale/en/all.cfg | 0 .../migrations/Localized_Charging_1.0.0.json | 0 .../migrations/Localized_Charging_1.0.0.lua | 0 .../prototypes/charger.lua | 948 +++++++++--------- .../prototypes/items.lua | 192 ++-- .../prototypes/recipes.lua | 156 +-- .../prototypes/technologies.lua | 118 +-- .../prototypes/vehicles.lua | 114 +-- .../volt_util.lua | 84 +- 20 files changed, 1183 insertions(+), 1184 deletions(-) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/constants.lua (96%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/control.lua (96%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/data.lua (97%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/graphics/entity/localized-charging-pole/bright.png (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/graphics/entity/localized-charging-pole/powered.png (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/graphics/entity/localized-charging-pole/unpowered.png (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/graphics/entity/projectile/induction-charge-beam.png (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/graphics/icons/electric-locomotive.png (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/graphics/icons/localized-charging-pole.png (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/graphics/technology/electric-trains.png (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/info.json (89%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/locale/en/all.cfg (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/migrations/Localized_Charging_1.0.0.json (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/migrations/Localized_Charging_1.0.0.lua (100%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/prototypes/charger.lua (95%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/prototypes/items.lua (96%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/prototypes/recipes.lua (95%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/prototypes/technologies.lua (95%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/prototypes/vehicles.lua (95%) rename {Localized_Charging_1.0.0 => Localized_Charging_1.1.0}/volt_util.lua (96%) diff --git a/Localized_Charging_1.0.0/constants.lua b/Localized_Charging_1.1.0/constants.lua similarity index 96% rename from Localized_Charging_1.0.0/constants.lua rename to Localized_Charging_1.1.0/constants.lua index f6edc96..b623e3d 100644 --- a/Localized_Charging_1.0.0/constants.lua +++ b/Localized_Charging_1.1.0/constants.lua @@ -1,4 +1,4 @@ -require('volt_util') - -scan_tick = ms_to_ticks(500) +require('volt_util') + +scan_tick = ms_to_ticks(500) vehicle_inventory_check = ms_to_ticks(1000) \ No newline at end of file diff --git a/Localized_Charging_1.0.0/control.lua b/Localized_Charging_1.1.0/control.lua similarity index 96% rename from Localized_Charging_1.0.0/control.lua rename to Localized_Charging_1.1.0/control.lua index 6bf4b7c..3483d34 100644 --- a/Localized_Charging_1.0.0/control.lua +++ b/Localized_Charging_1.1.0/control.lua @@ -1,361 +1,361 @@ -require('constants') - -script.on_init(function() - global.interfaces = {} - global.vehicles = {} -end) - -local charging_info = { - ["localized-charging-pole-1"] = { - ['interface'] = 'localized-charging-pole-interface-1', - ['range'] = 10, - ['efficiency'] = 0.5, - }, - ["localized-charging-pole-2"] = { - ['interface'] = 'localized-charging-pole-interface-2', - ['range'] = 10, - ['efficiency'] = 0.5, - }, - ["localized-charging-pole-3"] = { - ['interface'] = 'localized-charging-pole-interface-3', - ['range'] = 10, - ['efficiency'] = 0.5, - }, - ["localized-charging-pole-4"] = { - ['interface'] = 'localized-charging-pole-interface-4', - ['range'] = 10, - ['efficiency'] = 0.5, - }, -} - -local electric_vehicles = { - ['electric-locomotive'] = true, - -- airship mod lol - ['gunship'] = true, - ['jet'] = true, - ['cargo-plane'] = true, - ['flying-fortress'] = true, - -- predictabowl vehicle mammoth tank - ['tank-mk3'] = true, -} - -remote.add_interface('Localized_Charging', { - --Allow other mods to add electric vehicles - add_electric_vehicle = function(name) - if (electric_vehicles[name] ~= nil) then - return true - end - local vehicle = game.entity_prototypes[name] - if (vehicle ~= nil) and ((vehicle.type == 'car') or (vehicle.type == 'locomotive')) then - electric_vehicles[name] = true - return true - end - return false - end, - --Handle entity replacement by AAI Programmable Vehicles - on_entity_replaced = function(event) - for k, vehicle_info in pairs(global.vehicles) do - local vehicle = vehicle_info.vehicle - if(vehicle == event.old_entity) then - global.vehicles[k]['vehicle'] = event.new_entity - if(remote.interfaces['aai-programmable-vehicles']) and (remote.call('aai-programmable-vehicles', 'get_unit_by_entity', vehicle) ~= nil) then - --AAIPV uses a special fueling method, so disable regular battery fueling - global.vehicles[k]['battery_fueling_enabled'] = false - end - break - end - end - end -}) - -local function defaultdict(d) - t = {} - setmetatable(t, { - __index = function (t, k) - local ret = d() - rawset(t, k, ret) - return ret - end - }) - return t -end - -local function get_chargable_items(grid) - local items = {} - - for _, item in pairs(grid.equipment) do - if(item.max_energy - item.energy > 0) then - table.insert(items, item) - end - end - - return items -end - -script.on_event(defines.events.on_tick, function(event) - local remove = {} - - for k, vehicle_info in pairs(global.vehicles) do - vehicle = vehicle_info.vehicle - - if(not vehicle.valid) then - table.insert(remove, k) - elseif(vehicle.grid ~= nil) and (vehicle_info.battery_fueling_enabled) then - local grid = vehicle.grid - local available_power = grid.available_in_batteries - local current_power = vehicle.energy - -- vehicles have a maximum energy cap that we have no way to read, so just get a delta to determine what we spent - vehicle.energy = vehicle.energy + available_power - local spent_power = vehicle.energy - current_power - - if(spent_power > 0) then - for _, item in pairs(grid.equipment) do - if(item.energy > 0) then - if(item.energy > spent_power) then - item.energy = item.energy - spent_power - break - else - spent_power = spent_power - item.energy - item.energy = 0 - end - end - end - end - end - end - - for _, k in pairs(remove) do - global.vehicles[k] = nil - end - - if not (game.tick % scan_tick == 0) then - return - end - - local targets = {} - local split = defaultdict(function() return 0 end) - - -- vehicles are checked for validity in the upper loop - for _, vehicle_info in pairs(global.vehicles) do - vehicle = vehicle_info.vehicle - - if(vehicle_info.charging == true or (game.tick - vehicle_info.lastCheck > vehicle_inventory_check)) then - vehicle_info.lastCheck = game.tick - - -- maybe grid can be situational in future patches, who knows? - local grid = vehicle.grid - local hit = false - - if(grid ~= nil and grid.battery_capacity - grid.available_in_batteries > 0) then - local pt = { - ['ent'] = vehicle, - ['grid'] = grid, - ['towers'] = {}, - } - - for name, info in pairs(charging_info) do - for _, tower in pairs(vehicle.surface.find_entities_filtered{ - area={ - {vehicle.position['x'] - info['range'], vehicle.position['y'] - info['range']}, - {vehicle.position['x'] + info['range'], vehicle.position['y'] + info['range']}, - }, - name=name, - }) do - if(tower.force.name == vehicle.force.name and global.interfaces[tower.unit_number].energy > 0) then - -- towers can charge multiple targets, find out which way the power will be split before actually doing the charge tick - if(hit ~= true) then - table.insert(targets, pt) - hit = true - end - - table.insert(pt.towers, tower) - split[tower.unit_number] = split[tower.unit_number] + 1 - end - end - end - end - - vehicle_info.charging = hit - end - end - - for _, player in pairs(game.connected_players) do - if(player.controller_type ~= defines.controllers.ghost and player.character ~= nil) then - -- armor inventory is a one length inventory - local item = player.get_inventory(defines.inventory.player_armor)[1] - - if(item.valid_for_read and item.grid and item.grid.battery_capacity - item.grid.available_in_batteries > 0) then - local hit = false - local pt = { - ['ent'] = player.character, - ['grid'] = item.grid, - ['towers'] = {}, - } - - for name, info in pairs(charging_info) do - for _, tower in pairs(player.surface.find_entities_filtered{ - area={ - {player.position['x'] - info['range'], player.position['y'] - info['range']}, - {player.position['x'] + info['range'], player.position['y'] + info['range']}, - }, - name=name, - }) do - if(tower.force.name == player.force.name and global.interfaces[tower.unit_number].energy > 0) then - -- towers can charge multiple targets, find out which way the power will be split before actually doing the charge tick - if(hit ~= true) then - table.insert(targets, pt) - hit = true - end - - table.insert(pt.towers, tower) - split[tower.unit_number] = split[tower.unit_number] + 1 - end - end - end - end - end - end - - for _, info in pairs(targets) do - local grid = info.grid - local items = get_chargable_items(grid) - local item = table.remove(items, 1) - - if(item == nil) then -- wat - game.print('Localized Charging: this should never happen: no chargable items?') - error('Localized Charging: this should never happen: no chargable items?') - end - - for _, tower in pairs(info.towers) do - local power_info = charging_info[tower.name] - local interface = global.interfaces[tower.unit_number] - - -- lightning effect - tower.surface.create_entity{ - name = "charging-charge", - position = {tower.position['x'], tower.position['y'] - 1.5}, - force = info.ent.force, - target = info.ent - } - - local s = split[tower.unit_number] - - if(s == nil or s < 1) then - error('Localized Charging: invalid tower split: ' .. tostring(s)) - end - - local transfer = interface.energy / s - - -- we've partitioned off the energy we need - split[tower.unit_number] = split[tower.unit_number] - 1 - - repeat - local spent = item.energy - -- use ceil here to counter float imprecision - item.energy = item.energy + math.ceil(transfer * power_info.efficiency) - spent = (item.energy - spent) * (1 / power_info.efficiency) - - -- game.print(string.format('transferring %f to %i (split: %i, pool: %f, interface: %f)', spent, info.ent.unit_number, s, transfer, interface.energy)) - - transfer = transfer - spent - interface.energy = interface.energy - spent - - if(item.max_energy - item.energy < 1) then - -- charge the next item - item = table.remove(items, 1) - - -- everything has been charged - if(item == nil) then - break - end - end - until transfer < 1 - - if(item == nil) then - break - end - end - end - - -- game.print('-----') -end) - -local function on_entity_created(entity) - if(charging_info[entity.name] ~= nil) then - local uid = entity.unit_number - local interface = entity.surface.create_entity{ - name = charging_info[entity.name].interface, - position = {entity.position['x'], entity.position['y']}, - -- stop ai in everything mode from attacking this invulnerable building - force=game.forces['enemy'] --entity.force - } - - interface.operable = false - interface.destructible = false - interface.minable = false - - global.interfaces[uid] = interface - elseif(electric_vehicles[entity.name] ~= nil) then - -- trains could be paused here if they haven't been detected as moving - -- cars, etc can't be paused by event because there's no way to detect their inventory changing as it happens (no event) - table.insert(global.vehicles, { - ['vehicle'] = entity, - ['battery_fueling_enabled'] = true, - ['charging'] = false, - -- the last time the grid was scanned for non-empty batteries - ['lastCheck'] = 0, - }) - end -end - -local function on_entity_deleted(entity) - local interface = global.interfaces[entity.unit_number] - - if(interface ~= nil) then - interface.destroy() - end -end - --- hooks - -script.on_event(defines.events.on_robot_built_entity, function(event) - on_entity_created(event.created_entity) -end) - -script.on_event(defines.events.on_built_entity, function(event) - on_entity_created(event.created_entity) -end) - - -script.on_event(defines.events.on_entity_died, function(event) - on_entity_deleted(event.entity) -end) - -script.on_event(defines.events.on_preplayer_mined_item, function(event) - on_entity_deleted(event.entity) -end) - -script.on_event(defines.events.on_robot_pre_mined, function(event) - on_entity_deleted(event.entity) -end) - - --- unpause vehicle when player starts driving it, repause it with a player -> vehicle map to determine --- which vehicle stopped driving --- this is for tanks, jets, etc --- --- script.on_event(defines.events.on_player_driving_changed_state, function(event) --- local player = game.players[event.player_index] - --- if(player.vehicle == nil) then --- return --- end - --- local entity = player.vehicle - --- if(entity.name == 'electric-locomotive') then --- local current = entity.energy --- entity.energy = entity.energy + 1000 --- game.print('added: ' .. tostring(entity.energy - current)) --- end --- end) +require('constants') + +script.on_init(function() + global.interfaces = {} + global.vehicles = {} +end) + +local charging_info = { + ["localized-charging-pole-1"] = { + ['interface'] = 'localized-charging-pole-interface-1', + ['range'] = 10, + ['efficiency'] = 0.5, + }, + ["localized-charging-pole-2"] = { + ['interface'] = 'localized-charging-pole-interface-2', + ['range'] = 10, + ['efficiency'] = 0.5, + }, + ["localized-charging-pole-3"] = { + ['interface'] = 'localized-charging-pole-interface-3', + ['range'] = 10, + ['efficiency'] = 0.5, + }, + ["localized-charging-pole-4"] = { + ['interface'] = 'localized-charging-pole-interface-4', + ['range'] = 10, + ['efficiency'] = 0.5, + }, +} + +local electric_vehicles = { + ['electric-locomotive'] = true, + -- airship mod lol + ['gunship'] = true, + ['jet'] = true, + ['cargo-plane'] = true, + ['flying-fortress'] = true, + -- predictabowl vehicle mammoth tank + ['tank-mk3'] = true, +} + +remote.add_interface('Localized_Charging', { + --Allow other mods to add electric vehicles + add_electric_vehicle = function(name) + if (electric_vehicles[name] ~= nil) then + return true + end + local vehicle = game.entity_prototypes[name] + if (vehicle ~= nil) and ((vehicle.type == 'car') or (vehicle.type == 'locomotive')) then + electric_vehicles[name] = true + return true + end + return false + end, + --Handle entity replacement by AAI Programmable Vehicles + on_entity_replaced = function(event) + for k, vehicle_info in pairs(global.vehicles) do + local vehicle = vehicle_info.vehicle + if(vehicle == event.old_entity) then + global.vehicles[k]['vehicle'] = event.new_entity + if(remote.interfaces['aai-programmable-vehicles']) and (remote.call('aai-programmable-vehicles', 'get_unit_by_entity', vehicle) ~= nil) then + --AAIPV uses a special fueling method, so disable regular battery fueling + global.vehicles[k]['battery_fueling_enabled'] = false + end + break + end + end + end +}) + +local function defaultdict(d) + t = {} + setmetatable(t, { + __index = function (t, k) + local ret = d() + rawset(t, k, ret) + return ret + end + }) + return t +end + +local function get_chargable_items(grid) + local items = {} + + for _, item in pairs(grid.equipment) do + if(item.max_energy - item.energy > 0) then + table.insert(items, item) + end + end + + return items +end + +script.on_event(defines.events.on_tick, function(event) + local remove = {} + + for k, vehicle_info in pairs(global.vehicles) do + vehicle = vehicle_info.vehicle + + if(not vehicle.valid) then + table.insert(remove, k) + elseif(vehicle.grid ~= nil) and (vehicle_info.battery_fueling_enabled) then + local grid = vehicle.grid + local available_power = grid.available_in_batteries + local current_power = vehicle.energy + -- vehicles have a maximum energy cap that we have no way to read, so just get a delta to determine what we spent + vehicle.energy = vehicle.energy + available_power + local spent_power = vehicle.energy - current_power + + if(spent_power > 0) then + for _, item in pairs(grid.equipment) do + if(item.energy > 0) then + if(item.energy > spent_power) then + item.energy = item.energy - spent_power + break + else + spent_power = spent_power - item.energy + item.energy = 0 + end + end + end + end + end + end + + for _, k in pairs(remove) do + global.vehicles[k] = nil + end + + if not (game.tick % scan_tick == 0) then + return + end + + local targets = {} + local split = defaultdict(function() return 0 end) + + -- vehicles are checked for validity in the upper loop + for _, vehicle_info in pairs(global.vehicles) do + vehicle = vehicle_info.vehicle + + if(vehicle_info.charging == true or (game.tick - vehicle_info.lastCheck > vehicle_inventory_check)) then + vehicle_info.lastCheck = game.tick + + -- maybe grid can be situational in future patches, who knows? + local grid = vehicle.grid + local hit = false + + if(grid ~= nil and grid.battery_capacity - grid.available_in_batteries > 0) then + local pt = { + ['ent'] = vehicle, + ['grid'] = grid, + ['towers'] = {}, + } + + for name, info in pairs(charging_info) do + for _, tower in pairs(vehicle.surface.find_entities_filtered{ + area={ + {vehicle.position['x'] - info['range'], vehicle.position['y'] - info['range']}, + {vehicle.position['x'] + info['range'], vehicle.position['y'] + info['range']}, + }, + name=name, + }) do + if(tower.force.name == vehicle.force.name and global.interfaces[tower.unit_number].energy > 0) then + -- towers can charge multiple targets, find out which way the power will be split before actually doing the charge tick + if(hit ~= true) then + table.insert(targets, pt) + hit = true + end + + table.insert(pt.towers, tower) + split[tower.unit_number] = split[tower.unit_number] + 1 + end + end + end + end + + vehicle_info.charging = hit + end + end + + for _, player in pairs(game.connected_players) do + if(player.controller_type ~= defines.controllers.ghost and player.character ~= nil) then + -- armor inventory is a one length inventory + local item = player.get_inventory(defines.inventory.player_armor)[1] + + if(item.valid_for_read and item.grid and item.grid.battery_capacity - item.grid.available_in_batteries > 0) then + local hit = false + local pt = { + ['ent'] = player.character, + ['grid'] = item.grid, + ['towers'] = {}, + } + + for name, info in pairs(charging_info) do + for _, tower in pairs(player.surface.find_entities_filtered{ + area={ + {player.position['x'] - info['range'], player.position['y'] - info['range']}, + {player.position['x'] + info['range'], player.position['y'] + info['range']}, + }, + name=name, + }) do + if(tower.force.name == player.force.name and global.interfaces[tower.unit_number].energy > 0) then + -- towers can charge multiple targets, find out which way the power will be split before actually doing the charge tick + if(hit ~= true) then + table.insert(targets, pt) + hit = true + end + + table.insert(pt.towers, tower) + split[tower.unit_number] = split[tower.unit_number] + 1 + end + end + end + end + end + end + + for _, info in pairs(targets) do + local grid = info.grid + local items = get_chargable_items(grid) + local item = table.remove(items, 1) + + if(item == nil) then -- wat + game.print('Localized Charging: this should never happen: no chargable items?') + error('Localized Charging: this should never happen: no chargable items?') + end + + for _, tower in pairs(info.towers) do + local power_info = charging_info[tower.name] + local interface = global.interfaces[tower.unit_number] + + -- lightning effect + tower.surface.create_entity{ + name = "charging-charge", + position = {tower.position['x'], tower.position['y'] - 1.5}, + force = info.ent.force, + target = info.ent + } + + local s = split[tower.unit_number] + + if(s == nil or s < 1) then + error('Localized Charging: invalid tower split: ' .. tostring(s)) + end + + local transfer = interface.energy / s + + -- we've partitioned off the energy we need + split[tower.unit_number] = split[tower.unit_number] - 1 + + repeat + local spent = item.energy + -- use ceil here to counter float imprecision + item.energy = item.energy + math.ceil(transfer * power_info.efficiency) + spent = (item.energy - spent) * (1 / power_info.efficiency) + + -- game.print(string.format('transferring %f to %i (split: %i, pool: %f, interface: %f)', spent, info.ent.unit_number, s, transfer, interface.energy)) + + transfer = transfer - spent + interface.energy = interface.energy - spent + + if(item.max_energy - item.energy < 1) then + -- charge the next item + item = table.remove(items, 1) + + -- everything has been charged + if(item == nil) then + break + end + end + until transfer < 1 + + if(item == nil) then + break + end + end + end + + -- game.print('-----') +end) + +local function on_entity_created(entity) + if(charging_info[entity.name] ~= nil) then + local uid = entity.unit_number + local interface = entity.surface.create_entity{ + name = charging_info[entity.name].interface, + position = {entity.position['x'], entity.position['y']}, + -- stop ai in everything mode from attacking this invulnerable building + force=game.forces['enemy'] --entity.force + } + + interface.operable = false + interface.destructible = false + interface.minable = false + + global.interfaces[uid] = interface + elseif(electric_vehicles[entity.name] ~= nil) then + -- trains could be paused here if they haven't been detected as moving + -- cars, etc can't be paused by event because there's no way to detect their inventory changing as it happens (no event) + table.insert(global.vehicles, { + ['vehicle'] = entity, + ['battery_fueling_enabled'] = true, + ['charging'] = false, + -- the last time the grid was scanned for non-empty batteries + ['lastCheck'] = 0, + }) + end +end + +local function on_entity_deleted(entity) + local interface = global.interfaces[entity.unit_number] + + if(interface ~= nil) then + interface.destroy() + end +end + +-- hooks + +script.on_event(defines.events.on_robot_built_entity, function(event) + on_entity_created(event.created_entity) +end) + +script.on_event(defines.events.on_built_entity, function(event) + on_entity_created(event.created_entity) +end) + + +script.on_event(defines.events.on_entity_died, function(event) + on_entity_deleted(event.entity) +end) + +script.on_event(defines.events.on_preplayer_mined_item, function(event) + on_entity_deleted(event.entity) +end) + +script.on_event(defines.events.on_robot_pre_mined, function(event) + on_entity_deleted(event.entity) +end) + + +-- unpause vehicle when player starts driving it, repause it with a player -> vehicle map to determine +-- which vehicle stopped driving +-- this is for tanks, jets, etc +-- +-- script.on_event(defines.events.on_player_driving_changed_state, function(event) +-- local player = game.players[event.player_index] + +-- if(player.vehicle == nil) then +-- return +-- end + +-- local entity = player.vehicle + +-- if(entity.name == 'electric-locomotive') then +-- local current = entity.energy +-- entity.energy = entity.energy + 1000 +-- game.print('added: ' .. tostring(entity.energy - current)) +-- end +-- end) diff --git a/Localized_Charging_1.0.0/data.lua b/Localized_Charging_1.1.0/data.lua similarity index 97% rename from Localized_Charging_1.0.0/data.lua rename to Localized_Charging_1.1.0/data.lua index cde766c..a1e26ad 100644 --- a/Localized_Charging_1.0.0/data.lua +++ b/Localized_Charging_1.1.0/data.lua @@ -1,5 +1,5 @@ -require('prototypes.items') -require('prototypes.recipes') -require('prototypes.charger') -require('prototypes.vehicles') +require('prototypes.items') +require('prototypes.recipes') +require('prototypes.charger') +require('prototypes.vehicles') require('prototypes.technologies') \ No newline at end of file diff --git a/Localized_Charging_1.0.0/graphics/entity/localized-charging-pole/bright.png b/Localized_Charging_1.1.0/graphics/entity/localized-charging-pole/bright.png similarity index 100% rename from Localized_Charging_1.0.0/graphics/entity/localized-charging-pole/bright.png rename to Localized_Charging_1.1.0/graphics/entity/localized-charging-pole/bright.png diff --git a/Localized_Charging_1.0.0/graphics/entity/localized-charging-pole/powered.png b/Localized_Charging_1.1.0/graphics/entity/localized-charging-pole/powered.png similarity index 100% rename from Localized_Charging_1.0.0/graphics/entity/localized-charging-pole/powered.png rename to Localized_Charging_1.1.0/graphics/entity/localized-charging-pole/powered.png diff --git a/Localized_Charging_1.0.0/graphics/entity/localized-charging-pole/unpowered.png b/Localized_Charging_1.1.0/graphics/entity/localized-charging-pole/unpowered.png similarity index 100% rename from Localized_Charging_1.0.0/graphics/entity/localized-charging-pole/unpowered.png rename to Localized_Charging_1.1.0/graphics/entity/localized-charging-pole/unpowered.png diff --git a/Localized_Charging_1.0.0/graphics/entity/projectile/induction-charge-beam.png b/Localized_Charging_1.1.0/graphics/entity/projectile/induction-charge-beam.png similarity index 100% rename from Localized_Charging_1.0.0/graphics/entity/projectile/induction-charge-beam.png rename to Localized_Charging_1.1.0/graphics/entity/projectile/induction-charge-beam.png diff --git a/Localized_Charging_1.0.0/graphics/icons/electric-locomotive.png b/Localized_Charging_1.1.0/graphics/icons/electric-locomotive.png similarity index 100% rename from Localized_Charging_1.0.0/graphics/icons/electric-locomotive.png rename to Localized_Charging_1.1.0/graphics/icons/electric-locomotive.png diff --git a/Localized_Charging_1.0.0/graphics/icons/localized-charging-pole.png b/Localized_Charging_1.1.0/graphics/icons/localized-charging-pole.png similarity index 100% rename from Localized_Charging_1.0.0/graphics/icons/localized-charging-pole.png rename to Localized_Charging_1.1.0/graphics/icons/localized-charging-pole.png diff --git a/Localized_Charging_1.0.0/graphics/technology/electric-trains.png b/Localized_Charging_1.1.0/graphics/technology/electric-trains.png similarity index 100% rename from Localized_Charging_1.0.0/graphics/technology/electric-trains.png rename to Localized_Charging_1.1.0/graphics/technology/electric-trains.png diff --git a/Localized_Charging_1.0.0/info.json b/Localized_Charging_1.1.0/info.json similarity index 89% rename from Localized_Charging_1.0.0/info.json rename to Localized_Charging_1.1.0/info.json index 3aa4f98..0ae8604 100644 --- a/Localized_Charging_1.0.0/info.json +++ b/Localized_Charging_1.1.0/info.json @@ -1,10 +1,9 @@ - -{ - "name": "Localized_Charging", - "version": "1.0.0", - "title": "Localized_Charging", - "author": "Sirenfal", - "description": "A charging mod that will recharge batteries in vehicles and power armor when near a charging pole.", - "dependencies": ["base >= 0.15.0"], - "factorio_version": "0.15.0" -} +{ + "name": "Localized_Charging", + "version": "1.1.0", + "title": "Localized_Charging", + "author": "Sirenfal", + "description": "A charging mod that will recharge batteries in vehicles and power armor when near a charging pole.", + "dependencies": ["base >= 0.15.0"], + "factorio_version": "0.15.0" +} diff --git a/Localized_Charging_1.0.0/locale/en/all.cfg b/Localized_Charging_1.1.0/locale/en/all.cfg similarity index 100% rename from Localized_Charging_1.0.0/locale/en/all.cfg rename to Localized_Charging_1.1.0/locale/en/all.cfg diff --git a/Localized_Charging_1.0.0/migrations/Localized_Charging_1.0.0.json b/Localized_Charging_1.1.0/migrations/Localized_Charging_1.0.0.json similarity index 100% rename from Localized_Charging_1.0.0/migrations/Localized_Charging_1.0.0.json rename to Localized_Charging_1.1.0/migrations/Localized_Charging_1.0.0.json diff --git a/Localized_Charging_1.0.0/migrations/Localized_Charging_1.0.0.lua b/Localized_Charging_1.1.0/migrations/Localized_Charging_1.0.0.lua similarity index 100% rename from Localized_Charging_1.0.0/migrations/Localized_Charging_1.0.0.lua rename to Localized_Charging_1.1.0/migrations/Localized_Charging_1.0.0.lua diff --git a/Localized_Charging_1.0.0/prototypes/charger.lua b/Localized_Charging_1.1.0/prototypes/charger.lua similarity index 95% rename from Localized_Charging_1.0.0/prototypes/charger.lua rename to Localized_Charging_1.1.0/prototypes/charger.lua index aab3a34..91a2754 100644 --- a/Localized_Charging_1.0.0/prototypes/charger.lua +++ b/Localized_Charging_1.1.0/prototypes/charger.lua @@ -1,474 +1,474 @@ -require('constants') - --- in megawatts per second -local charging_output = 40 - -data:extend({ - { - type = "explosion", - name = "charging-charge", - flags = {"not-on-map", "placeable-off-grid"}, - animation_speed = 1, - rotate = true, - beam = true, - animations = - { - { - filename = "__Localized_Charging__/graphics/entity/projectile/induction-charge-beam.png", - priority = "extra-high", - width = 20, - height = 70, - frame_count = 6, - } - }, - light = { - intensity = 0.15, - size = 14, - shift = {0, 1.5}, - color = {r = 70 / 255, g = 153 / 255, b = 223 / 255}, - }, - -- smoke = "smoke-fast", - -- smoke_count = 1, - -- smoke_slow_down_factor = 1 - }, - { - type = "electric-energy-interface", - name = "localized-charging-pole-interface-1", - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - localised_name = {'entity-name.localized-charging-pole-1'}, - collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, - flags = {"not-blueprintable", "not-deconstructable", "not-on-map", "placeable-off-grid"}, - max_health = 1, -- At least you made it invulnerable in the script. - corpse = "medium-remnants", - collision_mask = {}, - energy_source = - { - type = "electric", - buffer_capacity = (((charging_output / 8) * scan_tick) / 60) .. 'MJ', - usage_priority = "secondary-input", - input_flow_limit = ((charging_output / 8) * scan_tick) .. 'MW', - output_flow_limit = "0W" - }, - energy_production = "0W", - energy_usage = "0kW", - picture = - { - filename = "__core__/graphics/empty.png", - priority = "low", - width = 1, - height = 1, - }, - }, - { - type = "electric-energy-interface", - name = "localized-charging-pole-interface-2", - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - localised_name = {'entity-name.localized-charging-pole-2'}, - collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, - flags = {"not-blueprintable", "not-deconstructable", "not-on-map", "placeable-off-grid"}, - max_health = 1, - corpse = "medium-remnants", - collision_mask = {}, - energy_source = - { - type = "electric", - buffer_capacity = (((charging_output / 4) * scan_tick) / 60) .. 'MJ', - usage_priority = "secondary-input", - input_flow_limit = ((charging_output / 4) * scan_tick) .. 'MW', - output_flow_limit = "0W" - }, - energy_production = "0W", - energy_usage = "0kW", - picture = - { - filename = "__core__/graphics/empty.png", - priority = "low", - width = 1, - height = 1, - }, - }, - { - type = "electric-energy-interface", - name = "localized-charging-pole-interface-3", - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - localised_name = {'entity-name.localized-charging-pole-3'}, - collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, - flags = {"not-blueprintable", "not-deconstructable", "not-on-map", "placeable-off-grid"}, - max_health = 1, - corpse = "medium-remnants", - collision_mask = {}, - energy_source = - { - type = "electric", - buffer_capacity = (((charging_output / 2) * scan_tick) / 60) .. 'MJ', - usage_priority = "secondary-input", - input_flow_limit = ((charging_output / 2) * scan_tick) .. 'MW', - output_flow_limit = "0W" - }, - energy_production = "0W", - energy_usage = "0kW", - picture = - { - filename = "__core__/graphics/empty.png", - priority = "low", - width = 1, - height = 1, - }, - }, - { - type = "electric-energy-interface", - name = "localized-charging-pole-interface-4", - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - localised_name = {'entity-name.localized-charging-pole-4'}, - collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, - flags = {"not-blueprintable", "not-deconstructable", "not-on-map", "placeable-off-grid"}, - max_health = 1, - corpse = "medium-remnants", - collision_mask = {}, - energy_source = - { - type = "electric", - buffer_capacity = ((charging_output * scan_tick) / 60) .. 'MJ', - usage_priority = "secondary-input", - input_flow_limit = (charging_output * scan_tick) .. 'MW', - output_flow_limit = "0W" - }, - energy_production = "0W", - energy_usage = "0kW", - picture = - { - filename = "__core__/graphics/empty.png", - priority = "low", - width = 1, - height = 1, - }, - }, - { - type = "electric-pole", - name = 'localized-charging-pole-1', - localised_name = {'entity-name.localized-charging-pole-1'}, - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - flags = {"placeable-neutral", "player-creation"}, - minable = {hardness = 0.2, mining_time = 0.5, result = "localized-charging-pole-1"}, - max_health = 400, - corpse = "medium-remnants", - resistances = - { - { - type = "fire", - percent = 100 - } - }, - collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, - selection_box = {{-1, -1}, {1, 1}}, - drawing_box = {{-1, -3}, {1, 0.5}}, - maximum_wire_distance = 30, - supply_area_distance = 0, - vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, - pictures = - { - filename = '__Localized_Charging__/graphics/entity/localized-charging-pole/powered.png', - priority = "high", - width = 168, - height = 165, - direction_count = 4, - shift = {1.6, -1.1} - }, - connection_points = - { - { - shadow = - { - copper = {2.7, 0}, - }, - wire = - { - copper = {0, -3.125}, - } - }, - { - shadow = - { - copper = {3.1, 0.2}, - }, - wire = - { - copper = {-0.0625, -3.125}, - } - }, - { - shadow = - { - copper = {2.9, 0.06}, - }, - wire = - { - copper = {-0.09375, -3.09375}, - } - }, - { - shadow = - { - copper = {3.1, 0.2}, - }, - wire = - { - copper = {-0.0625, -3.1875}, - } - } - }, - radius_visualisation_picture = - { - filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png", - width = 12, - height = 12, - priority = "extra-high-no-scale" - }, - }, - { - type = "electric-pole", - name = 'localized-charging-pole-2', - localised_name = {'entity-name.localized-charging-pole-2'}, - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - flags = {"placeable-neutral", "player-creation"}, - minable = {hardness = 0.2, mining_time = 0.5, result = "localized-charging-pole-2"}, - max_health = 400, - corpse = "medium-remnants", - resistances = - { - { - type = "fire", - percent = 100 - } - }, - collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, - selection_box = {{-1, -1}, {1, 1}}, - drawing_box = {{-1, -3}, {1, 0.5}}, - maximum_wire_distance = 30, - supply_area_distance = 0, - vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, - pictures = - { - filename = '__Localized_Charging__/graphics/entity/localized-charging-pole/powered.png', - priority = "high", - width = 168, - height = 165, - direction_count = 4, - shift = {1.6, -1.1} - }, - connection_points = - { - { - shadow = - { - copper = {2.7, 0}, - }, - wire = - { - copper = {0, -3.125}, - } - }, - { - shadow = - { - copper = {3.1, 0.2}, - }, - wire = - { - copper = {-0.0625, -3.125}, - } - }, - { - shadow = - { - copper = {2.9, 0.06}, - }, - wire = - { - copper = {-0.09375, -3.09375}, - } - }, - { - shadow = - { - copper = {3.1, 0.2}, - }, - wire = - { - copper = {-0.0625, -3.1875}, - } - } - }, - radius_visualisation_picture = - { - filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png", - width = 12, - height = 12, - priority = "extra-high-no-scale" - }, - }, - { - type = "electric-pole", - name = 'localized-charging-pole-3', - localised_name = {'entity-name.localized-charging-pole-3'}, - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - flags = {"placeable-neutral", "player-creation"}, - minable = {hardness = 0.2, mining_time = 0.5, result = "localized-charging-pole-3"}, - max_health = 400, - corpse = "medium-remnants", - resistances = - { - { - type = "fire", - percent = 100 - } - }, - collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, - selection_box = {{-1, -1}, {1, 1}}, - drawing_box = {{-1, -3}, {1, 0.5}}, - maximum_wire_distance = 30, - supply_area_distance = 0, - vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, - pictures = - { - filename = '__Localized_Charging__/graphics/entity/localized-charging-pole/powered.png', - priority = "high", - width = 168, - height = 165, - direction_count = 4, - shift = {1.6, -1.1} - }, - connection_points = - { - { - shadow = - { - copper = {2.7, 0}, - }, - wire = - { - copper = {0, -3.125}, - } - }, - { - shadow = - { - copper = {3.1, 0.2}, - }, - wire = - { - copper = {-0.0625, -3.125}, - } - }, - { - shadow = - { - copper = {2.9, 0.06}, - }, - wire = - { - copper = {-0.09375, -3.09375}, - } - }, - { - shadow = - { - copper = {3.1, 0.2}, - }, - wire = - { - copper = {-0.0625, -3.1875}, - } - } - }, - radius_visualisation_picture = - { - filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png", - width = 12, - height = 12, - priority = "extra-high-no-scale" - }, - }, - { - type = "electric-pole", - name = 'localized-charging-pole-4', - localised_name = {'entity-name.localized-charging-pole-4'}, - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - flags = {"placeable-neutral", "player-creation"}, - minable = {hardness = 0.2, mining_time = 0.5, result = "localized-charging-pole-4"}, - max_health = 400, - corpse = "medium-remnants", - resistances = - { - { - type = "fire", - percent = 100 - } - }, - collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, - selection_box = {{-1, -1}, {1, 1}}, - drawing_box = {{-1, -3}, {1, 0.5}}, - maximum_wire_distance = 30, - supply_area_distance = 0, - vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, - pictures = - { - filename = '__Localized_Charging__/graphics/entity/localized-charging-pole/powered.png', - priority = "high", - width = 168, - height = 165, - direction_count = 4, - shift = {1.6, -1.1} - }, - connection_points = - { - { - shadow = - { - copper = {2.7, 0}, - }, - wire = - { - copper = {0, -3.125}, - } - }, - { - shadow = - { - copper = {3.1, 0.2}, - }, - wire = - { - copper = {-0.0625, -3.125}, - } - }, - { - shadow = - { - copper = {2.9, 0.06}, - }, - wire = - { - copper = {-0.09375, -3.09375}, - } - }, - { - shadow = - { - copper = {3.1, 0.2}, - }, - wire = - { - copper = {-0.0625, -3.1875}, - } - } - }, - radius_visualisation_picture = - { - filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png", - width = 12, - height = 12, - priority = "extra-high-no-scale" - }, - }, -}) +require('constants') + +-- in megawatts per second +local charging_output = 40 + +data:extend({ + { + type = "explosion", + name = "charging-charge", + flags = {"not-on-map", "placeable-off-grid"}, + animation_speed = 1, + rotate = true, + beam = true, + animations = + { + { + filename = "__Localized_Charging__/graphics/entity/projectile/induction-charge-beam.png", + priority = "extra-high", + width = 20, + height = 70, + frame_count = 6, + } + }, + light = { + intensity = 0.15, + size = 14, + shift = {0, 1.5}, + color = {r = 70 / 255, g = 153 / 255, b = 223 / 255}, + }, + -- smoke = "smoke-fast", + -- smoke_count = 1, + -- smoke_slow_down_factor = 1 + }, + { + type = "electric-energy-interface", + name = "localized-charging-pole-interface-1", + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + localised_name = {'entity-name.localized-charging-pole-1'}, + collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, + flags = {"not-blueprintable", "not-deconstructable", "not-on-map", "placeable-off-grid"}, + max_health = 1, -- At least you made it invulnerable in the script. + corpse = "medium-remnants", + collision_mask = {}, + energy_source = + { + type = "electric", + buffer_capacity = (((charging_output / 8) * scan_tick) / 60) .. 'MJ', + usage_priority = "secondary-input", + input_flow_limit = ((charging_output / 8) * scan_tick) .. 'MW', + output_flow_limit = "0W" + }, + energy_production = "0W", + energy_usage = "0kW", + picture = + { + filename = "__core__/graphics/empty.png", + priority = "low", + width = 1, + height = 1, + }, + }, + { + type = "electric-energy-interface", + name = "localized-charging-pole-interface-2", + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + localised_name = {'entity-name.localized-charging-pole-2'}, + collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, + flags = {"not-blueprintable", "not-deconstructable", "not-on-map", "placeable-off-grid"}, + max_health = 1, + corpse = "medium-remnants", + collision_mask = {}, + energy_source = + { + type = "electric", + buffer_capacity = (((charging_output / 4) * scan_tick) / 60) .. 'MJ', + usage_priority = "secondary-input", + input_flow_limit = ((charging_output / 4) * scan_tick) .. 'MW', + output_flow_limit = "0W" + }, + energy_production = "0W", + energy_usage = "0kW", + picture = + { + filename = "__core__/graphics/empty.png", + priority = "low", + width = 1, + height = 1, + }, + }, + { + type = "electric-energy-interface", + name = "localized-charging-pole-interface-3", + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + localised_name = {'entity-name.localized-charging-pole-3'}, + collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, + flags = {"not-blueprintable", "not-deconstructable", "not-on-map", "placeable-off-grid"}, + max_health = 1, + corpse = "medium-remnants", + collision_mask = {}, + energy_source = + { + type = "electric", + buffer_capacity = (((charging_output / 2) * scan_tick) / 60) .. 'MJ', + usage_priority = "secondary-input", + input_flow_limit = ((charging_output / 2) * scan_tick) .. 'MW', + output_flow_limit = "0W" + }, + energy_production = "0W", + energy_usage = "0kW", + picture = + { + filename = "__core__/graphics/empty.png", + priority = "low", + width = 1, + height = 1, + }, + }, + { + type = "electric-energy-interface", + name = "localized-charging-pole-interface-4", + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + localised_name = {'entity-name.localized-charging-pole-4'}, + collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, + flags = {"not-blueprintable", "not-deconstructable", "not-on-map", "placeable-off-grid"}, + max_health = 1, + corpse = "medium-remnants", + collision_mask = {}, + energy_source = + { + type = "electric", + buffer_capacity = ((charging_output * scan_tick) / 60) .. 'MJ', + usage_priority = "secondary-input", + input_flow_limit = (charging_output * scan_tick) .. 'MW', + output_flow_limit = "0W" + }, + energy_production = "0W", + energy_usage = "0kW", + picture = + { + filename = "__core__/graphics/empty.png", + priority = "low", + width = 1, + height = 1, + }, + }, + { + type = "electric-pole", + name = 'localized-charging-pole-1', + localised_name = {'entity-name.localized-charging-pole-1'}, + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + flags = {"placeable-neutral", "player-creation"}, + minable = {hardness = 0.2, mining_time = 0.5, result = "localized-charging-pole-1"}, + max_health = 400, + corpse = "medium-remnants", + resistances = + { + { + type = "fire", + percent = 100 + } + }, + collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, + selection_box = {{-1, -1}, {1, 1}}, + drawing_box = {{-1, -3}, {1, 0.5}}, + maximum_wire_distance = 30, + supply_area_distance = 0, + vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, + pictures = + { + filename = '__Localized_Charging__/graphics/entity/localized-charging-pole/powered.png', + priority = "high", + width = 168, + height = 165, + direction_count = 4, + shift = {1.6, -1.1} + }, + connection_points = + { + { + shadow = + { + copper = {2.7, 0}, + }, + wire = + { + copper = {0, -3.125}, + } + }, + { + shadow = + { + copper = {3.1, 0.2}, + }, + wire = + { + copper = {-0.0625, -3.125}, + } + }, + { + shadow = + { + copper = {2.9, 0.06}, + }, + wire = + { + copper = {-0.09375, -3.09375}, + } + }, + { + shadow = + { + copper = {3.1, 0.2}, + }, + wire = + { + copper = {-0.0625, -3.1875}, + } + } + }, + radius_visualisation_picture = + { + filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png", + width = 12, + height = 12, + priority = "extra-high-no-scale" + }, + }, + { + type = "electric-pole", + name = 'localized-charging-pole-2', + localised_name = {'entity-name.localized-charging-pole-2'}, + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + flags = {"placeable-neutral", "player-creation"}, + minable = {hardness = 0.2, mining_time = 0.5, result = "localized-charging-pole-2"}, + max_health = 400, + corpse = "medium-remnants", + resistances = + { + { + type = "fire", + percent = 100 + } + }, + collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, + selection_box = {{-1, -1}, {1, 1}}, + drawing_box = {{-1, -3}, {1, 0.5}}, + maximum_wire_distance = 30, + supply_area_distance = 0, + vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, + pictures = + { + filename = '__Localized_Charging__/graphics/entity/localized-charging-pole/powered.png', + priority = "high", + width = 168, + height = 165, + direction_count = 4, + shift = {1.6, -1.1} + }, + connection_points = + { + { + shadow = + { + copper = {2.7, 0}, + }, + wire = + { + copper = {0, -3.125}, + } + }, + { + shadow = + { + copper = {3.1, 0.2}, + }, + wire = + { + copper = {-0.0625, -3.125}, + } + }, + { + shadow = + { + copper = {2.9, 0.06}, + }, + wire = + { + copper = {-0.09375, -3.09375}, + } + }, + { + shadow = + { + copper = {3.1, 0.2}, + }, + wire = + { + copper = {-0.0625, -3.1875}, + } + } + }, + radius_visualisation_picture = + { + filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png", + width = 12, + height = 12, + priority = "extra-high-no-scale" + }, + }, + { + type = "electric-pole", + name = 'localized-charging-pole-3', + localised_name = {'entity-name.localized-charging-pole-3'}, + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + flags = {"placeable-neutral", "player-creation"}, + minable = {hardness = 0.2, mining_time = 0.5, result = "localized-charging-pole-3"}, + max_health = 400, + corpse = "medium-remnants", + resistances = + { + { + type = "fire", + percent = 100 + } + }, + collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, + selection_box = {{-1, -1}, {1, 1}}, + drawing_box = {{-1, -3}, {1, 0.5}}, + maximum_wire_distance = 30, + supply_area_distance = 0, + vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, + pictures = + { + filename = '__Localized_Charging__/graphics/entity/localized-charging-pole/powered.png', + priority = "high", + width = 168, + height = 165, + direction_count = 4, + shift = {1.6, -1.1} + }, + connection_points = + { + { + shadow = + { + copper = {2.7, 0}, + }, + wire = + { + copper = {0, -3.125}, + } + }, + { + shadow = + { + copper = {3.1, 0.2}, + }, + wire = + { + copper = {-0.0625, -3.125}, + } + }, + { + shadow = + { + copper = {2.9, 0.06}, + }, + wire = + { + copper = {-0.09375, -3.09375}, + } + }, + { + shadow = + { + copper = {3.1, 0.2}, + }, + wire = + { + copper = {-0.0625, -3.1875}, + } + } + }, + radius_visualisation_picture = + { + filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png", + width = 12, + height = 12, + priority = "extra-high-no-scale" + }, + }, + { + type = "electric-pole", + name = 'localized-charging-pole-4', + localised_name = {'entity-name.localized-charging-pole-4'}, + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + flags = {"placeable-neutral", "player-creation"}, + minable = {hardness = 0.2, mining_time = 0.5, result = "localized-charging-pole-4"}, + max_health = 400, + corpse = "medium-remnants", + resistances = + { + { + type = "fire", + percent = 100 + } + }, + collision_box = {{-0.65, -0.65}, {0.65, 0.65}}, + selection_box = {{-1, -1}, {1, 1}}, + drawing_box = {{-1, -3}, {1, 0.5}}, + maximum_wire_distance = 30, + supply_area_distance = 0, + vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, + pictures = + { + filename = '__Localized_Charging__/graphics/entity/localized-charging-pole/powered.png', + priority = "high", + width = 168, + height = 165, + direction_count = 4, + shift = {1.6, -1.1} + }, + connection_points = + { + { + shadow = + { + copper = {2.7, 0}, + }, + wire = + { + copper = {0, -3.125}, + } + }, + { + shadow = + { + copper = {3.1, 0.2}, + }, + wire = + { + copper = {-0.0625, -3.125}, + } + }, + { + shadow = + { + copper = {2.9, 0.06}, + }, + wire = + { + copper = {-0.09375, -3.09375}, + } + }, + { + shadow = + { + copper = {3.1, 0.2}, + }, + wire = + { + copper = {-0.0625, -3.1875}, + } + } + }, + radius_visualisation_picture = + { + filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png", + width = 12, + height = 12, + priority = "extra-high-no-scale" + }, + }, +}) diff --git a/Localized_Charging_1.0.0/prototypes/items.lua b/Localized_Charging_1.1.0/prototypes/items.lua similarity index 96% rename from Localized_Charging_1.0.0/prototypes/items.lua rename to Localized_Charging_1.1.0/prototypes/items.lua index 83c4d30..b5376c2 100644 --- a/Localized_Charging_1.0.0/prototypes/items.lua +++ b/Localized_Charging_1.1.0/prototypes/items.lua @@ -1,96 +1,96 @@ -require('volt_util') - -data:extend({ - { - type = "item", - name = "localized-charging-pole-1", - localised_name = {'entity-name.localized-charging-pole-1'}, - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - flags = {"goes-to-quickbar"}, - subgroup = "energy-pipe-distribution", - order = "a[energy]-z[localized-charging-pole-1]", - place_result = "localized-charging-pole-1", - stack_size = 10 - }, - - { - type = "item", - name = "localized-charging-pole-2", - localised_name = {'entity-name.localized-charging-pole-2'}, - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - flags = {"goes-to-quickbar"}, - subgroup = "energy-pipe-distribution", - order = "a[energy]-z[localized-charging-pole-2]", - place_result = "localized-charging-pole-2", - stack_size = 10 - }, - - { - type = "item", - name = "localized-charging-pole-3", - localised_name = {'entity-name.localized-charging-pole-3'}, - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - flags = {"goes-to-quickbar"}, - subgroup = "energy-pipe-distribution", - order = "a[energy]-z[localized-charging-pole-3]", - place_result = "localized-charging-pole-3", - stack_size = 10 - }, - - { - type = "item", - name = "localized-charging-pole-4", - localised_name = {'entity-name.localized-charging-pole-4'}, - icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", - flags = {"goes-to-quickbar"}, - subgroup = "energy-pipe-distribution", - order = "a[energy]-z[localized-charging-pole-4]", - place_result = "localized-charging-pole-4", - stack_size = 10 - }, - clone_existing_data(data.raw['item-with-entity-data']['locomotive'], { - name = "electric-locomotive", - localised_name={'vehicles.electric-locomotive'}, - icon = "__Localized_Charging__/graphics/icons/electric-locomotive.png", - order = "a[train-system]-f[electric-locomotive]", - place_result = "electric-locomotive", - }), - - { - type = "item", - name = "test-battery-please-ignore", - icon = "__base__/graphics/icons/battery-mk2-equipment.png", - placed_as_equipment_result = "test-battery-please-ignore", - flags = {"goes-to-main-inventory"}, - subgroup = "equipment", - order = "c[battery]-b[test-battery-please-ignore]", - stack_size = 50, - default_request_amount = 10 - }, - { - type = "battery-equipment", - name = "test-battery-please-ignore", - sprite = - { - filename = "__base__/graphics/equipment/battery-mk2-equipment.png", - width = 32, - height = 64, - priority = "medium" - }, - shape = - { - width = 1, - height = 2, - type = "full" - }, - energy_source = - { - type = "electric", - buffer_capacity = "30GJ", - input_flow_limit = "1GW", - output_flow_limit = "1GW", - usage_priority = "terciary" - }, - categories = {"armor"} - }, -}) +require('volt_util') + +data:extend({ + { + type = "item", + name = "localized-charging-pole-1", + localised_name = {'entity-name.localized-charging-pole-1'}, + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + flags = {"goes-to-quickbar"}, + subgroup = "energy-pipe-distribution", + order = "a[energy]-z[localized-charging-pole-1]", + place_result = "localized-charging-pole-1", + stack_size = 10 + }, + + { + type = "item", + name = "localized-charging-pole-2", + localised_name = {'entity-name.localized-charging-pole-2'}, + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + flags = {"goes-to-quickbar"}, + subgroup = "energy-pipe-distribution", + order = "a[energy]-z[localized-charging-pole-2]", + place_result = "localized-charging-pole-2", + stack_size = 10 + }, + + { + type = "item", + name = "localized-charging-pole-3", + localised_name = {'entity-name.localized-charging-pole-3'}, + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + flags = {"goes-to-quickbar"}, + subgroup = "energy-pipe-distribution", + order = "a[energy]-z[localized-charging-pole-3]", + place_result = "localized-charging-pole-3", + stack_size = 10 + }, + + { + type = "item", + name = "localized-charging-pole-4", + localised_name = {'entity-name.localized-charging-pole-4'}, + icon = "__Localized_Charging__/graphics/icons/localized-charging-pole.png", + flags = {"goes-to-quickbar"}, + subgroup = "energy-pipe-distribution", + order = "a[energy]-z[localized-charging-pole-4]", + place_result = "localized-charging-pole-4", + stack_size = 10 + }, + clone_existing_data(data.raw['item-with-entity-data']['locomotive'], { + name = "electric-locomotive", + localised_name={'vehicles.electric-locomotive'}, + icon = "__Localized_Charging__/graphics/icons/electric-locomotive.png", + order = "a[train-system]-f[electric-locomotive]", + place_result = "electric-locomotive", + }), + + { + type = "item", + name = "test-battery-please-ignore", + icon = "__base__/graphics/icons/battery-mk2-equipment.png", + placed_as_equipment_result = "test-battery-please-ignore", + flags = {"goes-to-main-inventory"}, + subgroup = "equipment", + order = "c[battery]-b[test-battery-please-ignore]", + stack_size = 50, + default_request_amount = 10 + }, + { + type = "battery-equipment", + name = "test-battery-please-ignore", + sprite = + { + filename = "__base__/graphics/equipment/battery-mk2-equipment.png", + width = 32, + height = 64, + priority = "medium" + }, + shape = + { + width = 1, + height = 2, + type = "full" + }, + energy_source = + { + type = "electric", + buffer_capacity = "30GJ", + input_flow_limit = "1GW", + output_flow_limit = "1GW", + usage_priority = "terciary" + }, + categories = {"armor"} + }, +}) diff --git a/Localized_Charging_1.0.0/prototypes/recipes.lua b/Localized_Charging_1.1.0/prototypes/recipes.lua similarity index 95% rename from Localized_Charging_1.0.0/prototypes/recipes.lua rename to Localized_Charging_1.1.0/prototypes/recipes.lua index fdda83a..1b468ac 100644 --- a/Localized_Charging_1.0.0/prototypes/recipes.lua +++ b/Localized_Charging_1.1.0/prototypes/recipes.lua @@ -1,78 +1,78 @@ -data:extend({ - { - type = "recipe", - name = "localized-charging-pole-1", - localised_name = {'entity-name.localized-charging-pole-1'}, - enabled = false, - ingredients = { - {"advanced-circuit", 20}, - {"electronic-circuit", 40}, - {"iron-plate", 90}, - {"steel-plate", 15}, - {"wood", 5}, - {"battery", 15}, - }, - result = "localized-charging-pole-1", - }, - - { - type = "recipe", - name = "localized-charging-pole-2", - localised_name = {'entity-name.localized-charging-pole-2'}, - enabled = false, - ingredients = { - {"advanced-circuit", 5}, - {"electronic-circuit", 20}, - {"iron-plate", 10}, - {"steel-plate", 5}, - {"battery", 5}, - {"localized-charging-pole-1", 1}, - }, - result = "localized-charging-pole-2", - }, - - { - type = "recipe", - name = "localized-charging-pole-3", - localised_name = {'entity-name.localized-charging-pole-3'}, - enabled = false, - ingredients = { - {"advanced-circuit", 10}, - {"electronic-circuit", 30}, - {"iron-plate", 20}, - {"steel-plate", 5}, - {"battery", 10}, - {"localized-charging-pole-2", 1}, - }, - result = "localized-charging-pole-3", - }, - - { - type = "recipe", - name = "localized-charging-pole-4", - localised_name = {'entity-name.localized-charging-pole-4'}, - enabled = false, - ingredients = { - {"advanced-circuit", 15}, - {"electronic-circuit", 35}, - {"iron-plate", 30}, - {"steel-plate", 5}, - {"battery", 20}, - {"localized-charging-pole-3", 1}, - }, - result = "localized-charging-pole-4", - }, - { - type = "recipe", - name = "electric-locomotive", - localised_name = {'vehicles.electric-locomotive'}, - enabled = false, - ingredients = { - {"electric-engine-unit", 50}, - {"electronic-circuit", 50}, - {"steel-plate", 75}, - {"effectivity-module", 5}, - }, - result = "electric-locomotive" - }, -}) +data:extend({ + { + type = "recipe", + name = "localized-charging-pole-1", + localised_name = {'entity-name.localized-charging-pole-1'}, + enabled = false, + ingredients = { + {"advanced-circuit", 20}, + {"electronic-circuit", 40}, + {"iron-plate", 90}, + {"steel-plate", 15}, + {"wood", 5}, + {"battery", 15}, + }, + result = "localized-charging-pole-1", + }, + + { + type = "recipe", + name = "localized-charging-pole-2", + localised_name = {'entity-name.localized-charging-pole-2'}, + enabled = false, + ingredients = { + {"advanced-circuit", 5}, + {"electronic-circuit", 20}, + {"iron-plate", 10}, + {"steel-plate", 5}, + {"battery", 5}, + {"localized-charging-pole-1", 1}, + }, + result = "localized-charging-pole-2", + }, + + { + type = "recipe", + name = "localized-charging-pole-3", + localised_name = {'entity-name.localized-charging-pole-3'}, + enabled = false, + ingredients = { + {"advanced-circuit", 10}, + {"electronic-circuit", 30}, + {"iron-plate", 20}, + {"steel-plate", 5}, + {"battery", 10}, + {"localized-charging-pole-2", 1}, + }, + result = "localized-charging-pole-3", + }, + + { + type = "recipe", + name = "localized-charging-pole-4", + localised_name = {'entity-name.localized-charging-pole-4'}, + enabled = false, + ingredients = { + {"advanced-circuit", 15}, + {"electronic-circuit", 35}, + {"iron-plate", 30}, + {"steel-plate", 5}, + {"battery", 20}, + {"localized-charging-pole-3", 1}, + }, + result = "localized-charging-pole-4", + }, + { + type = "recipe", + name = "electric-locomotive", + localised_name = {'vehicles.electric-locomotive'}, + enabled = false, + ingredients = { + {"electric-engine-unit", 50}, + {"electronic-circuit", 50}, + {"steel-plate", 75}, + {"effectivity-module", 5}, + }, + result = "electric-locomotive" + }, +}) diff --git a/Localized_Charging_1.0.0/prototypes/technologies.lua b/Localized_Charging_1.1.0/prototypes/technologies.lua similarity index 95% rename from Localized_Charging_1.0.0/prototypes/technologies.lua rename to Localized_Charging_1.1.0/prototypes/technologies.lua index 0b909dc..4de519e 100644 --- a/Localized_Charging_1.0.0/prototypes/technologies.lua +++ b/Localized_Charging_1.1.0/prototypes/technologies.lua @@ -1,59 +1,59 @@ -data:extend({ - { - type = "technology", - name = "voltage-electric-trains", - icon = "__Localized_Charging__/graphics/technology/electric-trains.png", - icon_size = 128, - effects = { - { - type = "unlock-recipe", - recipe = "electric-locomotive", - }, - }, - prerequisites = {"railway", "effectivity-module"}, - unit = { - count = 200, - ingredients = { - {"science-pack-1", 1}, - {"science-pack-2", 1}, - {"science-pack-3", 1}, - }, - time = 45, - }, - order = "c-g-d", - }, - { - type = "technology", - name = "voltage-wireless-energy-distribution", - icon = "__base__/graphics/technology/electric-energy-distribution.png", - effects = { - { - type = "unlock-recipe", - recipe = "localized-charging-pole-1", - }, - { - type = "unlock-recipe", - recipe = "localized-charging-pole-2", - }, - { - type = "unlock-recipe", - recipe = "localized-charging-pole-3", - }, - { - type = "unlock-recipe", - recipe = "localized-charging-pole-4", - }, - }, - prerequisites = {"electric-energy-distribution-2"}, - unit = { - count = 200, - ingredients = { - {"science-pack-1", 1}, - {"science-pack-2", 1}, - {"science-pack-3", 1} - }, - time = 45 - }, - order = "c-e-c", - }, -}) +data:extend({ + { + type = "technology", + name = "voltage-electric-trains", + icon = "__Localized_Charging__/graphics/technology/electric-trains.png", + icon_size = 128, + effects = { + { + type = "unlock-recipe", + recipe = "electric-locomotive", + }, + }, + prerequisites = {"railway", "effectivity-module"}, + unit = { + count = 200, + ingredients = { + {"science-pack-1", 1}, + {"science-pack-2", 1}, + {"science-pack-3", 1}, + }, + time = 45, + }, + order = "c-g-d", + }, + { + type = "technology", + name = "voltage-wireless-energy-distribution", + icon = "__base__/graphics/technology/electric-energy-distribution.png", + effects = { + { + type = "unlock-recipe", + recipe = "localized-charging-pole-1", + }, + { + type = "unlock-recipe", + recipe = "localized-charging-pole-2", + }, + { + type = "unlock-recipe", + recipe = "localized-charging-pole-3", + }, + { + type = "unlock-recipe", + recipe = "localized-charging-pole-4", + }, + }, + prerequisites = {"electric-energy-distribution-2"}, + unit = { + count = 200, + ingredients = { + {"science-pack-1", 1}, + {"science-pack-2", 1}, + {"science-pack-3", 1} + }, + time = 45 + }, + order = "c-e-c", + }, +}) diff --git a/Localized_Charging_1.0.0/prototypes/vehicles.lua b/Localized_Charging_1.1.0/prototypes/vehicles.lua similarity index 95% rename from Localized_Charging_1.0.0/prototypes/vehicles.lua rename to Localized_Charging_1.1.0/prototypes/vehicles.lua index 36f3303..811ddb7 100644 --- a/Localized_Charging_1.0.0/prototypes/vehicles.lua +++ b/Localized_Charging_1.1.0/prototypes/vehicles.lua @@ -1,58 +1,58 @@ -require('volt_util') - - -data:extend({ - { - type = "equipment-grid", - name = "voltage-electric-locomotive", - width = 10, - height = 10, - equipment_categories = {"armor"}, - }, - clone_existing_data(data.raw.locomotive['locomotive'], { - name='electric-locomotive', - localised_name={'vehicles.electric-locomotive'}, - icon = "__Localized_Charging__/graphics/icons/electric-locomotive.png", - minable = {mining_time = 1, result = "electric-locomotive"}, - weight = 1750, - max_speed = 1.5, - max_power = "2MW", - reversing_power_modifier = 1.0, - braking_force = 30, - order="electric-locomotive", - equipment_grid = "voltage-electric-locomotive", - equipment_categories = {"armor"}, - energy_source = - { - type = "burner", - effectivity = 1, - fuel_inventory_size = 0, - }, - front_light = { - __partial__ = true, - { - picture = - { - scale = 4.5, - }, - size = 4.5, - intensity = 0.75 - }, - { - picture = - { - scale = 4.5, - }, - size = 4.5, - intensity = 0.75 - } - }, - working_sound = { - sound = { - filename = "__base__/sound/electric-furnace.ogg", - volume = 0.4, - }, - match_speed_to_activity = true, - }, - }), +require('volt_util') + + +data:extend({ + { + type = "equipment-grid", + name = "voltage-electric-locomotive", + width = 10, + height = 10, + equipment_categories = {"armor"}, + }, + clone_existing_data(data.raw.locomotive['locomotive'], { + name='electric-locomotive', + localised_name={'vehicles.electric-locomotive'}, + icon = "__Localized_Charging__/graphics/icons/electric-locomotive.png", + minable = {mining_time = 1, result = "electric-locomotive"}, + weight = 1750, + max_speed = 1.5, + max_power = "2MW", + reversing_power_modifier = 1.0, + braking_force = 30, + order="electric-locomotive", + equipment_grid = "voltage-electric-locomotive", + equipment_categories = {"armor"}, + energy_source = + { + type = "burner", + effectivity = 1, + fuel_inventory_size = 0, + }, + front_light = { + __partial__ = true, + { + picture = + { + scale = 4.5, + }, + size = 4.5, + intensity = 0.75 + }, + { + picture = + { + scale = 4.5, + }, + size = 4.5, + intensity = 0.75 + } + }, + working_sound = { + sound = { + filename = "__base__/sound/electric-furnace.ogg", + volume = 0.4, + }, + match_speed_to_activity = true, + }, + }), }) \ No newline at end of file diff --git a/Localized_Charging_1.0.0/volt_util.lua b/Localized_Charging_1.1.0/volt_util.lua similarity index 96% rename from Localized_Charging_1.0.0/volt_util.lua rename to Localized_Charging_1.1.0/volt_util.lua index 14f1f6b..ab28f0a 100644 --- a/Localized_Charging_1.0.0/volt_util.lua +++ b/Localized_Charging_1.1.0/volt_util.lua @@ -1,43 +1,43 @@ -require('util') - -function ms_to_ticks(ms) - return math.ceil(ms / (1000 / 60)) -end - -local function _clone_onto(source, override, partial) - local partial = partial or false - - if(override['__partial__'] ~= nil) then - partial = true - override['__partial__'] = nil - else - return override - end - - -- TODO: handle numeric-only arrays specially here (merge properly if partial) - - for k,v in pairs(override) do - if(source[k] ~= nil and type(source[k]) == 'table') then - source[k] = _clone_onto(source[k], v, true) - else - -- __partial__ will leak for tables here, but who cares? - source[k] = v - end - end - - return source -end - --- each key will fully replace that key unless __partial__ is in the table, in which case --- it will be merged with any keys from this table replacing keys in the source table --- partial true/false is recursive after each occurence -function clone_existing_data(entry, data) - if(entry == nil) then - error('Tried to clone non-existant data key') - end - - local new = table.deepcopy(entry) - data['__partial__'] = true - - return _clone_onto(new, data) +require('util') + +function ms_to_ticks(ms) + return math.ceil(ms / (1000 / 60)) +end + +local function _clone_onto(source, override, partial) + local partial = partial or false + + if(override['__partial__'] ~= nil) then + partial = true + override['__partial__'] = nil + else + return override + end + + -- TODO: handle numeric-only arrays specially here (merge properly if partial) + + for k,v in pairs(override) do + if(source[k] ~= nil and type(source[k]) == 'table') then + source[k] = _clone_onto(source[k], v, true) + else + -- __partial__ will leak for tables here, but who cares? + source[k] = v + end + end + + return source +end + +-- each key will fully replace that key unless __partial__ is in the table, in which case +-- it will be merged with any keys from this table replacing keys in the source table +-- partial true/false is recursive after each occurence +function clone_existing_data(entry, data) + if(entry == nil) then + error('Tried to clone non-existant data key') + end + + local new = table.deepcopy(entry) + data['__partial__'] = true + + return _clone_onto(new, data) end \ No newline at end of file