Rename mod: flowers to mcl_flowers
12
mods/mcl_flowers/README.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
Minetest 0.4 mod: flowers
|
||||
=========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2012-2013 Ironzorg, VanessaE
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
8
mods/mcl_flowers/credit.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
Credit to people who made things.
|
||||
|
||||
jojoa1997:
|
||||
-edited all of it
|
||||
-flower pot
|
||||
|
||||
VanessaE:
|
||||
-waterlily
|
1
mods/mcl_flowers/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
default
|
81
mods/mcl_flowers/func.lua
Normal file
|
@ -0,0 +1,81 @@
|
|||
minetest.register_entity("mcl_flowers:item",{
|
||||
hp_max = 1,
|
||||
visual="wielditem",
|
||||
visual_size={x=.25,y=.25},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
groups = {snappy=3,attached_node=1},
|
||||
stack_max = 1,
|
||||
physical=false,
|
||||
textures={"air"},
|
||||
on_activate = function(self, staticdata)
|
||||
if flower_tmp.nodename ~= nil and flower_tmp.texture ~= nil then
|
||||
self.nodename = flower_tmp.nodename
|
||||
flower_tmp.nodename = nil
|
||||
self.texture = flower_tmp.texture
|
||||
flower_tmp.texture = nil
|
||||
else
|
||||
if staticdata ~= nil and staticdata ~= "" then
|
||||
local data = staticdata:split(';')
|
||||
if data and data[1] and data[2] then
|
||||
self.nodename = data[1]
|
||||
self.texture = data[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.texture ~= nil then
|
||||
self.object:set_properties({textures={self.texture}})
|
||||
end
|
||||
end,
|
||||
get_staticdata = function(self)
|
||||
if self.nodename ~= nil and self.texture ~= nil then
|
||||
return self.nodename .. ';' .. self.texture
|
||||
end
|
||||
return ""
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
|
||||
local facedir = {}
|
||||
facedir[0] = {x=0,y=0,z=1}
|
||||
facedir[1] = {x=1,y=0,z=0}
|
||||
facedir[2] = {x=0,y=0,z=-1}
|
||||
facedir[3] = {x=-1,y=0,z=0}
|
||||
|
||||
local flower_pot_remove_item = function(pos, node)
|
||||
local objs = nil
|
||||
if node and node.name == "mcl_flowers:pot" then
|
||||
objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, .5)
|
||||
end
|
||||
if objs then
|
||||
for _, obj in ipairs(objs) do
|
||||
if obj and obj:get_luaentity() and obj:get_luaentity().name == "mcl_flowers:item" then
|
||||
obj:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
flower_pot_update_item = function(pos, node)
|
||||
flower_pot_remove_item(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta and meta:get_string("item") ~= "" then
|
||||
if node.name == "mcl_flowers:pot" then
|
||||
pos.y = pos.y
|
||||
end
|
||||
flower_tmp.nodename = node.name
|
||||
flower_tmp.texture = ItemStack(meta:get_string("item")):get_name()
|
||||
local e = minetest.add_entity(pos,"mcl_flowers:item")
|
||||
end
|
||||
end
|
||||
|
||||
flower_pot_drop_item = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("item") ~= "" then
|
||||
if node.name == "mcl_flowers:pot" then
|
||||
minetest.add_item({x=pos.x,y=pos.y+1,z=pos.z}, meta:get_string("item"))
|
||||
end
|
||||
meta:set_string("item","")
|
||||
end
|
||||
flower_pot_remove_item(pos, node)
|
||||
end
|
391
mods/mcl_flowers/init.lua
Normal file
|
@ -0,0 +1,391 @@
|
|||
-- Minetest 0.4 mod: default
|
||||
-- See README.txt for licensing and other information.
|
||||
local init = os.clock()
|
||||
flower_tmp={}
|
||||
|
||||
|
||||
-- Map Generation
|
||||
dofile(minetest.get_modpath("mcl_flowers").."/mapgen.lua")
|
||||
dofile(minetest.get_modpath("mcl_flowers").."/func.lua")
|
||||
|
||||
|
||||
|
||||
-------------------------------
|
||||
--- Fleur Simple (une case) ---
|
||||
-------------------------------
|
||||
|
||||
|
||||
local function add_simple_flower(name, desc, image, color)
|
||||
minetest.register_node("mcl_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 = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,dig_by_water=1,color=1,deco_block=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
buildable_to = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
add_simple_flower("poppy", "Poppy", "mcl_flowers_poppy", "color_red")
|
||||
add_simple_flower("dandelion", "Dandelion", "flowers_dandelion_yellow", "color_yellow")
|
||||
add_simple_flower("oxeye_daisy", "Oxeye Daisy", "mcl_flowers_oxeye_daisy", "color_yellow")
|
||||
add_simple_flower("tulip_orange", "Orange Tulip", "flowers_tulip", "color_orange")
|
||||
|
||||
minetest.register_node("mcl_flowers:tulip_pink", {
|
||||
description = "Pink Tulip",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcl_flowers_tulip_pink.png" },
|
||||
inventory_image = "mcl_flowers_tulip_pink.png",
|
||||
wield_image = "mcl_flowers_tulip_pink.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,color_pink=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
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("mcl_flowers:tulip_red", {
|
||||
description = "Red Tulip",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcl_flowers_tulip_red.png" },
|
||||
inventory_image = "mcl_flowers_tulip_red.png",
|
||||
wield_image = "mcl_flowers_tulip_red.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,color_red=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
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("mcl_flowers:tulip_white", {
|
||||
description = "White Tulip",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcl_flowers_tulip_white.png" },
|
||||
inventory_image = "mcl_flowers_tulip_white.png",
|
||||
wield_image = "mcl_flowers_tulip_white.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,color_white=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
--- allium ---
|
||||
|
||||
minetest.register_node("mcl_flowers:allium", {
|
||||
description = "Allium",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcl_flowers_allium.png" },
|
||||
inventory_image = "mcl_flowers_allium.png",
|
||||
wield_image = "mcl_flowers_allium.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,color_pink=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
|
||||
--- peony ---
|
||||
|
||||
minetest.register_node("mcl_flowers:peony", {
|
||||
description = "Peony",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcl_flowers_peony.png" },
|
||||
inventory_image = "mcl_flowers_peony.png",
|
||||
wield_image = "mcl_flowers_peony.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,color_pink=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
--- azure bluet ---
|
||||
|
||||
minetest.register_node("mcl_flowers:azure_bluet", {
|
||||
description = "Azure Bluet",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcl_flowers_azure_bluet.png" },
|
||||
inventory_image = "mcl_flowers_azure_bluet.png",
|
||||
wield_image = "mcl_flowers_azure_bluet.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,color_white=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
|
||||
---blue_orchid ---
|
||||
|
||||
minetest.register_node("mcl_flowers:blue_orchid", {
|
||||
description = "Blue Orchid",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcl_flowers_blue_orchid.png" },
|
||||
inventory_image = "mcl_flowers_blue_orchid.png",
|
||||
wield_image = "mcl_flowers_blue_orchid.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,color_blue=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
})
|
||||
|
||||
--- Fern ---
|
||||
|
||||
minetest.register_node("mcl_flowers:fern", {
|
||||
description = "Fern",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcl_flowers_fern.png" },
|
||||
inventory_image = "mcl_flowers_fern.png",
|
||||
wield_image = "mcl_flowers_fern.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,dig_by_water=1,deco_block=1},
|
||||
buildable_to = true,
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
|
||||
},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'farming:wheat_seed'},
|
||||
rarity = 24,
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
function register_large(name, desc, inv_img, bot_img, colr) --change in function
|
||||
minetest.register_node("mcl_flowers:"..name.."_bottom", {
|
||||
description = desc.." Bottom",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "double_plant_"..name.."_bottom.png" },
|
||||
inventory_image = "flowers_"..inv_img..".png",
|
||||
wield_image = "flowers_"..inv_img..".png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
--[[
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
pointed_thing.under = pointed_thing.under-1
|
||||
local name = minetest.get_node({x=pointed_thing.under, y=pointed_thing.under-1, z=pointed_thing.under}).name
|
||||
if minetest.get_item_group(name, "soil") ~= 0 then
|
||||
pointed_thing.under = pointed_thing.under+1
|
||||
local height = 0
|
||||
while minetest.get_node(pointed_thing.under).name == "mcl_flowers:"..name.."_bottom" and height < 2 do
|
||||
height = height+1
|
||||
pointed_thing.under = pointed_thing.under+1
|
||||
end
|
||||
if height <2 then
|
||||
if minetest.get_node(pointed_thing.under).name == "air" then
|
||||
minetest.set_node(pointed_thing.under, {name="mcl_flowers:"..name.."_top"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
]]
|
||||
drop = "mcl_flowers:"..name,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,colr=1, dig_by_water=1, double_bottom =1,deco_block=1,deco_block=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 },
|
||||
},
|
||||
})
|
||||
|
||||
-- Top
|
||||
minetest.register_node("mcl_flowers:"..name.."_top", {
|
||||
description = desc.." Top",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "double_plant_"..name.."_top.png" },
|
||||
inventory_image = "double_plant_"..inv_img.."_top.png",
|
||||
wield_image = "double_plant_"..inv_img.."_top.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
drop = "mcl_flowers:"..name,
|
||||
groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,colr=1, dig_by_water=1, not_in_creative_inventory = 1, double_top =1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 },
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Flower Pot
|
||||
--
|
||||
|
||||
minetest.register_node("mcl_flowers:pot",{
|
||||
description = "Flower Pot",
|
||||
drawtype = "nodebox",
|
||||
is_ground_content = false,
|
||||
node_box = { type = "fixed", fixed = {
|
||||
{-0.125,-0.125,-0.187500,-0.187500,-0.500,0.1875}, --Wall 1
|
||||
{0.1875,-0.125,-0.125,0.125,-0.500,0.1875}, --Wall 2
|
||||
{-0.1875,-0.125,-0.125,0.1875,-0.500,-0.1875}, --Wall 3
|
||||
{0.1875,-0.125,0.125,-0.1875,-0.500,0.1875}, --Wall 4
|
||||
{-0.125,-0.500,-0.125,0.125,-0.250,0.125}, --Dirt 5
|
||||
}},
|
||||
selection_box = { type = "fixed", fixed = {-0.125,-0.5,-0.125,0.125,-0.25,0.125 }},
|
||||
tiles = {"flowers_pot_top.png", "flowers_pot_bottom.png", "flowers_pot_top.png"},
|
||||
inventory_image="flowers_pot_inventory.png",
|
||||
paramtype = "light",
|
||||
groups = {dig_immediate=3,deco_block=1},
|
||||
stack_max = 64,
|
||||
sounds = default.node_sound_defaults(),
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner",placer:get_player_name())
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if not itemstack then return end
|
||||
local meta = minetest.get_meta(pos)
|
||||
if clicker:get_player_name() == meta:get_string("owner") then
|
||||
flower_pot_drop_item(pos,node)
|
||||
local s = itemstack:take_item()
|
||||
meta:set_string("item",s:to_string())
|
||||
flower_pot_update_item(pos,node)
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
on_punch = function(pos,node,puncher)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if puncher:get_player_name() == meta:get_string("owner") then
|
||||
flower_pot_drop_item(pos,node)
|
||||
end
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return player:get_player_name() == meta:get_string("owner")
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
flower_pot_drop_item(pos,node)
|
||||
minetest.add_node(pos, {name="air"})
|
||||
minetest.add_item(pos, "mcl_flowers:pot")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Lily Pad
|
||||
minetest.register_node("mcl_flowers:waterlily", {
|
||||
description = "Lily Pad",
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"flowers_waterlily.png", "flowers_waterlily.png"},
|
||||
inventory_image = "flowers_waterlily.png",
|
||||
wield_image = "flowers_waterlily.png",
|
||||
liquids_pointable = true,
|
||||
walkable = true,
|
||||
sunlight_propagates = true,
|
||||
groups = {dig_immediate = 3, dig_by_water = 1, deco_block=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
node_placement_prediction = "",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -15 / 32, 0.5}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, -15 / 32, 7 / 16}
|
||||
},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.above
|
||||
local node = minetest.get_node(pointed_thing.under).name
|
||||
local def = minetest.registered_nodes[node]
|
||||
local node_above = minetest.get_node(pointed_thing.above).name
|
||||
local def_above = minetest.registered_nodes[node_above]
|
||||
local player_name = placer:get_player_name()
|
||||
|
||||
if def and
|
||||
pointed_thing.under.x == pointed_thing.above.x and
|
||||
pointed_thing.under.z == pointed_thing.above.z then
|
||||
if ((def.liquidtype == "source" and minetest.get_item_group(node, "water") > 0) or
|
||||
(node == "default:ice") or
|
||||
(minetest.get_item_group(node, "frosted_ice") > 0)) and
|
||||
(def_above.buildable_to and minetest.get_item_group(node_above, "liquid") == 0) then
|
||||
if not minetest.is_protected(pos, player_name) then
|
||||
minetest.set_node(pos, {name = "mcl_flowers:waterlily",
|
||||
param2 = math.random(0, 3)})
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player_name, "Node is protected")
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
local time_to_load= os.clock() - init
|
||||
print(string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load))
|
108
mods/mcl_flowers/mapgen.lua
Normal file
|
@ -0,0 +1,108 @@
|
|||
minetest.register_alias("mapgen_dandelion", "mcl_flowers:dandelion_yellow")
|
||||
minetest.register_alias("mapgen_rose", "mcl_flowers:rose")
|
||||
|
||||
minetest.register_alias("mapgen_oxeye_daisy", "mcl_flowers:oxeye_daisy")
|
||||
|
||||
minetest.register_alias("mapgen_tulip_orange", "mcl_flowers:tulip_orange")
|
||||
minetest.register_alias("mapgen_tulip_pink", "mcl_flowers:tulip_pink")
|
||||
minetest.register_alias("mapgen_tulip_red", "mcl_flowers:tulip_red")
|
||||
minetest.register_alias("mapgen_tulip_white", "mcl_flowers:tulip_white")
|
||||
|
||||
minetest.register_alias("mapgen_allium", "mcl_flowers:allium")
|
||||
|
||||
minetest.register_alias("mapgen_paeonia", "mcl_flowers:paeonia")
|
||||
|
||||
minetest.register_alias("mapgen_houstonia", "mcl_flowers:houstonia")
|
||||
|
||||
minetest.register_alias("mapgen_blue_orchid", "mcl_flowers:blue_orchid")
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
if maxp.y >= 3 and minp.y <= 0 then
|
||||
-- Generate flowers
|
||||
local perlin1 = minetest.get_perlin(436, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine flowers amount from perlin noise
|
||||
local grass_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 9)
|
||||
-- Find random positions for flowers based on this random
|
||||
local pr = PseudoRandom(seed+456)
|
||||
for i=0,grass_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if ground_y then
|
||||
local p = {x=x,y=ground_y+1,z=z}
|
||||
local nn = minetest.get_node(p).name
|
||||
-- Check if the node can be replaced
|
||||
if minetest.registered_nodes[nn] and
|
||||
minetest.registered_nodes[nn].buildable_to then
|
||||
nn = minetest.get_node({x=x,y=ground_y,z=z}).name
|
||||
if nn == "default:dirt_with_grass" then
|
||||
--local flower_choice = pr:next(1, 11)
|
||||
local flower_choice = math.random(0, 11)
|
||||
local flower = "default:grass"
|
||||
if flower_choice == 1 then
|
||||
flower = "mcl_flowers:dandelion_yellow"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 2 then
|
||||
flower = "mcl_flowers:rose"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 3 then
|
||||
flower = "mcl_flowers:oxeye_daisy"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 4 then
|
||||
flower = "mcl_flowers:tulip_orange"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 5 then
|
||||
flower = "mcl_flowers:tulip_pink"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 6 then
|
||||
flower = "mcl_flowers:tulip_red"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 7 then
|
||||
flower = "mcl_flowers:tulip_white"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 8 then
|
||||
flower = "mcl_flowers:allium"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 9 then
|
||||
flower = "mcl_flowers:paeonia"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 10 then
|
||||
flower = "mcl_flowers:houstonia"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 11 then
|
||||
flower = "mcl_flowers:blue_orchid"
|
||||
minetest.set_node(p, {name=flower})
|
||||
elseif flower_choice == 12 then
|
||||
flower = "mcl_flowers:fern"
|
||||
minetest.set_node(p, {name=flower})
|
||||
else
|
||||
flower = "default:grass"
|
||||
minetest.set_node(p, {name=flower})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
BIN
mods/mcl_flowers/textures/flowers_dandelion_yellow.png
Normal file
After Width: | Height: | Size: 192 B |
BIN
mods/mcl_flowers/textures/flowers_pot_bottom.png
Normal file
After Width: | Height: | Size: 311 B |
BIN
mods/mcl_flowers/textures/flowers_pot_inventory.png
Normal file
After Width: | Height: | Size: 627 B |
BIN
mods/mcl_flowers/textures/flowers_pot_top.png
Normal file
After Width: | Height: | Size: 460 B |
BIN
mods/mcl_flowers/textures/flowers_rose.png
Normal file
After Width: | Height: | Size: 220 B |
BIN
mods/mcl_flowers/textures/flowers_tulip.png
Normal file
After Width: | Height: | Size: 436 B |
BIN
mods/mcl_flowers/textures/flowers_waterlily.png
Normal file
After Width: | Height: | Size: 520 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_allium.png
Normal file
After Width: | Height: | Size: 273 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_azure_bluet.png
Normal file
After Width: | Height: | Size: 225 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_blue_orchid.png
Normal file
After Width: | Height: | Size: 255 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_fern.png
Normal file
After Width: | Height: | Size: 301 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_oxeye_daisy.png
Normal file
After Width: | Height: | Size: 430 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_peony.png
Normal file
After Width: | Height: | Size: 336 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_poppy.png
Normal file
After Width: | Height: | Size: 302 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_tulip_pink.png
Normal file
After Width: | Height: | Size: 424 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_tulip_red.png
Normal file
After Width: | Height: | Size: 414 B |
BIN
mods/mcl_flowers/textures/mcl_flowers_tulip_white.png
Normal file
After Width: | Height: | Size: 435 B |