Circuit Processing


A mod for Bob's mods. Reintroduces green to red to blue circuit progression. New circuits result in overall increased resource usage. Reduces module count and types.

Tweaks
1 year, 11 months ago
0.15 - 1.1
83.3K

b Circuit Processing VS 1.0

4 years ago

error while loading mod__CircuitProcessing__/data-updates.lua:2:CircuitProcessing/bobmodules.lua:140:attempt to index field 'expensive' (a nil value) stack traceback:

CircuitProcessing/bobmodules.lua:140: in main chunk
[C]: in funktion 'require'
CircuitProcessing/data-updates.lua:2: in main chunk
stack traceback:
[C]: in funkzion 'require'
CircuitProcessing/date-updates.lua:2: in main chunk

4 years ago
(updated 4 years ago)

Line 140 in bobmodules.lua is:
replaceingredients(recipe.expensive.ingredients)

Commenting out this line allows the game to load, so long as you aren't using expensive mode.

-- replaceingredients(recipe.expensive.ingredients)

4 years ago
(updated 4 years ago)

created a propper fix (I think, not fimiliar with the code):
replace

  if recipe.normal then
    replaceingredients(recipe.normal.ingredients)
    replaceingredients(recipe.expensive.ingredients)
  else
    replaceingredients(recipe.ingredients)
  end

with

  if recipe.normal then
    replaceingredients(recipe.normal.ingredients)
  end
  if recipe.expensive then
    replaceingredients(recipe.expensive.ingredients)
  end
  if not (recipe.normal or recipe.expensive) then
    replaceingredients(recipe.ingredients)
  end

This basically just adds nil checks around all the calls as it should have been to begin with.

EDIT:
to be clear this just makes sure it doesn't crash, this might not be the intended behavior.

EDIT2:
after reading https://wiki.factorio.com/Prototype/Recipe#Recipe_data I updated the code to match their description.

4 years ago
(updated 4 years ago)

It looks like the intended behavior is to run "replaceingredients" on every possible variation of the recipe, so that should be good. In fact I think we can reduce it to this:

  if recipe.normal then
    replaceingredients(recipe.normal.ingredients)
  end
  if recipe.expensive then
    replaceingredients(recipe.expensive.ingredients)
  end
  if recipe.ingredients then
    replaceingredients(recipe.ingredients)
  end
4 years ago

no, according to the documentation recipe should only be used directly is normal and expensive are both false.
if the "normal" or "expensive" property exists, the recipe has difficulty. Then, the recipe data has to be specified for each difficulty instead of directly in the prototype. so if there is a difficulty, use that difficulty, if (and only if!) no difficulty exists use the prototype itself.

4 years ago

So... what exactly should I modify that mod to make it works properly?

4 years ago
(updated 4 years ago)

So... what exactly should I modify that mod to make it works properly?

Look within this mod's files for the file named "bobmodules.lua". Look near line 140 of that file; you should see the first code block that theMightyMan posted. Replace it with the second code block he posted, or with the code block I posted (it doesn't matter which, you'll get the same result either way).

so if there is a difficulty, use that difficulty, if (and only if!) no difficulty exists use the prototype itself.

I can see from reading the "replaceingredients" function that its purpose is to modify the recipe, not to use it. Modifying something that isn't going to be used anyway is harmless.

4 years ago

I guess that's true, but its doing unnecessary work. I guess its up to Trainwreck to decide what he does, both will work.

4 years ago
(updated 4 years ago)

I used an if-else chain:

if recipe.normal then
  replaceingredients(recipe.normal.ingredients)
else
  if recipe.expensive then
    replaceingredients(recipe.expensive.ingredients)
  else
    replaceingredients(recipe.ingredients)
  end
end

I think the problem is elsewhere, though. Something has the normal cost set but not the expensive one.

EDIT: Don't do this. theMightyMan is closer to the original code's behaviour.

4 years ago

joonazan, that is definitly wrong.
If normal exists expensive cal still exist as well. Since we dont know what difficulty the user is running at we dont know which one to replace.
Brilliand's and my solotion are both correct in that the user will not see a diference between the 2.
If someone is using your solution and playing at expensive mode, they will not see the "replaced" ingredients for anything that also a recipe for normal mode (so basically all of them).

New response