create mcl_soy mod.

This commit is contained in:
trans_soup 2023-07-16 20:18:57 +02:00
parent f9f97ba3d5
commit e6793d4956
17 changed files with 189 additions and 0 deletions

19
mcl_soy/craft.lua Normal file
View File

@ -0,0 +1,19 @@
local modname = minetest.get_current_modname()
local soy = modname .. ":soy"
local tofu_raw = modname .. ":tofu_raw"
minetest.register_craft({
output = tofu_raw,
recipe = {
{ soy, soy, soy },
{ soy, soy, soy },
},
})
minetest.register_craft({
type = "cooking",
output = modname .. ":tofu_cooked",
recipe = tofu_raw,
cooktime = 10,
})

3
mcl_soy/depends.txt Normal file
View File

@ -0,0 +1,3 @@
mcl_core
mcl_farming
mcl_sounds

10
mcl_soy/init.lua Normal file
View File

@ -0,0 +1,10 @@
-- 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")

81
mcl_soy/item.lua Normal file
View File

@ -0,0 +1,81 @@
local modname = minetest.get_current_modname()
minetest.register_craftitem(modname .. ":soy", {
description = "Soy Beans",
groups = {
craftitem = 1,
food = 1,
eatable = 1,
},
_mcl_saturation = 0.0,
inventory_image = modname .. "_soy.png",
on_place = function (item_stack, placer, pointed_thing)
return mcl_farming:place_seed(item_stack, placer, pointed_thing, modname .. ":soy_1")
end,
on_secondary_use = minetest.item_eat(1),
})
minetest.register_craftitem(modname .. ":tofu_raw", {
description = "Raw Tofu",
inventory_image = modname .. "_tofu_raw.png",
groups = {
craftitem = 1,
food = 1,
eatable = 3,
},
_mcl_saturation = 1.0,
on_place = minetest.item_eat(3),
on_secondary_use = minetest.item_eat(3),
})
minetest.register_craftitem(modname .. ":tofu_cooked", {
description = "Cooked Tofu",
inventory_image = modname .. "_tofu_cooked.png",
groups = {
food = 2,
eatable = 6,
},
_mcl_saturation = 4.0,
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

3
mcl_soy/mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = mcl_soy
description = adds soy and tofu to mineclone2.
title = soy for mineclone2

73
mcl_soy/node.lua Normal file
View File

@ -0,0 +1,73 @@
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, {
max_items = 4,
items = {
{ items = { modname .. ":soy" } },
{ items = { modname .. ":soy 2" }, rarity = 2 },
{ items = { modname .. ":soy 4" }, rarity = 3 },
{ items = { modname .. ":soy" } },
{ items = { modname .. ":soy 5" }, rarity = 6 },
},
})
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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B