diff --git a/mcl_soy/craft.lua b/mcl_soy/craft.lua new file mode 100644 index 0000000..e146a4e --- /dev/null +++ b/mcl_soy/craft.lua @@ -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, +}) diff --git a/mcl_soy/depends.txt b/mcl_soy/depends.txt new file mode 100644 index 0000000..2274fb1 --- /dev/null +++ b/mcl_soy/depends.txt @@ -0,0 +1,3 @@ +mcl_core +mcl_farming +mcl_sounds diff --git a/mcl_soy/init.lua b/mcl_soy/init.lua new file mode 100644 index 0000000..3235c65 --- /dev/null +++ b/mcl_soy/init.lua @@ -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") diff --git a/mcl_soy/item.lua b/mcl_soy/item.lua new file mode 100644 index 0000000..b593792 --- /dev/null +++ b/mcl_soy/item.lua @@ -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 diff --git a/mcl_soy/mod.conf b/mcl_soy/mod.conf new file mode 100644 index 0000000..f59b65d --- /dev/null +++ b/mcl_soy/mod.conf @@ -0,0 +1,3 @@ +name = mcl_soy +description = adds soy and tofu to mineclone2. +title = soy for mineclone2 diff --git a/mcl_soy/node.lua b/mcl_soy/node.lua new file mode 100644 index 0000000..2c50da6 --- /dev/null +++ b/mcl_soy/node.lua @@ -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) diff --git a/mcl_soy/textures/mcl_soy_soy.png b/mcl_soy/textures/mcl_soy_soy.png new file mode 100644 index 0000000..b880cb7 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy.png differ diff --git a/mcl_soy/textures/mcl_soy_soy_stage_0.png b/mcl_soy/textures/mcl_soy_soy_stage_0.png new file mode 100644 index 0000000..2726769 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy_stage_0.png differ diff --git a/mcl_soy/textures/mcl_soy_soy_stage_1.png b/mcl_soy/textures/mcl_soy_soy_stage_1.png new file mode 100644 index 0000000..8adeafb Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy_stage_1.png differ diff --git a/mcl_soy/textures/mcl_soy_soy_stage_2.png b/mcl_soy/textures/mcl_soy_soy_stage_2.png new file mode 100644 index 0000000..d698821 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy_stage_2.png differ diff --git a/mcl_soy/textures/mcl_soy_soy_stage_3.png b/mcl_soy/textures/mcl_soy_soy_stage_3.png new file mode 100644 index 0000000..e6a894b Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy_stage_3.png differ diff --git a/mcl_soy/textures/mcl_soy_soy_stage_4.png b/mcl_soy/textures/mcl_soy_soy_stage_4.png new file mode 100644 index 0000000..d32f2f4 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy_stage_4.png differ diff --git a/mcl_soy/textures/mcl_soy_soy_stage_5.png b/mcl_soy/textures/mcl_soy_soy_stage_5.png new file mode 100644 index 0000000..c396108 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy_stage_5.png differ diff --git a/mcl_soy/textures/mcl_soy_soy_stage_6.png b/mcl_soy/textures/mcl_soy_soy_stage_6.png new file mode 100644 index 0000000..cfb9070 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy_stage_6.png differ diff --git a/mcl_soy/textures/mcl_soy_soy_stage_7.png b/mcl_soy/textures/mcl_soy_soy_stage_7.png new file mode 100644 index 0000000..c38bc14 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_soy_stage_7.png differ diff --git a/mcl_soy/textures/mcl_soy_tofu_cooked.png b/mcl_soy/textures/mcl_soy_tofu_cooked.png new file mode 100644 index 0000000..1ffb487 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_tofu_cooked.png differ diff --git a/mcl_soy/textures/mcl_soy_tofu_raw.png b/mcl_soy/textures/mcl_soy_tofu_raw.png new file mode 100644 index 0000000..44df1e1 Binary files /dev/null and b/mcl_soy/textures/mcl_soy_tofu_raw.png differ