master
root 2022-05-27 10:09:52 +02:00
parent b7d83ff175
commit 890065b6ed
24 changed files with 169 additions and 54 deletions

View File

@ -11,6 +11,7 @@ globals = {
"doorz",
"farmz",
"fencez",
"floraz",
"flowerz",
"foodz",
"furnz",

View File

@ -75,7 +75,7 @@ local function open_door(pos, node, clicker, doorz_name)
helper.get_nodedef_field(node_open.name, "buildable_to") or
helper.node_is_air(node_open_pos)
) then
if helper.node_is_air(node_open_pos, "above") then
if helper.node_is_air(node_open_pos, 1) then
local facedir = minetest.dir_to_facedir(open_dir)
local doorz_name_opened = doorz_name.."_opened"
local rotation = meta:get_string("doorz:rotation")

93
mods/floraz/api.lua Normal file
View File

@ -0,0 +1,93 @@
--Liana
S, modname = ...
--Constants
local plant_grow_time = 5
function floraz.register_liana(name, def)
local liana_name = modname .. ":" .. name .. "_liana"
minetest.register_node(liana_name, {
description = S(def.desc),
drawtype = "nodebox",
walkable = false,
paramtype = "light",
paramtype2 = "facedir",
tiles = {modname.."_"..name.."_liana.png"},
inventory_image = def.inventory_image or def.tile,
wield_image = def.wield_imagew or def.inventory_image or def.tile,
use_texture_alpha = "clip",
node_box = helper.nodebox.flat_v,
groups = {
snappy = 2, flammable = 3, oddly_breakable_by_hand = 3, choppy = 2, carpet = 1, leafdecay = 3, leaves = 1,
},
sounds = sound.leaves()
})
end
--Growing Plants
local function check_soil(pos, offset, extra_soil_group)
if helper.node_is_soil(pos, offset) then
return true
else
if extra_soil_group then
if helper.in_group(vector.new(pos.x, pos.y+offset, pos.z), extra_soil_group) then
return true
end
end
return false
end
end
local function grow_plant(pos, plant_name, extra_soil_group)
local new_pos = vector.new(pos.x, pos.y + 1, pos.z)
if not(helper.node_is_buildable(new_pos)) then
return false
end
minetest.swap_node(new_pos, {name = plant_name, param2 = 1})
if check_soil(new_pos, -2, extra_soil_group) and helper.node_is_buildable(new_pos, 1) then
minetest.get_node_timer(new_pos):start(plant_grow_time)
end
end
local function can_grow(pos, plant_name, extra_soil_group)
if not(helper.node_is_buildable(pos, 1)) then
return false
end
local node_under = minetest.get_node_or_nil(vector.new(pos.x, pos.y-1, pos.z))
if check_soil(pos, -1, extra_soil_group)
or (node_under and node_under.name == plant_name and check_soil(pos, -2, extra_soil_group)) then
return true
else
return false
end
end
function floraz.register_growing_plant(name, def)
local plant_name = modname .. ":" .. name
minetest.register_node(plant_name, {
description = S(def.desc),
tiles = def.tiles,
paramtype2 = "none",
place_param2 = 1,
groups = def.groups,
sounds = def.sounds,
after_place_node = function(pos, placer, itemstack, pointed_thing)
if can_grow(pos, plant_name, def.extra_soil_group) then --check if soil or the same plant
minetest.get_node_timer(pos):start(plant_grow_time)
end
end,
on_timer = function(pos, elapsed)
grow_plant(pos, plant_name, def.extra_soil_group)
return false
end
})
end

9
mods/floraz/init.lua Normal file
View File

@ -0,0 +1,9 @@
floraz = {}
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
assert(loadfile(modpath .. "/api.lua"))(S, modname)
assert(loadfile(modpath .. "/lianas.lua"))()
assert(loadfile(modpath .. "/plants.lua"))()

5
mods/floraz/lianas.lua Normal file
View File

