simple_grow preview added
parent
398a69be12
commit
58eeb50685
|
@ -0,0 +1,52 @@
|
|||
--[[
|
||||
{
|
||||
{
|
||||
k_grow_time, -- k * STANDART_GROW_TIME
|
||||
image,
|
||||
drop,
|
||||
groups,
|
||||
chance
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
--
|
||||
--
|
||||
]]--
|
||||
|
||||
STANDART_SPGROW_TIME = 120
|
||||
|
||||
function register_simple_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) 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
|
|
@ -0,0 +1 @@
|
|||
simple_grow
|
|
@ -0,0 +1,51 @@
|
|||
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_simple_plant({
|
||||
{
|
||||
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
|
||||
},
|
||||
})
|
Binary file not shown.
After Width: | Height: | Size: 184 B |
Binary file not shown.
After Width: | Height: | Size: 117 B |
Binary file not shown.
After Width: | Height: | Size: 118 B |
Binary file not shown.
After Width: | Height: | Size: 135 B |
Binary file not shown.
After Width: | Height: | Size: 188 B |
Loading…
Reference in New Issue