Page 1 of 2
[Mod] Plants [3.5][plants]

Posted:
Tue Jul 31, 2012 03:31
by Bas080
Includes plants that spawn in
specific habitats!Possibilities- Mine the plants till they drop seeds for farming mod (unless it is a plant that can be picked up)
- Pick flowers and make a garden
- Enjoy the colors in the landscape.
- Find coals or iron by looking for coals flowers.





ChangelogDependshabitatDownloadhttps://github.com/bas080/plants/zipball/masteror see code https://github.com/bas080/plantsLicenseWTFPL for LUA and PNG files

Posted:
Tue Jul 31, 2012 09:43
by PilzAdam
Great!! Keep this up!!
Suggestion: make the plants spawn on map generation and not with an abm.

Posted:
Tue Jul 31, 2012 09:47
by Lippis
Looks cool. I need to test right now :)

Posted:
Tue Jul 31, 2012 12:35
by Topywo
Nice new plants!
When I start, minetest creates dummies for the cotton seeds, seedling and sapling
I think all the plants appeared
Unfortunately when I harvest them, they don't go into my inventory.
Harvesting doesn't make sound
But I still like this mod :-)

Posted:
Wed Aug 01, 2012 00:10
by Bas080
Topywo and Lippis:
Thnx, stay tuned for many updates. :)
PilzAdam:
I would love to make it spawn in map generation. That would improve performance allot. Can you point me to an example? .... However I also like that the plants grow again in the same area after having dug them. I don't think that would be possible without abm's. We could improve performance by reducing the amount of nodes being abm'd by making invisible plant-spawning nodes at map generation. And performing abm's on them. Avoiding abm-ing on all dirt_with_grass nodes...
Or is it possible to make code perform several seconds later. In that case you could dig the node on plant node dig you could set a timer that would trigger a function that adds a plant in the same-ish area. So is there a function with which you can set a time before a function performs?

Posted:
Wed Aug 01, 2012 00:51
by mauvebic
You might be better using 1 ABM with a random function than seperate ABMs for each type of plant to place. and you can use after_dig_node in your node definition to place a new plant /seedling upon harvest. :-)

Posted:
Wed Aug 01, 2012 08:21
by PilzAdam
Bas080 wrote:PilzAdam:
I would love to make it spawn in map generation. That would improve performance allot. Can you point me to an example? .... However I also like that the plants grow again in the same area after having dug them. I don't think that would be possible without abm's. We could improve performance by reducing the amount of nodes being abm'd by making invisible plant-spawning nodes at map generation. And performing abm's on them. Avoiding abm-ing on all dirt_with_grass nodes...
Or is it possible to make code perform several seconds later. In that case you could dig the node on plant node dig you could set a timer that would trigger a function that adds a plant in the same-ish area. So is there a function with which you can set a time before a function performs?
1. I would like it if they would not appear again in one area.
2. There is a timer function:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.after(2, function([param])
end, [param])
This will be called after 2 sec. You can leave [param] out if you dont need one or make a table if you want more than one.

