Skip to content

Commit

Permalink
Wooden: refactoring lottplants: reorganize code & files. Relates to #…
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Feb 29, 2024
1 parent 4443443 commit 89c4f49
Show file tree
Hide file tree
Showing 11 changed files with 1,476 additions and 1,533 deletions.
166 changes: 5 additions & 161 deletions mods/lord/Blocks/lottplants/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,169 +3,13 @@ local old_require = require
require = function(name) return dofile(mod_path .. "/src/" .. name:gsub("%.", "/") .. ".lua") end


local S = minetest.get_translator("lottplants")

require("nodes")
require("trees")
require("wild_crops")
require("flowers")

-- ===== GROWING TIME =====
-- 67 11
-- ольха
ALDINT = 67
ALDCHA = 11

-- яблоня
APPINT = 67
APPCHA = 11

-- берёза
BIRINT = 67
BIRCHA = 11

-- бук
BEEINT = 67
BEECHA = 11

-- кулумальда
CULINT = 67
CULCHA = 11

-- вяз
ELMINT = 67
ELMCHA = 11

-- ель
FIRINT = 67
FIRCHA = 11

-- лебетрон
LEBINT = 67
LEBCHA = 11

-- малорн
MALINT = 67
MALCHA = 11

-- лихолесье
MIRINT = 67
MIRCHA = 11

-- сосна
PININT = 67
PINCHA = 11

-- слива
PLUINT = 67
PLUCHA = 11

-- рябина
ROWINT = 67
ROWCHA = 11

-- белое дерево
WHIINT = 67
WHICHA = 11

-- йаванамирэ
YAVINT = 67
YAVCHA = 11

require("functions")

minetest.register_node("lottplants:brambles_of_mordor", {
description = S("Brambles Of Mordor"),
drawtype = "plantlike",
tiles = { "lottplants_brambles_of_mordor.png" },
inventory_image = "lottplants_brambles_of_mordor.png",
wield_image = "lottplants_brambles_of_mordor.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 42,
walkable = false,
waving = 1,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_grey=1, grass=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})

minetest.register_node("lottplants:pilinehtar", {
description = S("Pilinehtar"),
drawtype = "plantlike",
tiles = { "lottplants_pilinehtar.png" },
inventory_image = "lottplants_pilinehtar.png",
wield_image = "lottplants_pilinehtar.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 2,
waving = 1,
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_green=1, grass=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})

minetest.register_abm({
nodenames = {"group:flora"},
neighbors = {"default:dirt_with_grass", "default:desert_sand"},
interval = 50,
chance = 25,
action = function(pos, node)
pos.y = pos.y - 1
local under = minetest.get_node(pos)
pos.y = pos.y + 1
if under.name == "default:desert_sand" then
minetest.set_node(pos, {name="lottplants:brambles_of_mordor"})
elseif under.name ~= "default:dirt_with_grass" then
return
end

local light = minetest.get_node_light(pos)
if not light or light < 13 then
return
end

local pos0 = {x=pos.x-4,y=pos.y-4,z=pos.z-4}
local pos1 = {x=pos.x+4,y=pos.y+4,z=pos.z+4}
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
return
end

local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
if #flowers > 3 then
return
end

local seedling = minetest.find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
if #seedling > 0 then
seedling = seedling[math.random(#seedling)]
seedling.y = seedling.y + 1
light = minetest.get_node_light(seedling)
if not light or light < 13 then
return
end
if minetest.get_node(seedling).name == "air" then
minetest.set_node(seedling, {name=node.name})
end
end
end,
})

minetest.register_craftitem("lottplants:honey", {
description = S("Honey"),
inventory_image = "lottplants_honey.png",
on_use = minetest.item_eat(1),
})
require("herbs")
require("nodes")
--- @type lottplants.Planks_API
_G.planks = require('planks')


require = old_require
136 changes: 136 additions & 0 deletions mods/lord/Blocks/lottplants/src/herbs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
local S = minetest.get_translator("lottplants")


--Lorien grass
minetest.register_node("lottplants:lorien_grass_1", {
description = S("Lorien Grass"),
drawtype = "plantlike",
tiles = { "lottplants_lorien_grass_1.png" },
-- use a bigger inventory image
inventory_image = "lottplants_lorien_grass_3.png",
wield_image = "lottplants_lorien_grass_3.png",
paramtype = "light",
waving = 1,
walkable = false,
is_ground_content = true,
buildable_to = true,
groups = {
snappy = 3, flammable = 3, flora = 1, attached_node = 1, grass = 1, color_green = 1
},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -5 / 16, 0.5 },
},
on_place = function(itemstack, placer, pointed_thing)
-- place a random grass node
local stack = ItemStack("lottplants:lorien_grass_" .. math.random(1, 5))
local ret = minetest.item_place(stack, placer, pointed_thing)
return ItemStack("lottplants:lorien_grass_1 " .. itemstack:get_count() - (1 - ret:get_count()))
end,
})
minetest.register_node("lottplants:lorien_grass_2", {
description = S("Lorien Grass"),
drawtype = "plantlike",
tiles = { "lottplants_lorien_grass_2.png" },
inventory_image = "lottplants_lorien_grass_2.png",
wield_image = "lottplants_lorien_grass_2.png",
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
is_ground_content = true,
drop = "lottplants:lorien_grass_1",
groups = {
snappy = 3, flammable = 3, flora = 1, attached_node = 1, not_in_creative_inventory = 1, grass = 1
},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -5 / 16, 0.5 },
},
})
minetest.register_node("lottplants:lorien_grass_3", {
description = S("Lorien Grass"),
drawtype = "plantlike",
tiles = { "lottplants_lorien_grass_3.png" },
inventory_image = "lottplants_lorien_grass_3.png",
wield_image = "lottplants_lorien_grass_3.png",
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
is_ground_content = true,
drop = "lottplants:lorien_grass_1",
groups = {
snappy = 3, flammable = 3, flora = 1, attached_node = 1, not_in_creative_inventory = 1, grass = 1
},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -5 / 16, 0.5 },
},
})
minetest.register_node("lottplants:lorien_grass_4", {
description = S("Lorien Grass"),
drawtype = "plantlike",
tiles = { "lottplants_lorien_grass_4.png" },
inventory_image = "lottplants_lorien_grass_4.png",
wield_image = "lottplants_lorien_grass_4.png",
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
is_ground_content = true,
drop = "lottplants:lorien_grass_1",
groups = {
snappy = 3, flammable = 3, flora = 1, attached_node = 1, not_in_creative_inventory = 1, grass = 1
},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -5 / 16, 0.5 },
},
})

minetest.register_node("lottplants:brambles_of_mordor", {
description = S("Brambles Of Mordor"),
drawtype = "plantlike",
tiles = { "lottplants_brambles_of_mordor.png" },
inventory_image = "lottplants_brambles_of_mordor.png",
wield_image = "lottplants_brambles_of_mordor.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 42,
walkable = false,
waving = 1,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_grey=1, grass=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})

minetest.register_node("lottplants:pilinehtar", {
description = S("Pilinehtar"),
drawtype = "plantlike",
tiles = { "lottplants_pilinehtar.png" },
inventory_image = "lottplants_pilinehtar.png",
wield_image = "lottplants_pilinehtar.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 2,
waving = 1,
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_green=1, grass=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
Loading

0 comments on commit 89c4f49

Please sign in to comment.