Modular machines

Place to get help with not working mods / modding interface.
User avatar
FuzzCat927
Inserter
Inserter
Posts: 23
Joined: Sat Apr 08, 2017 3:04 pm
Contact:

Modular machines

Post by FuzzCat927 »

I'm wanting to make a mod that adds modular machines that function similar to multi-block structures in minecraft mods-- eg Colossal Chests or Blood Magic mods.
My goal is to replace every machine, furnace, assembler, etc (except for maybe belts) with multi-entity structures.
These structures would have different entities that modify the behavior of the multi-entity structure based on the entities used. Blood Magic's altars could be an example.
Every structure would have a corepiece, say furnaces use a "furnace corepiece", and then would contain 'structural pieces' in a square or rectangular shape (corepiece cannot be on the perimeter of this shape). Other shapes would fail to form a machine and would therefore not perform the desired action. (This probably means that every time a piece involved in any modular machine was mined or places, it would run a function)

If you don't want to go look up blood magic mod, I'll try another example

Say you have machine X using corepiece A, structure piece B, speed-increasing structure piece C, and productivity piece E (N for nothing),
perhaps 10% speed increase (doesn't stack, so 2 pieces would give 20% bonus, not 10% * 10% bonus, which would yield a 21% bonus.) per C, and 1% productivity increase per D (again, doesn't stack)

following 1 letter = 1 grid tile as a guideline

BBB
BAB -- this would be the most basic machine of corepiece type A, say with a crafting speed of 1.
BBB

BCB
CAC -- this would be the same as above, but with a 1.4 crafting speed.
BCB

BBBB
BABB -- would somehow be different than the first example, don't know yet. perhaps the perimeter of the machine affects stats?
BBBB

EEE
EAE -- would be the same as the first example, but with a 8% productivity bonus.
EEE

Problem is, I don't know how to do this because I'm still fairly new to modding. Help would be greatly appreciated, or if you feel up to it, make it yourself, assuming I get credit for the ideas.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Modular machines

Post by darkfrei »

This core is beacon.
User avatar
FuzzCat927
Inserter
Inserter
Posts: 23
Joined: Sat Apr 08, 2017 3:04 pm
Contact:

Re: Modular machines

Post by FuzzCat927 »

darkfrei wrote:This core is beacon.
Don't think you understood what I'm aiming for with this. Beacons are totally different than what I just described.
Pandemoneus
Fast Inserter
Fast Inserter
Posts: 127
Joined: Fri May 08, 2015 2:25 pm
Contact:

Re: Modular machines

Post by Pandemoneus »

There are basically two parts, one is, I'd say of medium difficulty, and the other is very hard.

First (medium): Detecting whether certain entities are next to each other in a certain configuration and then replacing them by a "completed structure" entity is not hard.

Second(the hard part): The problem now is if your structure can get boni depending on which entites are used. You cannot dynamically modify the crafting speed or productivity of a machine. What you would have to do is, for every possible configuration of entities (i.e. 2x speed, 1x productivity), you have to create an entity (in the data stage!) with the stats correctly summed/modified.

It's definately not impossible, but very advanced.

Similiar mods that might be worth looking at: Wear and Tear for how to dynamically create entity prototypes in the data stage.
My RSO+Bob's+Angel's modpack: Farlands (outdated)
Mods (current): Resource Labels
Mods (old): Biter Spires
User avatar
FuzzCat927
Inserter
Inserter
Posts: 23
Joined: Sat Apr 08, 2017 3:04 pm
Contact:

Re: Modular machines

Post by FuzzCat927 »

Pandemoneus wrote:There are basically two parts, one is, I'd say of medium difficulty, and the other is very hard.

First (medium): Detecting whether certain entities are next to each other in a certain configuration and then replacing them by a "completed structure" entity is not hard.

Second(the hard part): The problem now is if your structure can get boni depending on which entites are used. You cannot dynamically modify the crafting speed or productivity of a machine. What you would have to do is, for every possible configuration of entities (i.e. 2x speed, 1x productivity), you have to create an entity (in the data stage!) with the stats correctly summed/modified.

It's definately not impossible, but very advanced.

Similiar mods that might be worth looking at: Wear and Tear for how to dynamically create entity prototypes in the data stage.
Maybe I could have locked module slots with modules that would be changed depending on what bonuses it had?
Pandemoneus
Fast Inserter
Fast Inserter
Posts: 127
Joined: Fri May 08, 2015 2:25 pm
Contact:

Re: Modular machines

Post by Pandemoneus »

You can't lock module slots, and you can't detect whether a player picks up an item from a machine.
However, you can make the machine non-operable, but then the player can't access the GUI.
My RSO+Bob's+Angel's modpack: Farlands (outdated)
Mods (current): Resource Labels
Mods (old): Biter Spires
User avatar
FuzzCat927
Inserter
Inserter
Posts: 23
Joined: Sat Apr 08, 2017 3:04 pm
Contact:

Re: Modular machines

Post by FuzzCat927 »

Didn't think about not being able to detect when a player takes an item from an inventory.
Perhaps detecting any change in the player's inventory would run a function to "move it back", given that there's a module that shouldn't be in a player's inventory?
Pandemoneus
Fast Inserter
Fast Inserter
Posts: 127
Joined: Fri May 08, 2015 2:25 pm
Contact:

Re: Modular machines

Post by Pandemoneus »

How would you tell which machine he took it from though?
You could iterate over all of your machines and check whether the module slots have less modules inside now...
My RSO+Bob's+Angel's modpack: Farlands (outdated)
Mods (current): Resource Labels
Mods (old): Biter Spires
Post Reply

Return to “Modding help”