Posted:
Fri Aug 03, 2012 13:17
by Bas080
PilzAdam, I used your feedback and implemented it into the mod. Now harvest mod spawns plants on map generation. Tested it and it sure works faster better and with less lag. It does take a bit longer for the maps to generate. Please share your own experience.
Plz move me to mod releases. (plz help me with sounds, i can't get that to work)
I look forward to more feedback and ideas for plants and crops.

Posted:
Fri Aug 03, 2012 13:42
by PilzAdam
Some suggestions:
- Add descriptions to all items that you can have in your inventory.
- Increase the chance to get seeds.
- Make the seeds only placeable on soil.
Some code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_craft({
output = 'harvets:hoe_wood',
recipe = {
{"default:wood", "default:wood"},
{"", "default:stick"},
{"", "default:stick"},
},
})
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_abm({
nodenames = {"harvest:corn_seedling"},
interval = 60,
chance = 2,
action = function(pos, node)
if find_node_near(pos, 10, "default:water_source") ~= nil then
node.name = "harvest:corn_seedling"
minetest.env:set_node(pos, node)
end
end
})
Hope this code helps a bit (not testet).

Posted:
Fri Aug 03, 2012 14:15
by Bas080
PilzAdam wrote:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_abm({
nodenames = {"harvest:corn_seedling"},
interval = 60,
chance = 2,
action = function(pos, node)
if find_node_near(pos, 10, "default:water_source") ~= nil then
node.name = "harvest:corn_seedling"
minetest.env:set_node(pos, node)
end
end
})
If I where to do it like that, then it would only work for the corn. It has to be dynamic. With which I mean that it should be possible to turn the cotton into a farming plant without having to make a new abm for cotton. I was thinking to abm the worked soil, adding farm-able plants to an array and checking if the node on top of the soil is part of that farm plants array. If so make it evolve to next level farming node till it's the harvestable node type which gives corn or cotton and some seeds when dug.
EDIT:
Other feedback has been implemented except the only placeable on soil. Still thinking about how to do that.

Posted:
Fri Aug 03, 2012 14:16
by PilzAdam
Bas080 wrote:PilzAdam wrote:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_abm({
nodenames = {"harvest:corn_seedling"},
interval = 60,
chance = 2,
action = function(pos, node)
if find_node_near(pos, 10, "default:water_source") ~= nil then
node.name = "harvest:corn_seedling"
minetest.env:set_node(pos, node)
end
end
})
If I where to do it like that, then it would only work for the corn. It has to be dynamic. With which I mean that it should be possible to turn the cotton into a farming plant without having to make a new abm for cotton. I was thinking to abm the worked soil, adding farm-able plants to an array and checking if the node on top of the soil is part of that farm plants array. If so make it evolve to next level farming node till it's the harvestable node type which gives corn or cotton and some seeds when dug.
I guessed that you want to do it this way. Its better.

Posted:
Tue Aug 21, 2012 02:59
by Bas080
Big changes to the code and concept. Removed farming ideas. PilzAdam has made separate farming mod which i find better to keep separated. I would however like to see that this mod's plants provide seeds for PilzAdam's farming mod. Still have to think about how to implement seeds from this mod in the farming mod.
Further changes include sound added and some code cleanup.

Posted:
Tue Aug 21, 2012 10:49
by PilzAdam
Bas080 wrote:Big changes to the code and concept. Removed farming ideas. PilzAdam has made separate farming mod which i find better to keep separated. I would however like to see that this mod's plants provide seeds for PilzAdam's farming mod. Still have to think about how to implement seeds from this mod in the farming mod.
Further changes include sound added and some code cleanup.
When you add farming to dependecies you can change the drop from the plants to
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
farming:wheat_seed
farming:cotton_seed
farming:pumpkin_seed
Then the seeds can be planted and grow. I can also add some plants from your mod to my mod, when you provide textures.

Posted:
Tue Aug 21, 2012 11:53
by tonyka
I get the following error:
AL lib: pulseaudio.c:612: Context did not connect: Access denied
13:49:14: ERROR[main]: ========== ERROR FROM LUA ===========
13:49:14: ERROR[main]: Failed to load and run script from
13:49:14: ERROR[main]: /usr/share/minetest/games/avatar/mods/harvest/init.lua:
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:85: attempt to call field 'node_sound_leaves_default' (a nil value)
13:49:14: ERROR[main]: stack traceback:
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:85: in function 'add_plant'
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:106: in main chunk
13:49:14: ERROR[main]: =======END OF ERROR FROM LUA ========
13:49:14: ERROR[main]: Server: Failed to load and run /usr/share/minetest/games/avatar/mods/harvest/init.lua
13:49:14: ERROR[main]: ModError: Failed to load and run /usr/share/minetest/games/avatar/mods/harvest/init.lua

Posted:
Tue Aug 21, 2012 12:05
by PilzAdam
tonyka wrote:I get the following error:
AL lib: pulseaudio.c:612: Context did not connect: Access denied
13:49:14: ERROR[main]: ========== ERROR FROM LUA ===========
13:49:14: ERROR[main]: Failed to load and run script from
13:49:14: ERROR[main]: /usr/share/minetest/games/avatar/mods/harvest/init.lua:
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:85: attempt to call field 'node_sound_leaves_default' (a nil value)
13:49:14: ERROR[main]: stack traceback:
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:85: in function 'add_plant'
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:106: in main chunk
13:49:14: ERROR[main]: =======END OF ERROR FROM LUA ========
13:49:14: ERROR[main]: Server: Failed to load and run /usr/share/minetest/games/avatar/mods/harvest/init.lua
13:49:14: ERROR[main]: ModError: Failed to load and run /usr/share/minetest/games/avatar/mods/harvest/init.lua
Add a file called depends.txt to the mod folder and add default in the first line.

Posted:
Tue Aug 21, 2012 14:04
by tonyka
PilzAdam wrote:tonyka wrote:I get the following error:
AL lib: pulseaudio.c:612: Context did not connect: Access denied
13:49:14: ERROR[main]: ========== ERROR FROM LUA ===========
13:49:14: ERROR[main]: Failed to load and run script from
13:49:14: ERROR[main]: /usr/share/minetest/games/avatar/mods/harvest/init.lua:
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:85: attempt to call field 'node_sound_leaves_default' (a nil value)
13:49:14: ERROR[main]: stack traceback:
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:85: in function 'add_plant'
13:49:14: ERROR[main]: ...sr/share/minetest/games/avatar/mods/harvest/init.lua:106: in main chunk
13:49:14: ERROR[main]: =======END OF ERROR FROM LUA ========
13:49:14: ERROR[main]: Server: Failed to load and run /usr/share/minetest/games/avatar/mods/harvest/init.lua
13:49:14: ERROR[main]: ModError: Failed to load and run /usr/share/minetest/games/avatar/mods/harvest/init.lua
Add a file called depends.txt to the mod folder and add default in the first line.
fixed, I changed the name of the mod folder ...
harvest => Plants
Now I see the little plants in the world ...
should include a folder with the name of the mod and the mod in, would save a lot of headaches ...

Posted:
Tue Aug 21, 2012 15:39
by tonyka
hehe
I is great for my game mode ...
this already looks a bit more to the planet Pandora (Avatar)...
only I have to change the textures ...



Posted:
Tue Aug 21, 2012 15:42
by Spots
tonyka wrote:hehe
I is great for my game mode ...
this already looks a bit more to the planet Pandora (Avatar)...
only I have to change the textures ...


nice what texture pack are you using i would love to check it out

Posted:
Tue Aug 21, 2012 15:59
by tonyka
Spots wrote:nice what texture pack are you using i would love to check it out
I'm changing the textures of the game, with gimp ...
ideas as I come ...
I can upload the project to GitHub ...
but do not think they finalize ... this is just to hang out ...
I dont know how to create biomes, and many other things ...

Posted:
Wed Aug 22, 2012 08:58
by Bas080
Tonyka, not a bad idea making the plants give light. Maybe I’ll make plants series called luminescence plants.
Spots, I agree. The textures of tonyka look nice. I would like to see them for myself too. Plz share :)

