refactor: make mcl_soy use mcl_vegan_utils.
This commit is contained in:
parent
9c94d96fb9
commit
845dfaa6a2
4 changed files with 13 additions and 109 deletions
|
@ -1,3 +1,4 @@
|
|||
mcl_vegan_utils
|
||||
mcl_core
|
||||
mcl_farming
|
||||
mcl_sounds
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
-- TODO: extract this into general utility mod.
|
||||
local function include (filename)
|
||||
local modname = minetest.get_current_modname()
|
||||
local path = minetest.get_modpath(modname)
|
||||
return dofile(path .. "/" .. filename .. ".lua")
|
||||
end
|
||||
|
||||
include("item")
|
||||
include("node")
|
||||
include("craft")
|
||||
|
|
|
@ -39,43 +39,3 @@ minetest.register_craftitem(modname .. ":tofu_cooked", {
|
|||
on_place = minetest.item_eat(6),
|
||||
on_secondary_use = minetest.item_eat(6),
|
||||
})
|
||||
|
||||
-- TODO: extract this into general utility mod.
|
||||
local function get_drop (target_name)
|
||||
local def = minetest.registered_items[target_name]
|
||||
if not def then return false end
|
||||
def.drop = def.drop or {}
|
||||
return def.drop
|
||||
end
|
||||
|
||||
local function stringify_table (tab)
|
||||
local result = "{ "
|
||||
for key, value in pairs(tab) do
|
||||
if type(key) == "table" then key = stringify_table(key) end
|
||||
if type(value) == "table" then value = stringify_table(value) end
|
||||
result = result .. key .. " = " .. value .. ", "
|
||||
end
|
||||
return result .. "}"
|
||||
end
|
||||
|
||||
-- TODO: extract this into general utility mod.
|
||||
local function add_drop (target_name, item)
|
||||
local drops = get_drop(target_name)
|
||||
if not drops then return false end
|
||||
table.insert(drops.items, item)
|
||||
return true
|
||||
end
|
||||
|
||||
local grasses = {
|
||||
"mcl_flowers:tallgrass",
|
||||
"mcl_flowers:fern",
|
||||
"mcl_flowers:double_grass",
|
||||
"mcl_flowers:double_fern",
|
||||
}
|
||||
|
||||
for _, grass in pairs(grasses) do
|
||||
add_drop(grass, {
|
||||
items = { modname .. ":soy" },
|
||||
rarity = 8,
|
||||
})
|
||||
end
|
||||
|
|
|
@ -1,55 +1,6 @@
|
|||
local modname = minetest.get_current_modname()
|
||||
|
||||
-- copied from wheat for now
|
||||
local crop_heights = {
|
||||
-5/16,
|
||||
-2/16,
|
||||
0,
|
||||
3/16,
|
||||
5/16,
|
||||
6/16,
|
||||
7/16,
|
||||
8/16,
|
||||
}
|
||||
|
||||
local function register_plant_stage (stage, drops)
|
||||
local texture = modname .. "_soy_stage_" .. (stage - 1) .. ".png"
|
||||
|
||||
minetest.register_node(modname .. ":soy_" .. stage, {
|
||||
description = "Soy Plant (stage " .. stage .. ")",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = drops,
|
||||
tiles = { texture },
|
||||
inventory_image = texture,
|
||||
wield_image = texture,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, crop_heights[stage], 0.5}
|
||||
},
|
||||
},
|
||||
groups = {
|
||||
dig_immediate = 3,
|
||||
not_in_creative_inventory = 1,
|
||||
plant = 1,
|
||||
attached_node = 1,
|
||||
dig_by_water = 1,
|
||||
destroy_by_lava_flow = 1,
|
||||
dig_by_piston = 1,
|
||||
},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
_mcl_blast_resistance = 0,
|
||||
})
|
||||
end
|
||||
|
||||
for i=1,7 do
|
||||
register_plant_stage(i, modname .. ":soy")
|
||||
end
|
||||
|
||||
register_plant_stage(8, {
|
||||
local final_drops = {
|
||||
max_items = 4,
|
||||
items = {
|
||||
{ items = { modname .. ":soy" } },
|
||||
|
@ -58,16 +9,15 @@ register_plant_stage(8, {
|
|||
{ items = { modname .. ":soy" } },
|
||||
{ items = { modname .. ":soy 5" }, rarity = 6 },
|
||||
},
|
||||
}
|
||||
|
||||
mcl_vegan.register_basic_plant(modname, "soy", {
|
||||
seed = "soy",
|
||||
descriptions = {
|
||||
crop = "Soy Plant",
|
||||
},
|
||||
drops = final_drops,
|
||||
growth_interval = 15,
|
||||
growth_chance = 20,
|
||||
can_forage = true,
|
||||
})
|
||||
|
||||
|
||||
|
||||
mcl_farming:add_plant("plant_soy", modname .. ":soy_8", {
|
||||
modname .. ":soy_1",
|
||||
modname .. ":soy_2",
|
||||
modname .. ":soy_3",
|
||||
modname .. ":soy_4",
|
||||
modname .. ":soy_5",
|
||||
modname .. ":soy_6",
|
||||
modname .. ":soy_7",
|
||||
}, 20, 15)
|
||||
|
|
Loading…
Reference in a new issue