diff --git a/shit/simple_grow/init.lua b/shit/simple_grow/init.lua index 24774a3..896fb3e 100644 --- a/shit/simple_grow/init.lua +++ b/shit/simple_grow/init.lua @@ -8,14 +8,12 @@ chance } } - --- --- --- ]]-- STANDART_SPGROW_TIME = 120 +local TRANSFORMS = {} + function register_plant_with_full_stages(grow_table) for stage in ipairs(grow_table) do @@ -75,3 +73,56 @@ function register_simple_plant(name, final_description, stage_max, stage_time, i 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] + + minetest.env:add_node({ + x = pos.x + transform.x, + y = pos.y + transform.y, + z = pos.z + transform.z + }, + {name = transform.newname} + ) + if transform.oldname ~= nil then + minetest.env:add_node(pos, {name = transform.oldname}) + end + end + end + }) + end + end +end \ No newline at end of file diff --git a/shit/simple_plant/init.lua b/shit/simple_plant/init.lua index a3a07b7..818fc1d 100644 --- a/shit/simple_plant/init.lua +++ b/shit/simple_plant/init.lua @@ -68,4 +68,70 @@ minetest.register_craftitem('simple_plant:n_seed', { 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 + } }) \ No newline at end of file diff --git a/shit/simple_plant/textures/n1.png b/shit/simple_plant/textures/n1.png new file mode 100644 index 0000000..4f842a9 Binary files /dev/null and b/shit/simple_plant/textures/n1.png differ diff --git a/shit/simple_plant/textures/n2.png b/shit/simple_plant/textures/n2.png new file mode 100644 index 0000000..76a2bf3 Binary files /dev/null and b/shit/simple_plant/textures/n2.png differ diff --git a/shit/simple_plant/textures/n3.png b/shit/simple_plant/textures/n3.png new file mode 100644 index 0000000..96b96e6 Binary files /dev/null and b/shit/simple_plant/textures/n3.png differ diff --git a/shit/simple_plant/textures/n4.png b/shit/simple_plant/textures/n4.png new file mode 100644 index 0000000..d6bf025 Binary files /dev/null and b/shit/simple_plant/textures/n4.png differ diff --git a/shit/simple_plant/textures/n5.png b/shit/simple_plant/textures/n5.png new file mode 100644 index 0000000..5200438 Binary files /dev/null and b/shit/simple_plant/textures/n5.png differ diff --git a/shit/simple_plant/textures/n6.png b/shit/simple_plant/textures/n6.png new file mode 100644 index 0000000..9b52a8d Binary files /dev/null and b/shit/simple_plant/textures/n6.png differ diff --git a/shit/simple_plant/textures/n_seed.png b/shit/simple_plant/textures/n_seed.png new file mode 100644 index 0000000..9dca4a0 Binary files /dev/null and b/shit/simple_plant/textures/n_seed.png differ diff --git a/shit/simple_plant/textures/seed_strange.png b/shit/simple_plant/textures/seed_strange.png new file mode 100644 index 0000000..2ee8bce Binary files /dev/null and b/shit/simple_plant/textures/seed_strange.png differ diff --git a/shit/simple_plant/textures/sp1.png b/shit/simple_plant/textures/sp1.png new file mode 100644 index 0000000..ff31ad6 Binary files /dev/null and b/shit/simple_plant/textures/sp1.png differ diff --git a/shit/simple_plant/textures/sp2.png b/shit/simple_plant/textures/sp2.png new file mode 100644 index 0000000..e6d4b26 Binary files /dev/null and b/shit/simple_plant/textures/sp2.png differ diff --git a/shit/simple_plant/textures/sp_fin.png b/shit/simple_plant/textures/sp_fin.png new file mode 100644 index 0000000..3c2d97d Binary files /dev/null and b/shit/simple_plant/textures/sp_fin.png differ diff --git a/shit/simple_plant/textures/sp_stem.png b/shit/simple_plant/textures/sp_stem.png new file mode 100644 index 0000000..e5f3460 Binary files /dev/null and b/shit/simple_plant/textures/sp_stem.png differ diff --git a/shit/simple_plant/textures/sp_stem2.png b/shit/simple_plant/textures/sp_stem2.png new file mode 100644 index 0000000..0cf4553 Binary files /dev/null and b/shit/simple_plant/textures/sp_stem2.png differ