@ -0,0 +1,5 @@
--Liana
floraz.register_liana("swamp", {
desc= "Swamp Liana"
})

View File

@ -0,0 +1,3 @@
# textdomain: floraz
Cactus=Cactus
Swamp Liana=Liana de pantano

3
mods/floraz/mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = floraz
description = Some flora
depends =

8
mods/floraz/plants.lua Normal file
View File

@ -0,0 +1,8 @@
floraz.register_growing_plant("cactus", {
desc= "Cactus",
tiles = {"floraz_cactus_top.png", "floraz_cactus_top.png",
"floraz_cactus_side.png"},
groups = {choppy = 3},
sounds = sound.wood(),
extra_soil_group = "sand"
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

View File

Before

Width:  |  Height:  |  Size: 565 B

After

Width:  |  Height:  |  Size: 565 B

View File

@ -64,7 +64,8 @@ function flowerz.register_flower(name, def)
selection_box = {
type = "fixed",
fixed = def.box
}
},
sound = sound.leaves()
})
if def.deco then
@ -84,7 +85,7 @@ local function spread_mushroom(pos, mushroom_name)
{x=1, y=0, z=0}, {x=1, y=0, z=1}}
local _cells = helper.table.shuffle(cells)
local new_pos = vector.add(pos, _cells[1])
if helper.node_is_buildable(new_pos) and helper.node_is_soil(new_pos, "under") then
if helper.node_is_buildable(new_pos) and helper.node_is_soil(new_pos, -1) then
minetest.swap_node(new_pos, {name = mushroom_name, param2 = 1})
minetest.get_node_timer(new_pos):start(mushroom_spread_time)
end
@ -251,27 +252,3 @@ function flowerz.register_tall_flower(name, def)
end
end
--Liana
function flowerz.register_liana(name, def)
local liana_name = modname .. ":" .. name .. "_liana"
minetest.register_node(liana_name, {
description = S(def.desc),
drawtype = "nodebox",
walkable = false,
paramtype = "light",
paramtype2 = "facedir",
tiles = {modname.."_"..name.."_liana.png"},
inventory_image = def.inventory_image or def.tile,
wield_image = def.wield_imagew or def.inventory_image or def.tile,
use_texture_alpha = "clip",
node_box = helper.nodebox.flat_v,
groups = {
snappy = 2, flammable = 3, oddly_breakable_by_hand = 3, choppy = 2, carpet = 1, leafdecay = 3, leaves = 1,
},
sounds = sound:leaves(),
})
end

View File

@ -7,4 +7,3 @@ local S = minetest.get_translator(modname)
assert(loadfile(modpath .. "/api.lua"))(S, modname)
assert(loadfile(modpath .. "/flowers.lua"))()
assert(loadfile(modpath .. "/mushrooms.lua"))()
assert(loadfile(modpath .. "/lianas.lua"))()

View File

@ -1,5 +0,0 @@
--Liana
flowerz.register_liana("swamp", {
desc= "Swamp Liana"
})

View File

@ -46,11 +46,7 @@ end
function helper.node_is_air(pos, offset)
if offset then
if offset == "above" then
pos = vector.new(pos.x, pos.y+1, pos.z)
elseif offset == "under" then
pos = vector.new(pos.x, pos.y-1, pos.z)
end
pos = vector.new(pos.x, pos.y + offset, pos.z)
end
local node = minetest.get_node_or_nil(pos)
if node and helper.get_nodedef_field(node.name, "drawtype") == "airlike" then
@ -60,8 +56,11 @@ function helper.node_is_air(pos, offset)
end
end
function helper.node_is_buildable(pos)
function helper.node_is_buildable(pos, offset)
local node = minetest.get_node_or_nil(pos)
if offset then
pos = vector.new(pos.x, pos.y + offset, pos.z)
end
if node and (helper.node_is_air(pos) or node.buildable_to) then
return true
else
@ -71,9 +70,7 @@ end
function helper.node_is_soil(pos, offset)
if offset then
if offset == "under" then
pos = vector.new(pos.x, pos.y-1, pos.z)
end
pos = vector.new(pos.x, pos.y + offset, pos.z)
end
local node = minetest.get_node_or_nil(pos)
if node and minetest.get_item_group(node.name, "soil") >= 1 then
@ -85,9 +82,7 @@ end
function helper.node_is_water(pos, offset)
if offset then
if offset == "above" then
pos = vector.new(pos.x, pos.y+1, pos.z)
end
pos = vector.new(pos.x, pos.y + offset, pos.z)
end
local node = minetest.get_node_or_nil(pos)
if node and minetest.registered_nodes[node.name]["liquidtype"] == "source" or

