Help: Activating burner leech via research
Help: Activating burner leech via research
I'm working on a set of scenarios and would like to enable the burner leech [mod] functionality during the playthrough with a research (to make players aware of it in an organic way). How would I go about disabling it when loaded and activating it after a certain research?
Re: Help: Activating burner leech via research
Technology: Recipe unlock: leech inserter.
Re: Help: Activating burner leech via research
It's that easy? Thank you!
- BlueTemplar
- Smart Inserter
- Posts: 3031
- Joined: Fri Jun 08, 2018 2:16 pm
- Contact:
Re: Help: Activating burner leech via research
It isn't, because it's not a new dedicated inserter, but instead new functionality for burner inserters ?
BobDiggity (mod-scenario-pack)
Re: Help: Activating burner leech via research
Yes it's a new functionality for an existing entity. I haven't had a chance yet to test it.
Re: Help: Activating burner leech via research
I mean that you need to add new leech inserter on data stage and unlock it as the technology effect.
- AmatorPhasma
- Fast Inserter
- Posts: 126
- Joined: Sat Aug 05, 2017 8:20 pm
- Contact:
Re: Help: Activating burner leech via research
Its not that easy, you can't use the build-in function:
https://lua-api.factorio.com/latest/Lua ... rner_leech
it's read only and can only be set in the data stage.
And to todo it with a own script is not that easy, you can look into my script, this also clears the burnt-fuel-inventroy from machines.
"Disclaimer: this script is not the nicest code "
https://lua-api.factorio.com/latest/Lua ... rner_leech
it's read only and can only be set in the data stage.
And to todo it with a own script is not that easy, you can look into my script, this also clears the burnt-fuel-inventroy from machines.
"Disclaimer: this script is not the nicest code "
- BlueTemplar
- Smart Inserter
- Posts: 3031
- Joined: Fri Jun 08, 2018 2:16 pm
- Contact:
Re: Help: Activating burner leech via research
This would also work poorly with mods adding other burner inserters or those that convert electric inserter to burner ones ?
BobDiggity (mod-scenario-pack)
Re: Help: Activating burner leech via research
Change them as you want.BlueTemplar wrote: ↑Mon Jan 27, 2020 5:05 pmThis would also work poorly with mods adding other burner inserters or those that convert electric inserter to burner ones ?
Code: Select all
for inserter_name, inserter_prototype in pairs (data.raw.inserter) do
-- do what you want, for example
inserter_prototype.allow_burner_leech = true
end
Re: Help: Activating burner leech via research
Thank you so much darkfrei! I'm still in the process to getting accustomed to LUA and factorio modding and this has been most helpful. I really want a campaign so I'll have to learn a lot lovely to have such a helpful community around!
Cheers guys
Cheers guys
Re: Help: Activating burner leech via research
You can write a control script that does a lot of things when the tech is researched. I don't know how to convert entities doing stuff, but you could create a duplicate inserter in the data phase. When the research finishes, convert all the specific inserters on all surfaces, and then enable a conversion when a player or robot builds it. Not sure how it works with blueprints, but the mining result of the new inserter can be the old one, since it is on building it is changed.
I have mods! I guess!
Link
Link
- BlueTemplar
- Smart Inserter
- Posts: 3031
- Joined: Fri Jun 08, 2018 2:16 pm
- Contact:
Re: Help: Activating burner leech via research
AFAIK, both Burner Leech and InserterFuelLeech do quite a bit more than just inserter_prototype.allow_burner_leech ? Could not it get complicated, fast ?darkfrei wrote: ↑Mon Jan 27, 2020 7:01 pmChange them as you want.BlueTemplar wrote: ↑Mon Jan 27, 2020 5:05 pmThis would also work poorly with mods adding other burner inserters or those that convert electric inserter to burner ones ?
Another solution: enable them if they are fuel leeches. Look through all inserter and this list can be used by technology effects.Code: Select all
for inserter_name, inserter_prototype in pairs (data.raw.inserter) do -- do what you want, for example inserter_prototype.allow_burner_leech = true end
BobDiggity (mod-scenario-pack)
Re: Help: Activating burner leech via research
The Inserter Fuel Leech is the fork of Klonan's mod, all stuff is done via the script.BlueTemplar wrote: ↑Tue Jan 28, 2020 12:06 am AFAIK, both Burner Leech and InserterFuelLeech do quite a bit more than just inserter_prototype.allow_burner_leech ? Could not it get complicated, fast ?
The Burner Leech has both parts, but my opinion is, that the C++ side (vanilla Factorio engine) is enough. I haven't tested it before.
So it must be enough to set inserter_prototype.allow_burner_leech = true in data stage and it works as expected.
- BlueTemplar
- Smart Inserter
- Posts: 3031
- Joined: Fri Jun 08, 2018 2:16 pm
- Contact:
Re: Help: Activating burner leech via research
Zaflis wrote:But it will only ever pull fuel from the input side of inserter. If it puts in an assembler that already has coal in, it can't take it out.kingarthur wrote:all the leech function does is allow a burner inserter to take fuel out of a assembler/furnace to feed its self if its set to pull items out from that entity
BobDiggity (mod-scenario-pack)
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Help: Activating burner leech via research
Summary:
1) data-final-fixes method:
Make a copy of every fucking inserter. In on_research_finished replace every fucking normal inserter in the entire world with it's leech-enabled version. Edit: Oh, and replace all assembler recipes and all inserter items in the world, or try and fail to monitor every fucking on_built event.
Benefit: No on_tick UPS cost,relatively low moderate maintenance cost.
Drawback: Huge UPS spike when replacing (not as bad if the scenario only allows small factories), can't be done in pure control.lua.
2) scripted leech method:
Hope that none of the inserters have have leech enabled in the prototype. Dis/Enable the script as you like.
Benefit: Allows clean dis/enabled in pure control.lua.
Drawback: Scripts have a continous UPS cost and are more prone to bugs. If the licenses allows to steal someone elses code it might not be too bad. And if the scenario implies that burners are not used in huge quantities (early-game-only) the UPS cost might be negligible.
3) fake method:
Add a technology with an empty effect that describes the leech-effect but doesn't actually change anything. This would make the player *aware* of the leech feature.
Benefit: Trivial to implement and maintain.
Drawback: Players can use leech without the technology if they know how to do it.
1) data-final-fixes method:
Make a copy of every fucking inserter. In on_research_finished replace every fucking normal inserter in the entire world with it's leech-enabled version. Edit: Oh, and replace all assembler recipes and all inserter items in the world, or try and fail to monitor every fucking on_built event.
Benefit: No on_tick UPS cost,
Drawback: Huge UPS spike when replacing (not as bad if the scenario only allows small factories), can't be done in pure control.lua.
2) scripted leech method:
Hope that none of the inserters have have leech enabled in the prototype. Dis/Enable the script as you like.
Benefit: Allows clean dis/enabled in pure control.lua.
Drawback: Scripts have a continous UPS cost and are more prone to bugs. If the licenses allows to steal someone elses code it might not be too bad. And if the scenario implies that burners are not used in huge quantities (early-game-only) the UPS cost might be negligible.
3) fake method:
Add a technology with an empty effect that describes the leech-effect but doesn't actually change anything. This would make the player *aware* of the leech feature.
Benefit: Trivial to implement and maintain.
Drawback: Players can use leech without the technology if they know how to do it.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Help: Activating burner leech via research
1) The entity replacements can be spread out. Find all inserters on the surfaces, divide by s seconds * 60 ticks, and only replace n inserters per tick. Benefit: to find the number of replaceable inserters, you also have the entity table, and only need to find_entities_filtered on the first tick. If there's more than one kind of inserter, you can spread out that, too. You don't have to replace the recipes nor items, because inserters can be changed on placement/mining (the mining result is static in prototypes, on placement would be control events), they do not need to be changed in inventory(s). Only drawback I see is blueprinting.eradicator wrote: ↑Tue Jan 28, 2020 1:16 pm Summary:
1) data-final-fixes method:
Make a copy of every fucking inserter. In on_research_finished replace every fucking normal inserter in the entire world with it's leech-enabled version. Edit: Oh, and replace all assembler recipes and all inserter items in the world, or try and fail to monitor every fucking on_built event.
Benefit: No on_tick UPS cost,relatively lowmoderate maintenance cost.
Drawback: Huge UPS spike when replacing (not as bad if the scenario only allows small factories), can't be done in pure control.lua.
2) scripted leech method:
Hope that none of the inserters have have leech enabled in the prototype. Dis/Enable the script as you like.
Benefit: Allows clean dis/enabled in pure control.lua.
Drawback: Scripts have a continous UPS cost and are more prone to bugs. If the licenses allows to steal someone elses code it might not be too bad. And if the scenario implies that burners are not used in huge quantities (early-game-only) the UPS cost might be negligible.
3) fake method:
Add a technology with an empty effect that describes the leech-effect but doesn't actually change anything. This would make the player *aware* of the leech feature.
Benefit: Trivial to implement and maintain.
Drawback: Players can use leech without the technology if they know how to do it.
2) Haha no. That would be such a massive UPS overhead.
3) I'm trying to think of a better way to restrict an inserter but I can't think of any.
I have mods! I guess!
Link
Link
Re: Help: Activating burner leech via research
4) partially [1], but the technology unlocks the recipe to convert normal inserters into leeches.
Re: Help: Activating burner leech via research
That's... not a bad idea. The recipe could take .5 seconds and cost nothing, and would be available via upgrade planner and completely bypass blueprinting issues.
I have mods! I guess!
Link
Link
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Help: Activating burner leech via research
Congratualtions. 1 was the ugliest option for the programmer. You managed to make it the ugliest option for the player instead :twisted: .
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Help: Activating burner leech via research
The code wasn't tested, but must be clear. We made the technology and then going through all inserters. If the inserter is not leech, then we made new leech inserter, new recipe to convert old inserter into the new one, then adding this recipe to the technology effects.
Code: Select all
local prototypes = {}
local new_technology = {
type = "technology",
name = "leech-inserters",
icon_size = 128,
icon = "__new_mod_name__/graphics/technology/leech-inserters.png", -- picture 128x128
enabled = false,
effects = {},
unit.count = 8,
unit.ingredients = {{"automation-science-pack", 1}},
unit.time = 1,
order = "li-a",
}
for inserter_name, inserter_prototype in pairs (data.raw.inserter) do
if not (inserter_prototype.allow_burner_leech) then
--create new prototype!
local new_inserter_prototype = table.deepcopy (inserter_prototype)
local new_inserter_name = 'leech-' .. inserter_name
new_inserter_prototype.name = new_inserter_name
new_inserter_prototype.minable = {mining_time = 0.1, result = new_inserter_name}
new_inserter_prototype.allow_burner_leech = true
table.insert (prototypes, new_inserter_prototype)
-- recipe for it
local new_recipe = {
type = 'recipe',
name = new_inserter_name,
ingredients = {{inserter_name, 1}},
result = new_inserter_name
}
table.insert (prototypes, new_recipe)
-- add them to the technology effect
table.insert(new_technology.effects, {type = "unlock-recipe", recipe = new_inserter_name})
end
end
if #prototypes > 1 then -- vanilla cannot be extended with empty table; you don't need the technology without effects
table.insert (prototypes, new_technology)
data:extend (prototypes)
end