diff --git a/shit/simple_grow/init.lua b/shit/simple_grow/init.lua new file mode 100644 index 0000000..d3b60a2 --- /dev/null +++ b/shit/simple_grow/init.lua @@ -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 diff --git a/shit/simple_plant/depends.txt b/shit/simple_plant/depends.txt new file mode 100644 index 0000000..3a4ca9b --- /dev/null +++ b/shit/simple_plant/depends.txt @@ -0,0 +1 @@ +simple_grow diff --git a/shit/simple_plant/init.lua b/shit/simple_plant/init.lua new file mode 100644 index 0000000..144b063 --- /dev/null +++ b/shit/simple_plant/init.lua @@ -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 + }, +}) diff --git a/shit/simple_plant/textures/seed0.png b/shit/simple_plant/textures/seed0.png new file mode 100644 index 0000000..94e0b43 Binary files /dev/null and b/shit/simple_plant/textures/seed0.png differ diff --git a/shit/simple_plant/textures/stage1.png b/shit/simple_plant/textures/stage1.png new file mode 100644 index 0000000..d2dc3e4 Binary files /dev/null and b/shit/simple_plant/textures/stage1.png differ diff --git a/shit/simple_plant/textures/stage2.png b/shit/simple_plant/textures/stage2.png new file mode 100644 index 0000000..18a0cad Binary files /dev/null and b/shit/simple_plant/textures/stage2.png differ diff --git a/shit/simple_plant/textures/stage3.png b/shit/simple_plant/textures/stage3.png new file mode 100644 index 0000000..d846cb1 Binary files /dev/null and b/shit/simple_plant/textures/stage3.png differ diff --git a/shit/simple_plant/textures/stage4.png b/shit/simple_plant/textures/stage4.png new file mode 100644 index 0000000..fd0b4ce Binary files /dev/null and b/shit/simple_plant/textures/stage4.png differ