Skip to content

Commit

Permalink
Successful load of the game
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelta0 committed Dec 22, 2018
1 parent 39bea09 commit 041b733
Show file tree
Hide file tree
Showing 4 changed files with 521 additions and 0 deletions.
46 changes: 46 additions & 0 deletions control.lua
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)
12 changes: 12 additions & 0 deletions info.json
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"
}

23 changes: 23 additions & 0 deletions remote.lua
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,
})
Loading

0 comments on commit 041b733

Please sign in to comment.