version 0.21

This commit is contained in:
davedevils 2015-06-29 19:55:56 +02:00
parent bd1233aaf1
commit c8d70b992c
1717 changed files with 68882 additions and 0 deletions

12
mods/flowers/README.txt Normal file
View 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/flowers/credit.txt Normal file
View file

@ -0,0 +1,8 @@
Credit to people who made things.
jojoa1997:
-edited all of it
-flower pot
VanessaE:
-waterlily

1
mods/flowers/depends.txt Normal file
View file

@ -0,0 +1 @@
default

81
mods/flowers/func.lua Normal file
View file

@ -0,0 +1,81 @@
minetest.register_entity("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 == "flowers:pot" then
objs = minetest.env: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 == "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.env:get_meta(pos)
if meta and meta:get_string("item") ~= "" then
if node.name == "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.env:add_entity(pos,"flowers:item")
end
end
flower_pot_drop_item = function(pos, node)
local meta = minetest.env:get_meta(pos)
if meta:get_string("item") ~= "" then
if node.name == "flowers:pot" then
minetest.env: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

364
mods/flowers/init.lua Normal file
View file

@ -0,0 +1,364 @@
-- Minetest 0.4 mod: default
-- See README.txt for licensing and other information.
flower_tmp={}
-- Map Generation
dofile(minetest.get_modpath("flowers").."/mapgen.lua")
dofile(minetest.get_modpath("flowers").."/func.lua")
-------------------------------
--- Fleur Simple (une case) ---
-------------------------------
local function add_simple_flower(name, desc, image, color)
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 = 64,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color=1},
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("rose", "Coqlicot", "flowers_coqlicot", "color_red")
--add_simple_flower("rose", "Rose", "flowers_rose", "color_red") -- Old skin :( you miss me
add_simple_flower("dandelion_yellow", "Yellow Dandelion", "flowers_dandelion_yellow", "color_yellow")
add_simple_flower("oxeye_daisy", "Oxeye Daisy", "flower_oxeye_daisy", "color_yellow")
add_simple_flower("tulip_orange", "Orange Tulip", "flower_tulip_orange", "color_orange")
minetest.register_node("flowers:tulip_pink", {
description = "Pink Tulip",
drawtype = "plantlike",
tiles = { "flower_tulip_pink.png" },
inventory_image = "flower_tulip_pink.png",
wield_image = "flower_tulip_pink.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 64,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_pink=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:tulip_red", {
description = "Red Tulip",
drawtype = "plantlike",
tiles = { "flower_tulip_red.png" },
inventory_image = "flower_tulip_red.png",
wield_image = "flower_tulip_red.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 64,
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.2, 0.15 },
},
})
minetest.register_node("flowers:tulip_white", {
description = "White Tulip",
drawtype = "plantlike",
tiles = { "flower_tulip_white.png" },
inventory_image = "flower_tulip_white.png",
wield_image = "flower_tulip_white.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 64,
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.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
--- allium ---
minetest.register_node("flowers:allium", {
description = "Allium",
drawtype = "plantlike",
tiles = { "flower_allium.png" },
inventory_image = "flower_allium.png",
wield_image = "flower_allium.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 64,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_pink=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
--- paeonia ---
minetest.register_node("flowers:paeonia", {
description = "Paeonia",
drawtype = "plantlike",
tiles = { "flower_paeonia.png" },
inventory_image = "flower_paeonia.png",
wield_image = "flower_paeonia.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 64,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_pink=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
--- houstonia ---
minetest.register_node("flowers:houstonia", {
description = "Houstonia",
drawtype = "plantlike",
tiles = { "flower_houstonia.png" },
inventory_image = "flower_houstonia.png",
wield_image = "flower_houstonia.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 64,
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.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
---blue_orchid ---
minetest.register_node("flowers:blue_orchid", {
description = "Blue Orchid",
drawtype = "plantlike",
tiles = { "flower_blue_orchid.png" },
inventory_image = "flower_blue_orchid.png",
wield_image = "flower_blue_orchid.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 64,
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 },
},
})
--- Fern ---
minetest.register_node("flowers:fern", {
description = "Fern",
drawtype = "plantlike",
tiles = { "fern.png" },
inventory_image = "fern.png",
wield_image = "fern.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 64,
groups = {snappy=3,flammable=2,flower=1,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
function register_large(name, desc, inv_img, bot_img, colr) --change in function
minetest.register_node("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 == "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="flowers:"..name.."_top"})
end
end
end
end,
]]
drop = "flowers:"..name,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,colr=1, dig_by_water=1, double_bottom =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("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 = "flowers:"..name,
groups = {snappy=3,flammable=2,flower=1,flora=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
-----------------------------
--- Generation terrin ----
-----------------------------
minetest.register_abm({
nodenames = {"group:flora"},
neighbors = {"default:dirt_with_grass", "default:sand"},
interval = 40,
chance = 20,
action = function(pos, node)
pos.y = pos.y - 1
local under = minetest.get_node(pos)
pos.y = pos.y + 1
if under.name == "default:sand" then
minetest.set_node(pos, {name="default:dry_shrub"})
elseif under.name ~= "default:sand" then
return
end
local light = minetest.get_node_light(pos)
if not light or light < 10 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}
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,
})
--
-- Flower Pot
--
minetest.register_node("flowers:pot",{
description = "Flower Pot",
drawtype = "nodebox",
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 = {snappy=3},
stack_max = 16,
sounds = default.node_sound_defaults(),
after_place_node = function(pos, placer, itemstack)
local meta = minetest.env: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.env: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.env: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.env: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.env:add_node(pos, {name="air"})
minetest.env:add_item(pos, "flowers:pot")
end,
})

108
mods/flowers/mapgen.lua Normal file
View file

@ -0,0 +1,108 @@
minetest.register_alias("mapgen_dandelion", "flowers:dandelion_yellow")
minetest.register_alias("mapgen_rose", "flowers:rose")
minetest.register_alias("mapgen_oxeye_daisy", "flowers:oxeye_daisy")
minetest.register_alias("mapgen_tulip_orange", "flowers:tulip_orange")
minetest.register_alias("mapgen_tulip_pink", "flowers:tulip_pink")
minetest.register_alias("mapgen_tulip_red", "flowers:tulip_red")
minetest.register_alias("mapgen_tulip_white", "flowers:tulip_white")
minetest.register_alias("mapgen_allium", "flowers:allium")
minetest.register_alias("mapgen_paeonia", "flowers:paeonia")
minetest.register_alias("mapgen_houstonia", "flowers:houstonia")
minetest.register_alias("mapgen_blue_orchid", "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 = "flowers:dandelion_yellow"
minetest.set_node(p, {name=flower})
elseif flower_choice == 2 then
flower = "flowers:rose"
minetest.set_node(p, {name=flower})
elseif flower_choice == 3 then
flower = "flowers:oxeye_daisy"
minetest.set_node(p, {name=flower})
elseif flower_choice == 4 then
flower = "flowers:tulip_orange"
minetest.set_node(p, {name=flower})
elseif flower_choice == 5 then
flower = "flowers:tulip_pink"
minetest.set_node(p, {name=flower})
elseif flower_choice == 6 then
flower = "flowers:tulip_red"
minetest.set_node(p, {name=flower})
elseif flower_choice == 7 then
flower = "flowers:tulip_white"
minetest.set_node(p, {name=flower})
elseif flower_choice == 8 then
flower = "flowers:allium"
minetest.set_node(p, {name=flower})
elseif flower_choice == 9 then
flower = "flowers:paeonia"
minetest.set_node(p, {name=flower})
elseif flower_choice == 10 then
flower = "flowers:houstonia"
minetest.set_node(p, {name=flower})
elseif flower_choice == 11 then
flower = "flowers:blue_orchid"
minetest.set_node(p, {name=flower})
elseif flower_choice == 12 then
flower = "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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B