[0.17] [WIP Mod for modders] Composite combinators
Posted: Tue Nov 19, 2019 10:44 pm
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. --
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.2 Create your setup --
2.1.3 Connect imaginary input and output --
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. --
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.
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à
--
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 .
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. --
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.2 Create your setup --
2.1.3 Connect imaginary input and output --
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. --
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 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à
--
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 .