View File

@ -269,7 +269,7 @@ function kitz.roam(self, pos, vel, dtime)
pos.y,
pos.z + math.random(-1, 1)
)
if helper.node_is_air(new_pos, "under") then
if helper.node_is_air(new_pos, -1) then
local dir = vector.subtract(new_pos, pos)
local frame = 0.07
vel = {

View File

@ -34,15 +34,11 @@ function ladderz.register_ladder(name, def)
tiles = {tile, def.material, def.material, def.material, def.material, def.material},
inventory_image = inventory_image,
wield_image = def.wield_image or def.inventory_image or def.tiles,
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
climbable = true,
is_ground_content = false,
selection_box = {
type = "wallmounted",
},
groups = {choppy = 2, oddly_breakable_by_hand = 3, flammable = 2, ladder =1, deco = 1, build = 1},
legacy_wallmounted = true,
sounds = _sound,

View File

@ -598,3 +598,32 @@ minetest.register_decoration({
y_min = 1,
})
--Cactus
minetest.register_decoration({
deco_type = "schematic",
place_on = {"nodez:desert_sand"},
sidelen = 16,
noise_params = {
offset = 0.0005,
scale = 0.0005,
spread = {x = 250, y = 250, z = 250},
seed = 2341,
octaves = 3,
persist = 0.66
},
biomes = {"desert"},
height = 2,
y_min = 0,
y_max = 1000,
place_offset_y = 1,
schematic = {
size = {x = 1, y = 3, z = 1},
data = {
{name = "floraz:cactus"}, {name = "floraz:cactus"}, {name = "floraz:cactus"},
}
},
flags = "place_center_x, place_center_z, force_placement",
rotation = "random",
})

View File

@ -113,7 +113,7 @@ function treez.register_tree(name, def)
attached_node = 1, sapling = 1},
on_construct = function(pos)
if helper.node_is_soil(pos, "under") then
if helper.node_is_soil(pos, -1) then
minetest.get_node_timer(pos):start(math.random(tree_grow_time - (tree_grow_time * variability),
tree_grow_time + (tree_grow_time * variability)))
end

View File

@ -1,3 +1,3 @@
name = treez
description = Trees
depends = mapgenz, helper, fencez
depends = mapgenz, helper, fencez, floraz

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 565 B

View File

@ -138,7 +138,7 @@ local function render_recipes(item_name, recipe_no)
for i= 1, 4 do
local item = items[i]
local element_render, prefix, name
if not item then
if not item or not craft_items[item] then
prefix = "empty"
else
prefix = string.sub(item, 1, 6)
@ -239,7 +239,8 @@ local info = {
"Plant seeds.",
"Seeds are obtained by collecting grass or sunflower seeds.",
"Wait for them to grow.",
"Mushrooms also spread if you plant them."
"Mushrooms also spread if you plant them.",
"You can plant cacti and have them grow."
})
}

View File

@ -25,3 +25,4 @@ Plant seeds.=Planta semillas.
Seeds are obtained by collecting grass or sunflower seeds.=Obtén semillas recolectando hierba o de los girasoles.
Wait for them to grow.=Espera a que crezcan.
Mushrooms also spread if you plant them.=Los hongos también se expanden si los plantas.
You can plant cacti and have them grow.=Puedes plantar cactus y que crezcan.