-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
521 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require("src.main") | ||
require("remote") | ||
|
||
local function on_init() | ||
-- Working set | ||
|
||
-- List of all known vehicles with an equipment grid | ||
-- [unit-number] = entity | ||
global.vehicles = { } | ||
-- List of all trains currently slowing down. Used for regenerative braking. | ||
-- [*] = braking data | ||
global.braking_trains = { } | ||
-- Dictinary of all non-train vehicles currently slowing down. Used for regenerative braking. | ||
-- [unit-number] = braking data | ||
global.braking_vehicles = { } | ||
|
||
-- Passive prototype data | ||
|
||
-- Dictionary of recognized transformer equipment | ||
global.transformers = { } | ||
-- Dictionary of recognized regenerating brakes equipment | ||
-- [name] = efficiency | ||
global.brakes = { } | ||
end | ||
|
||
local function on_load() | ||
rebuild_caches() | ||
end | ||
|
||
local function on_configuration_changed(data) | ||
validate_prototypes() | ||
validate_entities() | ||
end | ||
|
||
script.on_init(on_init) | ||
script.on_load(on_load) | ||
script.on_configuration_changed(on_configuration_changed) | ||
|
||
script.on_event(defines.events.on_built_entity, on_built_entity) | ||
script.on_event(defines.events.on_entity_died, on_entity_died) | ||
script.on_event(defines.events.on_player_placed_equipment, on_player_placed_equipment) | ||
script.on_event(defines.events.on_player_removed_equipment, on_player_removed_equipment) | ||
script.on_event(defines.events.on_pre_player_mined_item, on_pre_player_mined_item) | ||
script.on_event(defines.events.on_robot_pre_mined, on_robot_pre_mined) | ||
script.on_event(defines.events.on_tick, on_tick) | ||
script.on_event(defines.events.on_train_changed_state, on_train_changed_state) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "electric-vehicles-lib-reborn", | ||
"version": "0.0.1", | ||
"title": "Electric Vehicles Lib: Reborn", | ||
"author": ".-PiteR-.", | ||
"homepage": "https://github.com/March3wQa/Electric-Vehicles-Lib-Reborn", | ||
"description": "Contains all the support code that allows for electric vehicles and their recharging. Powers the the Electric Vehicles: Reborn mod. Based on mknejp's Electric Vehicles mod", | ||
"factorio_version": "0.16", | ||
"dependencies": ["base >= 0.16.51"], | ||
"license": "MIT" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
events = | ||
{ | ||
-- Called when charging of an entity begins. | ||
-- entity: the entity that is now charging | ||
-- charging_entityes: array of player-placed entities associated with charging process. | ||
on_charging_started = script.generate_event_name(), | ||
-- Called when an entity is no longer being charged because it moved out of range, something was destroyed, etc. | ||
-- entity: the affected entity | ||
-- charging_entityes: array of player-placed entities that were associated with the charging process. | ||
on_charging_stopped = script.generate_event_name(), | ||
} | ||
|
||
remote.add_interface("electric-vehicles-lib", { | ||
--- Register a new equipment type to be recognized as transformer. It should be a "battery-equipment" type and have its "usage_priority" set to "primary-input". | ||
-- @param data A table containing these values: | ||
-- name: the name of the equipment prototype | ||
["register-transformer"] = register_transformer, | ||
--- Register a new equipment type to be recognized as regenerative brake. It should be a "battery-equipment" type and have its "usage_priority" set to "primary-output". | ||
-- @param data A table containing these values: | ||
-- name: the name of the equipment prototype | ||
-- efficiency: the efficiency of energy recovery in range [0,1] | ||
["register-brake"] = register_brake, | ||
}) |
Oops, something went wrong.