Posted:
Thu Aug 23, 2012 13:08
by tonyka
Bas080 wrote:Tonyka, not a bad idea making the plants give light. Maybe I’ll make plants series called luminescence plants.
Spots, I agree. The textures of tonyka look nice. I would like to see them for myself too. Plz share :)
ok, I created a post for the game mode ...
http://minetest.net/forum/viewtopic.php?id=2845

Posted:
Sun Sep 23, 2012 11:35
by Alfino
Hello Bas080,
I was tweaking your mods so its can drops seed, unfortunately its give init.lua error.
here's the code :
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
--Harvest
--A simple farming mod
--A extended plant spawning mod
--register alias to avoid unknown plants from previous harvest version
--Variable and function definitions
local mod_name = "harvest"
local wild_crops = {}
local wild_crop_count = 0
local add_plant = function(name_plant) -- register a wild plant
local name = mod_name..":"..name_plant
local img = mod_name.."_"..name_plant
minetest.register_node(name.."_wild", {--register wild plant
tile_images = {img.."_wild.png"},
inventory_image = img.."_wild.png",
description = name_plant,
drawtype = "plantlike",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = { snappy = 3,flammable=2 },
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("harvest:wheat_wild", {
paramtype = "light",
walkable = false,
drawtype = "plantlike",
tiles = {"harvest_wheat_wild.png"},
drop = {
max_items = 4,
items = {
{ items = {'farming:wheat_seed'} },
{ items = {'farming:wheat_seed'}, rarity = 2},
{ items = {'farming:wheat_seed'}, rarity = 5},
{ items = {'farming:wheat_harvested'} }
}
},
groups = {snappy=3, flammable=2},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("harvest:brownshroom_wild",
tile_images = {"harvest_brownshroom_wild.png"},
inventory_image = "harvest_brownshroom_wild.png",
description = name_plant,
drawtype = "plantlike",
light_propagates = true,
sunlight_propagates = true,
paramtype = "light",
` light_source = 12,
walkable = false,
groups = { snappy = 3,flammable=2 },
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("harvest:redshroom_wild",
tile_images = {"harvest_redshroom_wild.png"},
inventory_image = "harvest_redshroom_wild.png",
description = name_plant,
drawtype = "plantlike",
light_propagates = true,
sunlight_propagates = true,
paramtype = "light",
` light_source = 12,
walkable = false,
groups = { snappy = 3,flammable=2 },
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("harvest:cotton_wild", {
paramtype = "light",
walkable = false,
drawtype = "plantlike",
tiles = {"harvest_cotton_wild.png"},
drop = {
max_items = 6,
items = {
{ items = {'farming:cotton_seed'} },
{ items = {'farming:cotton_seed'}, rarity = 2},
{ items = {'farming:cotton_seed'}, rarity = 5},
{ items = {'farming:string'} },
{ items = {'farming:string'}, rarity = 2 },
{ items = {'farming:string'}, rarity = 5 }
}
},
groups = {snappy=3, flammable=2},
sounds = default.node_sound_leaves_defaults(),
})
end
--plant registration
--Just wild plant
--node registration
minetest.register_alias("harvest:lavender_wild", "plants:lavender_wild")
minetest.register_alias("harvest:redshroom_wild", "plants:redshroom_wild")
minetest.register_alias("harvest:wheat_wild", "plants:wheat_wild")
minetest.register_alias("harvest:cotton_wild", "plants:cotton_wild")
minetest.register_alias("harvest:brownshroom_wild", "plants:brownshroom_wild")
minetest.register_alias("harvest:chamomile_wild", "plants:chamomile_wild")
minetest.register_alias("harvest:colchicum_wild", "plants:colchicum_wild")
minetest.register_alias("harvest:poppy_wild", "plants:poppy_wild")
minetest.register_alias("harvest:grasstall_wild", "plants:grasstall_wild")
minetest.register_alias("harvest:grass_wild", "plants:grass_wild")
--Make node in which dirt changes after hoe preperation
--create plant nodes. Not all plants spawn in the wild for this you have to define it on the generate on function
add_plant("cotton")
add_plant("wheat")
add_plant("lavender")
add_plant("potato")
add_plant("redshroom")
add_plant("cacao")
add_plant("brownshroom")
add_plant("chamomile")
add_plant("colchicum")
add_plant("poppy")
add_plant("grasstall")
add_plant("grass")
--generate(node, surface, minp, maxp, height_min, height_max, spread, habitat_size, habitat_nodes)
--For the plants that do spawn on the lang we have the generate function. This makes sure that plants are placed when new peaces of the level are loaded.
minetest.register_on_generated(function(minp, maxp, seed)
generate("harvest:lavender_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 60, 4, 4, {"default:sand"},0,{""})
generate("harvest:redshroom_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 60, 20, 8, {"default:leaves"},0,{""})
generate("harvest:wheat_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 60, 8, 10, {"default:water_source"},0,{""})
generate("harvest:cotton_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 60, 8, 10, {"default:desert_sand"},0,{""})
generate("harvest:brownshroom_wild", {"default:stone"}, minp, maxp, -40, -10, 2, 10, {"default:water_source"},0,{""})
generate("harvest:chamomile_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 40, 8, 4, {"default:stone_with_coal"},0,{""})
generate("harvest:colchicum_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 40, 4, 10, {"default:stone_with_iron"},0,{""})
generate("harvest:poppy_wild", {"default:desert_sand"}, minp, maxp, -10, 20, 4, 10, {"default:water_source"},0,{""})
generate("harvest:grasstall_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 20, 3, 3, {"default:water_source"},0,{""})
generate("harvest:grass_wild", {"default:dirt_with_grass"}, minp, maxp, -10, 20, 3, 3, {"default:water_source"},0,{""})
end)
print("[Harvest] Loaded!")
i don't know whats wrong with it, could you help me ?

Posted:
Sun Sep 23, 2012 22:15
by Bas080
@Alfino
Good idea, but what are you going to do with the seeds?
I see your code. I see that you added a drop function to some of the nodes. So in this case wheat drops seeds and others don't. Your code is however very redundant(repeats itself unnecessarily). You could make an extra argument for the add_plant function.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local add_plant = function(name_plant, [color=red]has_seeds[/color]) -- register a wild plant
if has_seeds then
define node with drop and seed item.
else
define node without drop
end
end
Let me know if it helped you and please share the reason why you want the seeds feature. If you want to get used to the LUA, I still have a work in progress mod which is the portal mod to which you can contribute. Tip: also use other peoples mods to checkout how they achieved certain features. Have fun modding.

Posted:
Mon Sep 24, 2012 05:48
by Alfino
thx Bas080,
the reason why add seeds,
Combine with PilzAdam's mod so wild plants give seeds
I will try it soon.

Posted:
Tue Mar 19, 2013 16:17
by Bas080
Finally made it support PilzAdam's farming mod. Better late then never.

Posted:
Wed Mar 20, 2013 21:22
by Inocudom
This looks very pretty. Why did you revert back to the habitat mod? How well does habitat work with plants_lib?
The brown mushrooms that appear in the caves only appear near the surface. They don't appear deep underground, though caves would be prettier if they did. Sadly, areas that were generated before the installing of this mod will never have any of its nodes appear in them.

Posted:
Thu Mar 21, 2013 07:37
by Bas080
Inocudom wrote:This looks very pretty. Why did you revert back to the habitat mod? How well does habitat work with plants_lib?
The brown mushrooms that appear in the caves only appear near the surface. They don't appear deep underground, though caves would be prettier if they did. Sadly, areas that were generated before the installing of this mod will never have any of its nodes appear in them.
Habitat does not conflict with plants_lib, They both have a similar function, but for the look I want, habitat still performs better. The mushrooms only spawn near water and till a certain depth. I could make a different kind of plant that spawns deeper. What about a lava-shroom? Glow-shroom is also on the todo list
Only placed on biome generate, :S This is not the only mod that has that "issue". I am not going to use ABM's (cpu reasons).
EDIT: Ty for the compliment ;)

Posted:
Mon Mar 25, 2013 21:58
by Inocudom
Minetest definitely uses more CPU these days, which can cause computers to be overworked. I approve of lava shrooms and glow shrooms. You may want to make it so that the flowers and plants are renewable (a seed system similar to what is seen in PilzAdam's farming mod.)

Posted:
Tue Mar 26, 2013 17:09
by Bas080
Inocudom, the shrooms have been added. You can see them in the screenshots. I will be working on the renewable function shortly. Also will be adding plants that blossom simultaneously. First plant will be the morning-glory.

Posted:
Tue Mar 26, 2013 19:54
by Inocudom
The new shrooms are very beautiful and add beauty to the subterranean world. It is a shame that you are not able to get this mod to work with plants_lib as well as you would want it to. I was thinking that you or someone else could make a version that uses plants_lib while keeping this version for computers with weaker CPUs.