[0.17] [WIP Mod for modders] Composite combinators

Topics and discussion about specific mods
DRE
Inserter
Inserter
Posts: 41
Joined: Sun Jan 25, 2015 2:30 pm
Contact:

[0.17] [WIP Mod for modders] Composite combinators

Post by DRE »

This mod for mod creation is a framework for combinators that contain micro combinators inside - simplify advanced logic with more functional combinators.
viewtopic.php?f=190&t=77246 is WIP mod that is based on this one.

Have you ever been bothered by the fact that you cannot fit a bit more of a logic inside a combinator, flooding your combinator gaming board?
This fact annoyed me slightly to create this.

Github: https://github.com/m3fn/FactorioMods
Last release as of 20 Nov 2019 https://github.com/m3fn/FactorioMods/releases/tag/0.1.4
--------------------------------------------------------------------------------------------------

Assuming you have a bit of lua knowledge and factorio modding background.
Simple HOW TO:

1. Basics for simple arithmetic-combinator based combinator

Let's assume our combinator name is "euc-demo"

Copy entity, item and recipe from vanilla base mod or from Extremely useful composite combinators "euc-demo" https://github.com/m3fn/FactorioMods/tr ... ombinators to your own mod.
You can change entity name to your own, but keep entity type.

What we have at this point - is a combinator with our custom name that behaves 100% like vanilla arithmetic combinator.
1_1.png
1_1.png (150 KiB) Viewed 1896 times
--

2. Simple composite combinator

Let's assume we want to create composite combinator that multiplies everything by 2 on the red wire, multiplies everything by 4 on the green wire, and outputs anything if the result is more than 100.

2.1. Create combinator setup string

2.1.1 Load Composite combinators core mod with setting "Developer mode" = ON
2.1_1.png
2.1_1.png (20.44 KiB) Viewed 1896 times
--

2.1.2 Create your setup
2.1.2.png
2.1.2.png (495.2 KiB) Viewed 1896 times
--

2.1.3 Connect imaginary input and output
2.1.3.png
2.1.3.png (339.87 KiB) Viewed 1896 times
--

Use entity "Composite combinators IO marker" that looks like darker constant combinator to mark our new combinator inputs and outputs
1 and 2 correspond to defines.circuit_connector_id.combinator_input and defines.circuit_connector_id.combinator_output

2.1.4

Use green colored tool "Get composite combinator string from big (archetype) combinators", select our setup.
2.1.4.png
2.1.4.png (310.89 KiB) Viewed 1896 times
--

Save the string from the message box - this string will be used to spawn components of our new combinator.

NOTE: this tool and "Composite combinators IO marker" are only available in developer mode

2.2 Register combinator prototype

Time to write some code in control.lua, it should appear self explanatory for the most part.

Code: Select all

function OnInit()
	remote.call("Composite-Combinators-Core", "registerCompositeCombinatorPrototype", "euc-demo", 2, { x = 0, y = 0 }, "CompositeCombinatorsDemoMod", "demoEntity_")
end

script.on_init(OnInit)

-- callbacks from core
remote.add_interface("CompositeCombinatorsDemoMod", {

  demoEntity_GetBuildString = function(entity)
    if entity == nil then
      return nil
    end
    return "2#$item#composite-combinator-io-marker#arithmetic-combinator#decider-combinator#$1#2#1#0#0#0#1%1#3#45#2.5#1#2#virtual!signal-each!^!4!virtual!signal-each!1%1#3#45#2.5#0#2#virtual!signal-each!^!2!virtual!signal-each!1%1#4#51#4.5#1#2#virtual!signal-each!^!100!virtual!signal-each!65538%1#4#51#4.5#0#2#virtual!signal-each!^!100!virtual!signal-each!65538%1#2#1#0#0#0#2%$01#1#3#1#1#%00#1#2#1#1#%00#2#4#2#1#%01#3#5#2#1#%00#4#6#2#1#%01#5#6#2#1#%"
  end,

  demoEntity_SaveStateInfoToSlots = function(entity) 
    if entity == nil then
      return nil
    end
    return { }
  end,
  
  demoEntity_RestoreStateInfoFromSlots = function(entity, slots, nextSlot)
    if entity == nil then
      return
    end
  end
})
We registered our new entity to be managed by Composite combinators mod.
We also added some callbacks, demoEntity_GetBuildString returns string that we have just got from the green tool.
This is the simplest code for a composite combinator.

