Make recipe allowed producitivity Module

Place to get help with not working mods / modding interface.
omagaalpha
Inserter
Inserter
Posts: 23
Joined: Mon Apr 29, 2013 4:49 pm
Contact:

Make recipe allowed producitivity Module

Post by omagaalpha »

I want to try change recipe as to allow producitivity Module work but I can not not figure how one goes about it and I can't figure it out from looking at the files .
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Make recipe allowed producitivity Module

Post by FreeER »

If you open the data\base\prototypes\item\module.lua file you'll see on line 66 a function which returns a table of names (I'm not sure if they are item names or recipe names to be honest), which is used to provide a limitation table to the productivity modules. Since that is the case I would think that using something like the below (inside of a mod's data.lua that is loaded after the base game) would work

Code: Select all

for k, v in pairs(data.raw.module) do
  if v.name:find("productivity-module") then
    v.limitation = {} -- empty limitation table
  end
end
To change the beacon to allow productivity modules I think you'd need to use something like

Code: Select all

table.insert(data.raw.beacon["basic-beacon"].allowed_effects, "productivity")
since the beacons have a list of allowed_effects defined in their entity definition (data\base\prototypes\entity\entities.lua). Obviously you could use a for loop over the data.raw.beacon table instead (to change mod added beacons), I chose to just index the basic beacon since it's the only one in the base game :)
omagaalpha
Inserter
Inserter
Posts: 23
Joined: Mon Apr 29, 2013 4:49 pm
Contact:

Re: Make recipe allowed producitivity Module

Post by omagaalpha »

Nice know but does not help me since aim get recipe blast furnace(dytech) recipes to accept productivity module. Unfortunately find no hint purposely add some thing too prevent it from happening.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Make recipe allowed producitivity Module

Post by FreeER »

omagaalpha wrote:blast furnace recipes
ah, my apologies :) The blast furnace machine doesn't allow any module, to allow it to, use
data.raw["assembling-machine"]["blast-furnace"].module_slots = 2
data.raw["assembling-machine"]["blast-furnace"].allowed_effects = {"consumption", "speed", "productivity", "pollution"}
in general it's data.raw["machine-type"]["machine-name"].module_slots = number_of_slots and ...allowed_effects = {list_of_allowed_module_types} (though not all types allow modules, the assembling-machine obviously does :))
just make sure that in your mod's info.json you set the dependency to ["mod-name-you-are-changing-taken-from-their-info-file >= the-mod-version-from-info"] so a dependency for dytech-metallurgy would be "dependencies": ["base", "DyTech-Metallurgy >= 1.0.0"], you can leave off the >= version if you're lazy :) The dependency makes the mod you're modifying load first (so that the data is actually there for your mod to change)
omagaalpha
Inserter
Inserter
Posts: 23
Joined: Mon Apr 29, 2013 4:49 pm
Contact:

Re: Make recipe allowed producitivity Module

Post by omagaalpha »

Unfortunately did that already and double check nothing it did not work(I apologize for not telling you that I did that part).

How do go about remove few item from limitation list(assume somehow those item is on it)?

Edit: Good news Dytech module(4+) don't obey limitation list heehe.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Make recipe allowed producitivity Module

Post by FreeER »

sorry for the delay, I had to figure out why it wasn't working :)
So, the mistake I made on removing the limitations with the code earlier is that I used a '-' with string.find and '-'s are a special character when pattern matching so it needs to be escaped with a '%'...obviously still not an expert at lua :lol:
this worked for me (though I was lazy and just stuck it at the end of the metallurgy data.lua file) :)

Code: Select all

data.raw["assembling-machine"]["blast-furnace"].module_slots = 2
data.raw["assembling-machine"]["blast-furnace"].allowed_effects = {"consumption", "speed", "productivity", "pollution"}
for k, v in pairs(data.raw.module) do
  if v.name:find("productivity%-module") then
    v.limitation = nil -- empty limitation table
    v.limitation_message_key = nil
  end
end
omagaalpha wrote:Edit: Good news Dytech module(4+) don't obey limitation list heehe.
hm, seems they don't :lol: I suppose that would be the 'legit' way to do this then :D
omagaalpha
Inserter
Inserter
Posts: 23
Joined: Mon Apr 29, 2013 4:49 pm
Contact:

Re: Make recipe allowed producitivity Module

Post by omagaalpha »

Maybe don't how wonder possible go through limitation table remove only molten(like molten-copper,molten-iron,molten-carbonated-iron) items from the list?
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Make recipe allowed producitivity Module

Post by FreeER »

omagaalpha wrote:remove only molten
Well, the thing is that none of the dytech stuff is obviously written in the base :) And I don't see anywhere that Dysoch modified the base modules (and if he did I'm not sure why he wouldn't have made his modules limited as well...). As such, I've no idea how to make just the blast-furnace recipes able to use the productivity modules.
here's the list of limitations from the item module.lua file (in base)
list
edit: had a thought, it may be that these are a list of the recpies that are allowed to be used...that kind of makes sense but not what I was thinking :)
as such it'd only be a matter of adding to the list the DyTech recipe names that should be allowed as well :lol:
similar to the code I used above to set it to nil (meaning allow all) but instead use table.insert(v, "recipename"), could use a second for loop over a table of names like so

Code: Select all

for k, v in pairs(data.raw.module) do
  if v.name:find("productivity%-module") and v.limitation then
    for _, recipe in ipairs({table_of_dytech_recipe_names}) do
      table.insert(v.limitation, recipe)
    end
  end
end
omagaalpha
Inserter
Inserter
Posts: 23
Joined: Mon Apr 29, 2013 4:49 pm
Contact:

Re: Make recipe allowed producitivity Module

Post by omagaalpha »

Got around implementing code and it work like charmed. So thank you for the help.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Make recipe allowed producitivity Module

Post by FreeER »

omagaalpha wrote:Got around implementing code and it work like charmed. So thank you for the help.
No problem, glad it works :) I learned something as well since I'd never gotten around to seeing how the production module limitation had been implemented myself :lol:
User avatar
BEEFE
Inserter
Inserter
Posts: 42
Joined: Sat May 25, 2019 1:13 am
Contact:

Re: Make recipe allowed producitivity Module

Post by BEEFE »

I know this is from 5 years ago but this is some really basic, important information that's not in the wiki or the stickied tutorial thread. The code is different from what Angel and Bob's Mods seem to use, but I couldn't figure out how to repurpose them while this worked right out of the box.

If you're still around to read this, thanks for the help!
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Make recipe allowed producitivity Module

Post by Bilka »

BEEFE wrote: Wed Jun 05, 2019 1:39 am I know this is from 5 years ago but this is some really basic, important information that's not in the wiki.
https://wiki.factorio.com/Prototype/Module#limitation
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
BEEFE
Inserter
Inserter
Posts: 42
Joined: Sat May 25, 2019 1:13 am
Contact:

Re: Make recipe allowed producitivity Module

Post by BEEFE »

Sorry, I meant in the tutorial in the wiki. You've got documentation so you've done your job as a developer!
Post Reply

Return to “Modding help”