Page 1 of 1

charging_offsets ["solved"]

Posted: Fri May 14, 2021 2:56 pm
by boeljoet
as my first mod, I thought about doing something easy.
copy a roboport, disable the inventory and double the number of recharge stations.

I got everything working except the charging_offsets.
for some reason, they all just charge at the center.

this is the code I use:

Code: Select all

local oldTechnology = table.deepcopy(data.raw["technology"]["construction-robotics"])
local oldRecipy = table.deepcopy(data.raw["recipe"]["roboport"])
local oldEntity = table.deepcopy(data.raw["roboport"]["roboport"])
local oldItem = table.deepcopy(data.raw["item"]["roboport"])

--Backpack
local newItem = oldItem
newItem.name = "rechargeport"
newItem.icons = {
	{
		icon = newItem.icon,
		tint = {r=1,g=0,b=0}
	},
}
newItem.place_result = "rechargeport"

--technology
local newTechnology = oldTechnology

newTechnology.name = "rechargeport"
newTechnology.effects = {
	{
		type = "unlock-recipe",
		recipe = "rechargeport"
	}
}
newTechnology.prerequisites = {"construction-robotics","logistic-robotics"}
newTechnology.unit = {
	count = 50,
	ingredients = {
		{"automation-science-pack", 1},
		{"logistic-science-pack", 1}
	},
	time = 30
}

--Entity
local newEntity = oldEntity
newEntity.name = "rechargeport"
newEntity.energy_source ={
		type = "electric",
		usage_priority = "secondary-input",
		input_flow_limit = "9MW",
		buffer_capacity = "160MJ"
	}
newEntity.energy_usage = "10kW"
newEntity.robot_slots_count = 0
newEntity.material_slots_count = 0
newEntity.charging_station_count = 8
newEntity.charging_offsets = {{-1.5, -0.5}, {1.5, -0.5}, {1.5, 1.5}, {-1.5, 1.5}, {1.5, .5}, {-1.5, .5}, {0, 1.5}, {0, -1},}

--Recipy
local newRecipy = oldRecipy
newRecipy.enabled = false
newRecipy.name = newItem.name
newRecipy.ingredients = {{"steel-plate",30},{"advanced-circuit",30},{"copper-cable",30}}
newRecipy.results = {
	{type = "item", name = newItem.name, amount = 1},
}

data:extend{newItem,newEntity,newRecipy,newTechnology}
try it here https://mods.factorio.com/mod/RechargePort

Re: charging_offsets

Posted: Fri May 14, 2021 5:12 pm
by DaveMcW
If you set charging_station_count, it disables charging_offsets and uses charging_distance instead.

Re: charging_offsets

Posted: Fri May 14, 2021 5:55 pm
by boeljoet
DaveMcW wrote:
Fri May 14, 2021 5:12 pm
If you set charging_station_count, it disables charging_offsets and uses charging_distance instead.
this solved it.
not sure how to mark it as solved,
this drove me crazy, tysm ^^

Re: charging_offsets

Posted: Fri May 14, 2021 11:04 pm
by eradicator
boeljoet wrote:
Fri May 14, 2021 5:55 pm
not sure how to mark it as solved,
Press "edit" on the first post and add "[Solved]" to the subject. Most people don't bother though...