2.3 Voilà
3.png
3.png (775.62 KiB) Viewed 1896 times
--

Everything else is managed by core mod.

3. More advanced usage

To change combinator components layout during the game, change individual component's parameters, custom combinator GUIs - take a look at Extremely useful composite combinators mod. These except GUIs are managed by core mod. To understand core mod - take a look at entry.lua .
PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: [0.17] [WIP Mod for modders] Composite combinators

Post by PyroFire »

Why use UPS-intensive lua combinators when you can just use regular combinators?
Why muck about with blueprints and prototypes and guis and special configurations when there's a cleaner solution available?

https://mods.factorio.com/mod/circuitchips

Sorry that i just obsoleted your project.
DRE
Inserter
Inserter
Posts: 41
Joined: Sun Jan 25, 2015 2:30 pm
Contact:

Re: [0.17] [WIP Mod for modders] Composite combinators

Post by DRE »

Hi PyroFire,

It is nice to have something similar but different in mods list. Do you look to see your creation used in "Combinator Creations" forum section one day?

I could not load your mod to check it out, there is an error.

Your points are not quite valid:

- I do not use UPS-intensive lua combinators, there are some operations only when it is building;
- My mod is created for the diversity of logic components, so one has more than decider and arithmetic combinators in their arsenal. One semi-transparent blue combinator is definitely not that;
- I am yet to see how did you implement blueprinting, copying, undo, etc... I am creating this mod with the thought in mind that people should not be bothered to have some special approaches to all of that, so blueprinting is almost as smooth as vanilla. I would be surprised if your mod manages this well;
PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: [0.17] [WIP Mod for modders] Composite combinators

Post by PyroFire »

DRE wrote: Thu Nov 21, 2019 8:41 am Hi PyroFire,

It is nice to have something similar but different in mods list. Do you look to see your creation used in "Combinator Creations" forum section one day?

I could not load your mod to check it out, there is an error.
It was just an idea that i saw wasn't really fulfilled, so i whipped up the "factorissimo but instead of factory warehouse its circuit warehouses" mod idea that i've seen floating around because no one has actually done it yet, particularly when it comes to blueprint and copying.

Also;
Errors.
Give, please?
- I do not use UPS-intensive lua combinators, there are some operations only when it is building;
Interesting, i always thought deviation from standard behavior, particularly for combinators, needed tick math.
I'll have to have a closer look at your code some time.
- My mod is created for the diversity of logic components, so one has more than decider and arithmetic combinators in their arsenal. One semi-transparent blue combinator is definitely not that;
It is so much more than a simple semi-transparent blue combinator.
You can enter it by throwing a wrench-type capsule at it, and there is a configurable surface inside it.
It's the "factorissimo but instead of factory warehouse its circuit warehouses".

You can then place combinators and connect them the special combinators on the sides which represent all the connection points of the blue combinator.
They can be connected to, well, whatever you like!
You have 4 connection points to share signals into and out of the chip.
- I am yet to see how did you implement blueprinting, copying, undo, etc... I am creating this mod with the thought in mind that people should not be bothered to have some special approaches to all of that, so blueprinting is almost as smooth as vanilla. I would be surprised if your mod manages this well;
Yeah exactly.
This mod does that.

Copy+paste settings (shift + right/left click) is managed no problem.
If you change one circuit, you can paste it over any other.
This is particularly useful if you need to correct errors you've made in one of your chips.

Blueprinting however i'm still fiddling with.
It is functional, but still needs more work and polish to get to a truly stable point.
One problem for example is that copy+paste settings takes into account combinator costs, e.g. 1 for 1 for each combinator "inside" the chip, where blueprints just spawns them and gives you free combinators.
But the proof of the concept is definitely there.

Noting also my mod is just about as new as yours, only a few days old so work still to be done lol.
DRE
Inserter
Inserter
Posts: 41
Joined: Sun Jan 25, 2015 2:30 pm
Contact:

Re: [0.17] [WIP Mod for modders] Composite combinators

Post by DRE »

Hi PyroFire,

Version 0.0.4 was buggy, it is good now.

Your blueprinting is actually better, I did not know about the existence of of set_blueprint_entity_tag.
So I have done a whole layer of extra work messing with storing data in invisible constant combinators if there are no downsides :x
Post Reply

Return to “Mods”