Make drop logic work better for non-8-step-plants. (#1544)
authorThomas--S <Thomas--S@users.noreply.github.com>
Wed, 8 Feb 2017 23:59:25 +0000 (00:59 +0100)
committerAuke Kok <sofar+github@foo-projects.org>
Wed, 8 Feb 2017 23:59:25 +0000 (15:59 -0800)
Using @paramat's formula.

mods/farming/api.lua

index 182e1b20d347e44bbbf885f565a130c19d0089b1..b6e3ee3e8ee6eecc2b9313bfa5cd1b282b9ba9ae 100644 (file)
@@ -330,12 +330,16 @@ farming.register_plant = function(name, def)
 
        -- Register growing steps
        for i = 1, def.steps do
+               local base_rarity = 1
+               if def.steps ~= 1 then
+                       base_rarity =  8 - (i - 1) * 7 / (def.steps - 1)
+               end
                local drop = {
                        items = {
-                               {items = {mname .. ":" .. pname}, rarity = 9 - i},
-                               {items = {mname .. ":" .. pname}, rarity= 18 - i * 2},
-                               {items = {mname .. ":seed_" .. pname}, rarity = 9 - i},
-                               {items = {mname .. ":seed_" .. pname}, rarity = 18 - i * 2},
+                               {items = {mname .. ":" .. pname}, rarity = base_rarity},
+                               {items = {mname .. ":" .. pname}, rarity = base_rarity * 2},
+                               {items = {mname .. ":seed_" .. pname}, rarity = base_rarity},
+                               {items = {mname .. ":seed_" .. pname}, rarity = base_rarity * 2},
                        }
                }
                local nodegroups = {snappy = 3, flammable = 2, plant = 1, not_in_creative_inventory = 1, attached_node = 1}