rm grow
|
@ -1,132 +0,0 @@
|
||||||
--[[
|
|
||||||
{
|
|
||||||
{
|
|
||||||
k_grow_time, -- k * STANDART_GROW_TIME
|
|
||||||
image,
|
|
||||||
drop,
|
|
||||||
groups,
|
|
||||||
chance
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]--
|
|
||||||
|
|
||||||
STANDART_SPGROW_TIME = 120
|
|
||||||
|
|
||||||
local TRANSFORMS = {}
|
|
||||||
|
|
||||||
function register_plant_with_full_stages(grow_table)
|
|
||||||
|
|
||||||
for stage in ipairs(grow_table) do
|
|
||||||
if grow_table[stage].chance > 1 then
|
|
||||||
grow_table[stage].chance = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node(grow_table[stage].name, {
|
|
||||||
description = grow_table[stage].name,
|
|
||||||
drawtype = "plantlike",
|
|
||||||
walkable = false,
|
|
||||||
tile_images = {grow_table[stage].image},
|
|
||||||
inventory_image = grow_table[stage].image,
|
|
||||||
wield_image = grow_table[stage].image,
|
|
||||||
paramtype = "light",
|
|
||||||
drop = grow_table[stage].drop,
|
|
||||||
groups = grow_table[stage].groups,
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
if (#(grow_table) > stage) then
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = { grow_table[stage].name },
|
|
||||||
interval = grow_table[stage].time * STANDART_SPGROW_TIME,
|
|
||||||
chance = grow_table[stage].chance,
|
|
||||||
action = function (pos, node)
|
|
||||||
if math.random() < grow_table[stage].chance then
|
|
||||||
minetest.env:add_node(pos, {name = grow_table[stage + 1].name})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function register_simple_plant(name, final_description, stage_max, stage_time, image_template, final_drop)
|
|
||||||
-- number of stages of growth [1 .. stage_max]
|
|
||||||
-- image template .. [1 .. stage_max] .. ".png" --> png
|
|
||||||
local ngrow_table = {}
|
|
||||||
local cur_drop = ''
|
|
||||||
|
|
||||||
for i=1, stage_max do
|
|
||||||
cur_drop = ''
|
|
||||||
if i == stage_max then
|
|
||||||
cur_drop = final_drop
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(ngrow_table, {
|
|
||||||
name = name .. i,
|
|
||||||
time = stage_time,
|
|
||||||
image = image_template .. i .. ".png",
|
|
||||||
drop = cur_drop,
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.6
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
register_plant_with_full_stages(ngrow_table)
|
|
||||||
end
|
|
||||||
|
|
||||||
function register_transform_plant(grow_table)
|
|
||||||
|
|
||||||
for stage in ipairs(grow_table) do
|
|
||||||
if grow_table[stage].chance > 1 then
|
|
||||||
grow_table[stage].chance = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node(grow_table[stage].name, {
|
|
||||||
description = grow_table[stage].name,
|
|
||||||
drawtype = "plantlike",
|
|
||||||
walkable = false,
|
|
||||||
tile_images = {grow_table[stage].image},
|
|
||||||
inventory_image = grow_table[stage].image,
|
|
||||||
wield_image = grow_table[stage].image,
|
|
||||||
paramtype = "light",
|
|
||||||
drop = grow_table[stage].drop,
|
|
||||||
groups = grow_table[stage].groups,
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
if (grow_table[stage].transform ~= nil) then
|
|
||||||
|
|
||||||
TRANSFORMS[grow_table[stage].name] = grow_table[stage].transform
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = { grow_table[stage].name },
|
|
||||||
interval = grow_table[stage].time * STANDART_SPGROW_TIME,
|
|
||||||
chance = grow_table[stage].chance,
|
|
||||||
action = function (pos, node)
|
|
||||||
if math.random() < grow_table[stage].chance then
|
|
||||||
local rnd = 1
|
|
||||||
if #(TRANSFORMS[node.name]) > 1 then
|
|
||||||
rnd = math.random(#(TRANSFORMS[node.name]))
|
|
||||||
end
|
|
||||||
local transform = TRANSFORMS[node.name][rnd]
|
|
||||||
|
|
||||||
if transform.oldname ~= nil then
|
|
||||||
minetest.env:add_node(pos, {name = transform.oldname})
|
|
||||||
end
|
|
||||||
|
|
||||||
local trans_coord = {
|
|
||||||
x = pos.x + transform.x,
|
|
||||||
y = pos.y + transform.y,
|
|
||||||
z = pos.z + transform.z
|
|
||||||
}
|
|
||||||
if minetest.env:get_node(trans_coord).name == 'air' then
|
|
||||||
minetest.env:add_node(trans_coord, {name = transform.newname})
|
|
||||||
else
|
|
||||||
minetest.env:add_node(pos, {name = transform.newname})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1 +0,0 @@
|
||||||
simple_grow
|
|
|
@ -1,137 +0,0 @@
|
||||||
minetest.register_craftitem('simple_plant:seed0', {
|
|
||||||
inventory_image = 'seed0.png',
|
|
||||||
stack_max = 99,
|
|
||||||
usable = true,
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
|
||||||
-- Must be pointing to node
|
|
||||||
if pointed_thing.type == 'node' then
|
|
||||||
n = minetest.env:get_node(pointed_thing.under)
|
|
||||||
if n.name == 'default:dirt_with_grass' then
|
|
||||||
minetest.env:add_node(pointed_thing.above, {name='simple_plant:splant1'})
|
|
||||||
end
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
register_plant_with_full_stages({
|
|
||||||
{
|
|
||||||
name = 'simple_plant:splant1',
|
|
||||||
time = 0.5,
|
|
||||||
image = 'stage1.png',
|
|
||||||
drop = '',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = 'simple_plant:splant2',
|
|
||||||
time = 0.5,
|
|
||||||
image = 'stage2.png',
|
|
||||||
drop = 'default:iron_lump',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = 'simple_plant:splant3',
|
|
||||||
time = 0.5,
|
|
||||||
image = 'stage3.png',
|
|
||||||
drop = '',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = 'simple_plant:splant4',
|
|
||||||
time = 0.5,
|
|
||||||
image = 'stage4.png',
|
|
||||||
drop = 'default:clay_brick 4',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.4
|
|
||||||
},
|
|
||||||
})
|
|
||||||
---------------------
|
|
||||||
register_simple_plant('simple_plant:n', 'Odd flower', 6, 0.5, 'n', 'simple_plant:n_seed 5')
|
|
||||||
|
|
||||||
minetest.register_craftitem('simple_plant:n_seed', {
|
|
||||||
description = 'N seed',
|
|
||||||
inventory_image = 'n_seed.png',
|
|
||||||
stack_max = 99,
|
|
||||||
usable = true,
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
|
||||||
-- Must be pointing to node
|
|
||||||
if pointed_thing.type == 'node' then
|
|
||||||
n = minetest.env:get_node(pointed_thing.under)
|
|
||||||
if n.name == 'default:dirt_with_grass' then
|
|
||||||
minetest.env:add_node(pointed_thing.above, {name='simple_plant:n1'})
|
|
||||||
end
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
------------------------
|
|
||||||
minetest.register_craftitem('simple_plant:strange_seed', {
|
|
||||||
description = 'Strange seed',
|
|
||||||
inventory_image = 'seed_strange.png',
|
|
||||||
stack_max = 99,
|
|
||||||
usable = true,
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
|
||||||
-- Must be pointing to node
|
|
||||||
if pointed_thing.type == 'node' then
|
|
||||||
n = minetest.env:get_node(pointed_thing.under)
|
|
||||||
if n.name == 'default:dirt_with_grass' then
|
|
||||||
minetest.env:add_node(pointed_thing.above, {name='simple_plant:sp1'})
|
|
||||||
end
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
register_transform_plant({
|
|
||||||
{
|
|
||||||
name = 'simple_plant:sp1',
|
|
||||||
transform = {{newname = 'simple_plant:sp2', x =0, y=0, z=0}},
|
|
||||||
time = 0.5,
|
|
||||||
image = 'sp1.png',
|
|
||||||
drop = '',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = 'simple_plant:sp2',
|
|
||||||
transform = {{newname = 'simple_plant:sp_fin', oldname ='simple_plant:sp_stem', x =0, y=1, z=0},
|
|
||||||
{newname = 'simple_plant:sp_fin', oldname ='simple_plant:sp_stem2', x =0, y=1, z=0}},
|
|
||||||
time = 0.5,
|
|
||||||
image = 'sp2.png',
|
|
||||||
drop = '',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = 'simple_plant:sp_stem',
|
|
||||||
transform = nil,
|
|
||||||
time = 0.5,
|
|
||||||
image = 'sp_stem.png',
|
|
||||||
drop = '',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = 'simple_plant:sp_stem2',
|
|
||||||
transform = nil,
|
|
||||||
time = 0.5,
|
|
||||||
image = 'sp_stem2.png',
|
|
||||||
drop = '',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = 'simple_plant:sp_fin',
|
|
||||||
time = 0.5,
|
|
||||||
image = 'sp_fin.png',
|
|
||||||
drop = 'simple_plant:strange_seed',
|
|
||||||
groups = {snappy=3},
|
|
||||||
chance = 0.7
|
|
||||||
}
|
|
||||||
})
|
|
Before Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 218 B |
Before Width: | Height: | Size: 217 B |
Before Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 214 B |
Before Width: | Height: | Size: 244 B |
Before Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 135 B |
Before Width: | Height: | Size: 188 B |