Wood Gasification updated

by yokmp

Updated Wood Gasification from cappie https://mods.factorio.com/mod/Wood_Gasification And included the K2 Greenhouse https://mods.factorio.com/mod/Krastorio2greenhouse None of these mods are mine, i just modified them to work with 2.0

Content
27 days ago
2.0
1.31K
Fluids Manufacturing

b Crash w/o Space Age

29 days ago
(updated 29 days ago)

Hi, just wanted to let you know that the mod crashes the game due to invalid references when the Space Age DLC is not installed. I ended up making a fix for myself, while also changing tech and tidying up a bit. Would you like a copy? I have uploaded it to my Google Drive:

https://drive.google.com/file/d/1DsoQo4AGf06z49h2aKbIFG5Xwt2CmDnq/view?usp=sharing

Mind you, I don't know whether it works with the DLC installed.

29 days ago

I discovered the same issue yesterday and ill look into it

29 days ago

All right!

28 days ago
(updated 28 days ago)

Game still crash with the newest fix from 15h ago :(

Err.-Msg.:
Wood_Gasification_updated /prototypes/space-age.lua:120: attempt to index field 'minable' (a nil value)
stack traceback:
Wood_Gasification_updated /prototypes/space-age.lua:120: in main chunk
[C]: in function 'require'
Wood_Gasification_updated /data.lua:6: in main chunk

28 days ago
(updated 28 days ago)

Thanks for the update, the mod seems to work fine now! As for the problem reported above, my non-expert guess is, that a nil check must be made for the entire address, since the minable or result property below it could be removed by another mod (they are both optional properties according to docs).

A standard function I like to use (for the sake of compactness), is this:

function address_exists(t, ...)
  for i = 1, select("#", ...) do
    if t == nil then return false end
    t = t[select(i, ...)]
  end
  return true
end

An implementation would then look like this:

local t = data.raw.tree
  for _, value in pairs(t) do
    if address_exists(minable, "result") and value.minable.result == "wood" then
      [code]
    end
  end
end

Which should at least prevent a crash. Pardon the unsolicited advice, just really wanted to share! The function is very useful for deep tables. [Edit: Fixed code and explanation above]

27 days ago

Neat.
I hope i've fixed it in 4.1.3

27 days ago

Aight!👍

27 days ago

Thanks for the realy fast support! it works for now - happy to use the mod again ^^

27 days ago

For now? Ouch ... ^^

New response