Farm Quality Plants


Planting quality seeds will now yield quality plants!

Content
19 hours ago
2.0
119
Manufacturing

g It doesnt initate

6 days ago

There seems to be a bug whith how icons are organized for the player display

Error al cargar el mod: quality-plants/data-updates.lua:119: attempt to concatenate field 'order' (a nil value)
stack traceback:
quality-plants/data-updates.lua:119: in function 'generate_plant_products'
quality-plants/data-updates.lua:166: in main chunk

6 days ago

Are you running any mods?

6 days ago
(updated 6 days ago)

Hi there

I was digging around in the code for fun and found these four issues, tried some solutions, see below. I don't know if these are issues in the other mods (e.g., maybe you have to specify an order and it's wrong not to do so), but I think it's easier to handle those issues here in your mod, makes it more robust anyways.

1 the "order" error from data-updates.lua:119 is caused by some mods I have installed not having "order" specified in their plants' minable.results:

2 no order specified in the plants themselves:

3 Another problem is when there are multiple minable.results, Lignumis has one plant with three results:

4 Finally, another problem I encountered is when the resulting product was found in neither "item" nor "capsule" (your checks in 108:111) - Moshine has one, it's a "tool":


So I tried these approaches locally, maybe you can use these as solutions (or of course implement it differently) - although I have not tested them (I just recently started a new save; besides Lignumis, I don't even know what those plants do on their planets or how the experience with them is). But with these, Factorio doesn't crash anymore when your mod's enabled.

  1. guard in line 119 against missing order of plants' minable.results:
    if product_prototype.order ~= nil then product_prototype.order = "z"..product_prototype.order..quality_level end

  2. guard in line 87 against missing order of plant:
    if plant_prototype.order ~= nil then plant_prototype.order = plant_prototype.order..quality_level end

  3. handle multiple minable.results:
    a) introduce array to return before 107: local plant_products = {}
    b) don't return first item in 140, but add to array: plant_products[i] = product_prototype
    c) after 141, i.e. after the loop, return the whole array: return plant_products
    d) replace 167:169 with this (since we return an array now and not a single item):
    for i, product in pairs(product_prototype) do
    place_icon_on_item(product, quality_name)
    data:extend{product}
    end
    data:extend{plant_prototype}

  4. I don't know what to do here, I don't understand what Moshine does with the tool "datacell-solved-equation" (I don't even understand what "tool" means, seems to be science packs mostly); so I chose to ignore the whole thing, that is:
    a) after 111, if still nil, return to caller: if product_prototype == nil then return nil end
    b) then, execute the stuff added in 3.d) only if not returned nil: if product_prototype ~= nil then <<<StuffFromSection3.d)>>> end


6 days ago

Yup that’s what my guess was, it’s just not an issue in vanilla. It’ll be an easy fix as I just have to change one line or two, thanks for the report

6 days ago

you could push your source to github so I could have just made a PR for you to review ;-)

6 days ago
(updated 6 days ago)

I've actually got no clue how to use github, but I'll probably take the time today to learn it given how many mods I have up. First, I'll fix this issue.

Also, the mod does handle multiple minable.results actually :), maybe I just need to double check with that mod. With boompuff agriculture, it worked fine

5 days ago

Alright, this should all be fixed. At least it is functional on my end with the mods you mentioned. Funny story about the mining results: in my testing for multiple results + mods, I used boompuff agriculture. Boompuff agriculture adds a plant that yields wood, and spoilage. With the way my code was running, it would only create the fake quality spoilage prototypes. Why no crash? Because the tree prototypes were created earlier, so the quality wood prototypes were already created. Therefore, I never actually ran into any issues with this stuff when making the mod lol

New response