I have now twice attempted to create a mod, only to be stymied in the same way and I was wondering if there's any sane way of dealing with it. The problem is this- I wish for more flexible prototypes.
In one case, I wanted to create a "foot powered equipment generator" aka "reverse-exoskeleton", that slows your gait but charges your pack. I would have expected to achieve this by combining the "movement-bonus-equipment" prototype with the "generator-equipment" prototype. Lua allows multiple inheritance but Factorio does not, so that idea is off the table.
In the 2nd case, I wished to create a powered offshore Pump. Of course, this is not possible given the prototype definition- it has no "EnergySource" field. Again, I have to abandon the idea.
Given the API, the only way I can see to solve these problems is by lobbying the devs to create new prototypes- a "movement-bonus-generator-equipment" prototype and a "offshore-pump-with-energy-source"- but that seems highly unlikely and pretty much a bad idea. I'm not a Lua expect and I don't know anything about the base code, but I thought I would ask before I give up on the idea forever. What can be done when the prototypes don't meet our needs? Can we lobby the devs for adding specific prototypes or is that entirely not kosher? And if multiple inheritance is not currently possible, perhaps someday it could be?
More flexible Prototypes
- adamwong246
- Fast Inserter
- Posts: 148
- Joined: Tue Dec 01, 2020 5:01 am
- Contact:
Re: More flexible Prototypes
The developer response has been "adding more fields would make the base game too inefficient".
For powered offshore pump, there is a creative solution. Assembling-machine does everything you want except for filtering coastline. So make the base entitiy an offshore-pump, then use control.lua to swap in an assembling-machine after it is built.
For powered offshore pump, there is a creative solution. Assembling-machine does everything you want except for filtering coastline. So make the base entitiy an offshore-pump, then use control.lua to swap in an assembling-machine after it is built.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: More flexible Prototypes
Congratulations, you discovered the reason why 99% of all mods are "more machines" or "more recipes".
Changes that reduce vanilla performace will never happen.adamwong246 wrote: ↑Thu Jan 28, 2021 4:11 amAnd if multiple inheritance is not currently possible, perhaps someday it could be?
You create control.lua abominations that swap out entities at runtime and drive you more insane with every futile attempt you make at hiding it all from the user.adamwong246 wrote: ↑Thu Jan 28, 2021 4:11 amWhat can be done when the prototypes don't meet our needs?
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.
- adamwong246
- Fast Inserter
- Posts: 148
- Joined: Tue Dec 01, 2020 5:01 am
- Contact:
Re: More flexible Prototypes
I pretty much expected that answer and yeah, I'm kind of bummed. I'm sure all these concerns have technical considerations tho.
- adamwong246
- Fast Inserter
- Posts: 148
- Joined: Tue Dec 01, 2020 5:01 am
- Contact:
Re: More flexible Prototypes
An idea did occur to me- Perhaps the devs could make some multi-use prototypes, unused by vanilla, to serve as hooks for mods. Perhaps a "multi-equipment" prototype that theoretically supports ALL equipment prototypes, to be used under the caveat that it's not great for performance.
It's just an idea, I really don't know what's possible.
It's just an idea, I really don't know what's possible.
Re: More flexible Prototypes
I am creating a custom belt mod at the moment and my solution was to create an energy-interface for the placed blts and "connect" them with control. If the energy isn't high enough ore the player changes the Speed, the belt is replaces with a new, faster ore slower prototype. So there are work arounds, but the control.lua of course impacts the performance.
There I do only the necessary stuff.
For your first mod my naive Idea would be, that you create the foot powered equipment generator and a battery, it will load. Then you could get the player walking speed and change the battery state depending on the speed, but you probably have to consider belts and vehicles.
Ore maybe you could create an Exoskelett with negative energy values, but I don't know if this works.
That's just a bunch of Ideas, of course but I try, to find a new way if my initial plan doesn't work.
There I do only the necessary stuff.
For your first mod my naive Idea would be, that you create the foot powered equipment generator and a battery, it will load. Then you could get the player walking speed and change the battery state depending on the speed, but you probably have to consider belts and vehicles.
Ore maybe you could create an Exoskelett with negative energy values, but I don't know if this works.
That's just a bunch of Ideas, of course but I try, to find a new way if my initial plan doesn't work.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: More flexible Prototypes
Electric energy source does not support negative consumption as far as i know. Not sure if exo supports negative movement speed bonus. In any case you'd end up with on_tick to measure the walking speed. And if neg mov bonus is supported you'd be constantly swapping between -0% and -X% exos depending on if the battery is full or not. (And if the player inserts a normal exo you'd probably be swapping once per tick :P)
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.