owl_tech/farming/seeds.lua

120 lines
4.6 KiB
Lua
Raw Normal View History

2023-01-12 18:58:55 +01:00
local S = minetest.get_translator(minetest.get_current_modname())
local name = minetest.get_current_modname()
local path = minetest.get_modpath(name)
local function spawn_crop_from_seed(pos,itemstack,crop_name)
minetest.place_node(pos, crop_name)
local item_amount = itemstack:get_count()
if item_amount==1 then
itemstack:clear()
end
end
local sel_heights = {
-5/16,
-2/16,
0,
3/16,
5/16,
6/16,
7/16,
}
--1)name 2)Name 3)texture base name 4)stages 5)seed texture 6)drop name 7)drop amount
local list_all_crops ={
{"ruber_wheat","Ruber Wheat","owl_tech_ruber_wheat_",8,"owl_tech.seed_ruber_wheat.png"},
}
for i = 1, #list_all_crops, 1 do
local create, name, longdesc
if i == 1 then
create = true
name = S("Premature "..list_all_crops[i][2] )
longdesc = S(
"Premature plants grow on farmland under sunlight in 8 stages.On hydrated farmland, they grow faster. They can be harvested at any time but will only yield a profit when mature.")
else
create = false
end
minetest.register_craftitem("owl_tech:seeds_"..list_all_crops[i][1], {
description = S(list_all_crops[i][2].." Seeds"),
_tt_help = S("Grows on farmland"),
_doc_items_longdesc = S("Grows into a wheat plant."),
_doc_items_usagehelp = S(" Place the wheat seeds on farmland (which can be created with a hoe) to plant plant."),
groups = {craftitem = 1, compostability = 30},
inventory_image = list_all_crops[i][5],
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type =="node" then
local node_chek = minetest.get_node(pointed_thing.under)
if node_chek.name=="mcl_farming:soil" or node_chek.name=="mcl_farming:soil_wet" then
2023-01-12 20:07:41 +01:00
if itemstack:get_count()>1 then
itemstack:set_count(itemstack:get_count()-1)
else
itemstack:clear()
end
2023-01-12 18:58:55 +01:00
minetest.set_node({x=pointed_thing.under.x,y=pointed_thing.under.y+1,z=pointed_thing.under.z},{name="owl_tech:plant_"..list_all_crops[i][1]..1})
2023-01-12 20:07:41 +01:00
return itemstack
2023-01-12 18:58:55 +01:00
end
end
end
})
for j = 1, list_all_crops[i][4]-1, 1 do
minetest.register_node("owl_tech:plant_"..list_all_crops[i][1]..j, {
description = S("Premature "..list_all_crops[i][2]),
_doc_items_create_entry = create,
_doc_items_entry_name = name,
_doc_items_longdesc = longdesc,
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 3,
sunlight_propagates = true,
walkable = false,
drawtype = "plantlike",
drop = "owl_tech:seeds_"..list_all_crops[i][1],
tiles = {"owl_tech_ruber_wheat_"..j..".png"},
inventory_image = "owl_tech_ruber_wheat_"..j..".png",
wield_image = "owl_tech_ruber_wheat_"..j..".png",
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, sel_heights[i], 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
minetest.register_node("owl_tech:plant_"..list_all_crops[i][1].."8", {
description = S("Mature "..list_all_crops[i][2]),
_doc_items_longdesc = S("Mature plants are ready to be harvested for wheat and seeds."),
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 3,
walkable = false,
drawtype = "plantlike",
tiles = {list_all_crops[i][3].."8.png"},
inventory_image = list_all_crops[i][3].."8.png",
wield_image = list_all_crops[i][3].."8.png",
drop = {
max_items = 4,
items = {
{ items = {"owl_tech:seeds_"..list_all_crops[i][1]} },
{ items = {"owl_tech:seeds_"..list_all_crops[i][1]}, rarity = 2},
{ items = {"owl_tech:seeds_"..list_all_crops[i][1]}, rarity = 5},
{ items = {"owl_tech:raw_ruber_dust"} }
}
},
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