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?
minetest.after(2, function([param])
end, [param])
minetest.register_craft({
output = 'harvets:hoe_wood',
recipe = {
{"default:wood", "default:wood"},
{"", "default:stick"},
{"", "default:stick"},
},
})
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
})
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
})
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.
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.
farming:wheat_seed
farming:cotton_seed
farming:pumpkin_seed
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
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
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.
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 ...
Spots wrote:nice what texture pack are you using i would love to check it out
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 :)
--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!")
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
Combine with PilzAdam's mod so wild plants give seeds
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.
Users browsing this forum: No registered users and 69 guests