mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-28 09:36:27 -04:00
Improve flowers mod
Improve of the Flowers minetest_game mod, the code is more smaller and do the same thing.
This commit is contained in:
parent
f49faadc19
commit
1af3e40f41
1 changed files with 75 additions and 94 deletions
|
@ -1,9 +1,6 @@
|
|||
-- Minetest 0.4 mod: default
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
-- Namespace for functions
|
||||
flowers = {}
|
||||
|
||||
-- Map Generation
|
||||
dofile(minetest.get_modpath("flowers").."/mapgen.lua")
|
||||
|
||||
|
@ -15,93 +12,56 @@ minetest.register_alias("flowers:flower_rose", "flowers:rose")
|
|||
minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
|
||||
minetest.register_alias("flowers:flower_viola", "flowers:viola")
|
||||
|
||||
-------------------------------
|
||||
--- Fleur Simple (une case) ---
|
||||
-------------------------------
|
||||
|
||||
local function add_simple_flower(name, desc, image, color, f_groups)
|
||||
minetest.register_node("flowers:"..name.."", {
|
||||
description = desc,
|
||||
drawtype = "plantlike",
|
||||
tiles = { image..".png" },
|
||||
inventory_image = image..".png",
|
||||
wield_image = image..".png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 99,
|
||||
groups = f_groups,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
add_simple_flower("dandelion_yellow", "Yellow Dandelion", "flowers_dandelion_yellow", "color_yellow",{snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color_yellow=1})
|
||||
add_simple_flower("geranium", "Blue Geranium", "flowers_geranium", "color_blue",{snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color_blue=1})
|
||||
add_simple_flower("rose", "Rose", "flowers_rose", "color_red",{snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color_red=1})
|
||||
add_simple_flower("tulip", "Orange Tulip", "flowers_tulip", "color_orange",{snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color_orange=1})
|
||||
|
||||
---------------------------------------------
|
||||
----------------- OLD SYSTEM ----------------
|
||||
---------------------------------------------
|
||||
|
||||
minetest.register_node("flowers:dandelion_white", {
|
||||
description = "White Dandelion",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_dandelion_white.png" },
|
||||
inventory_image = "flowers_dandelion_white.png",
|
||||
wield_image = "flowers_dandelion_white.png",
|
||||
is_ground_content = true,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1},
|
||||
groups = {snappy = 3, flammable = 2, flower = 1, flora = 1, attached_node = 1, color_white = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 },
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("flowers:dandelion_yellow", {
|
||||
description = "Yellow Dandelion",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_dandelion_yellow.png" },
|
||||
inventory_image = "flowers_dandelion_yellow.png",
|
||||
wield_image = "flowers_dandelion_yellow.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_yellow=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("flowers:geranium", {
|
||||
description = "Blue Geranium",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_geranium.png" },
|
||||
inventory_image = "flowers_geranium.png",
|
||||
wield_image = "flowers_geranium.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_blue=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("flowers:rose", {
|
||||
description = "Rose",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_rose.png" },
|
||||
inventory_image = "flowers_rose.png",
|
||||
wield_image = "flowers_rose.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_red=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.3, 0.15 },
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("flowers:tulip", {
|
||||
description = "Tulip",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "flowers_tulip.png" },
|
||||
inventory_image = "flowers_tulip.png",
|
||||
wield_image = "flowers_tulip.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_orange=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -111,11 +71,12 @@ minetest.register_node("flowers:viola", {
|
|||
tiles = { "flowers_viola.png" },
|
||||
inventory_image = "flowers_viola.png",
|
||||
wield_image = "flowers_viola.png",
|
||||
is_ground_content = true,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1},
|
||||
groups = {snappy = 3, flammable = 2, flower = 1, flora = 1, attached_node = 1, color_violet = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
|
@ -123,36 +84,52 @@ minetest.register_node("flowers:viola", {
|
|||
},
|
||||
})
|
||||
|
||||
minetest.register_node("flowers:lily_pad", {
|
||||
description = "Lily Pad",
|
||||
drawtype = "nodebox",
|
||||
tiles = { "flowers_lily_pad.png" },
|
||||
inventory_image = "flowers_lily_pad.png",
|
||||
wield_image = "flowers_lily_pad.png",
|
||||
wield_scale = {x = 1, y = 1, z = 0.001},
|
||||
is_ground_content = true,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
groups = {snappy = 3, flammable = 2, flower = 1, flora = 1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.45, -0.5, 0.5, -0.4375, 0.5},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:flora"},
|
||||
neighbors = {"default:dirt_with_grass", "default:desert_sand"},
|
||||
interval = 50,
|
||||
chance = 25,
|
||||
interval = 2,
|
||||
chance = 500,
|
||||
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="default:dry_shrub"})
|
||||
elseif under.name ~= "default:dirt_with_grass" then
|
||||
return
|
||||
end
|
||||
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
|
||||
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 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
|
||||
if #flowers > 3 then return end
|
||||
|
||||
local seedling = minetest.find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
|
||||
if #seedling > 0 then
|
||||
|
@ -168,3 +145,7 @@ minetest.register_abm({
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
if minetest.setting_getbool("log_mods") then
|
||||
minetest.log("action", "Carbone: [flowers] loaded.")
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue