From 9288bef68540cd763859620e9424b6669b182599 Mon Sep 17 00:00:00 2001 From: Nemo08 Date: Thu, 5 Apr 2012 18:54:10 +0400 Subject: [PATCH] add transformable plant. --- shit/simple_grow/init.lua | 59 +++++++++++++++-- shit/simple_plant/init.lua | 66 ++++++++++++++++++++ shit/simple_plant/textures/n1.png | Bin 0 -> 212 bytes shit/simple_plant/textures/n2.png | Bin 0 -> 221 bytes shit/simple_plant/textures/n3.png | Bin 0 -> 216 bytes shit/simple_plant/textures/n4.png | Bin 0 -> 218 bytes shit/simple_plant/textures/n5.png | Bin 0 -> 217 bytes shit/simple_plant/textures/n6.png | Bin 0 -> 239 bytes shit/simple_plant/textures/n_seed.png | Bin 0 -> 260 bytes shit/simple_plant/textures/seed_strange.png | Bin 0 -> 287 bytes shit/simple_plant/textures/sp1.png | Bin 0 -> 154 bytes shit/simple_plant/textures/sp2.png | Bin 0 -> 161 bytes shit/simple_plant/textures/sp_fin.png | Bin 0 -> 210 bytes shit/simple_plant/textures/sp_stem.png | Bin 0 -> 214 bytes shit/simple_plant/textures/sp_stem2.png | Bin 0 -> 244 bytes 15 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 shit/simple_plant/textures/n1.png create mode 100644 shit/simple_plant/textures/n2.png create mode 100644 shit/simple_plant/textures/n3.png create mode 100644 shit/simple_plant/textures/n4.png create mode 100644 shit/simple_plant/textures/n5.png create mode 100644 shit/simple_plant/textures/n6.png create mode 100644 shit/simple_plant/textures/n_seed.png create mode 100644 shit/simple_plant/textures/seed_strange.png create mode 100644 shit/simple_plant/textures/sp1.png create mode 100644 shit/simple_plant/textures/sp2.png create mode 100644 shit/simple_plant/textures/sp_fin.png create mode 100644 shit/simple_plant/textures/sp_stem.png create mode 100644 shit/simple_plant/textures/sp_stem2.png 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 0000000000000000000000000000000000000000..4f842a9196e86c08c24166b124227e6d00d39704 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijSl0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP(rH2 zHKHUqKdq!Zu_%=xATcwqM9KLZB)gPZ!4!3;*Ol|Nq-FyE3FO zsLoJ2n{Yii>Gul82{)v9k4zL~1;Ki}I$&A?@=k82b*i{A8$KdJe=d#Wzp$P!M C+dg;z literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/n2.png b/shit/simple_plant/textures/n2.png new file mode 100644 index 0000000000000000000000000000000000000000..76a2bf3f1bd18c94efc5bc881093ee9da1e10c5d GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijSl0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP(rH2 zHKHUqKdq!Zu_%=xATcwqM9KLZB*BPZ!4!3;*Ol|Nq-FyE3FO zsLoJ2n{Yii>Gul82{)v9U8-6fPt~g@Bs@N+&yw7@a9;m5pktR>oD~vS>u~{S0E4Hi KpUXO@geCytus}Be literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/n3.png b/shit/simple_plant/textures/n3.png new file mode 100644 index 0000000000000000000000000000000000000000..96b96e6af22a235cc3d5eea595b21f41dc640511 GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijSl0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP(rH2 zHKHUqKdq!Zu_%=xATcwqM9KLZB)GPZ!4!3;*Ol|Nq-FyE3FO zsLoJ2n{Yii>Gul82{)uU8(%Pg(|UKs%YaAX)z7xwj12croxHZX>{kF#FN3G6pUXO@ GgeCyqyFpw4 literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/n4.png b/shit/simple_plant/textures/n4.png new file mode 100644 index 0000000000000000000000000000000000000000..d6bf025e37c7bcad0d9fdc203992a747bd5416ba GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijSl0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP(rH2 zHKHUqKdq!Zu_%=xATcwqM9KLZB)mPZ!4!3;*Ol|Nq-FyE3FO zsLoJ2n{Yii>Gul82{#tkD*S5DJv29rV^_n%dHGiuqS_f5ZvQ;?Mdv!>TA*$QPgg&e IbxsLQ0B+<#_W%F@ literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/n5.png b/shit/simple_plant/textures/n5.png new file mode 100644 index 0000000000000000000000000000000000000000..5200438a267db624fc3ce715c36a65a197bebe2e GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijSl0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP(rH2 zHKHUqKdq!Zu_%=xATcwqM9KLZB)`PZ!4!3;*Ol|Nq-FyE3FO zsLoJ2n{Yii>9>I40d|>VJD6uBNElrC+$&`u#m3WeiIG9P=+MHHGhr-1%?zHdelF{r G5}E*}Mm*vG literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/n6.png b/shit/simple_plant/textures/n6.png new file mode 100644 index 0000000000000000000000000000000000000000..9b52a8d9d50087405590dbd9149f4b1f94277186 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijSl0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP(rH2 zHKHUqKdq!Zu_%=xATcwqM9KLZB*lPZ!4!3;*Ol|Nq-FyE3FO zsLoJ2n{fT{rn~HKHvH##VX~`gj~+v2TVjluph?5RdHgvXk!%frIZPPh6@+KLZGS`PZ!4!3;*N<3Dzx~jsNvu z|37SS(o7-y-=`9@N;XAlrliR^7bbJJ7R*j;o0!6Jf+44Ef{5M^9!0H${=7cM-AuE+ zJB%1sz4&ja(wx91l*`~@Y{Vw%uqADmCJO^=>W)v<9cIixdl)=j{an^LB{Ts5!ir4L literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/seed_strange.png b/shit/simple_plant/textures/seed_strange.png new file mode 100644 index 0000000000000000000000000000000000000000..2ee8bce753f35a86183358b6baf950126ea1ba82 GIT binary patch literal 287 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijSl0AZa85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP(rH2 zHKHUqKdq!Zu_%=xATcwqM9KLZGU0PZ!4!3;*Ol|Nq-FyE3FO zsLoJ2n{Yii$-0&&K_L4F|KS@k-IuuyeD4Hl7BD*`y=Y62Xz*4xJ1ddc;JkF}g)FnKl{hJJKe|t#H<$H$~DR>(Vj{ beFla}TiQkE!lvI6;1C9V-A z!TD(=<%vb93;~Imc_n&&t|1C##(JiDh6V;-iWUM@X?wajhFJI~|M~ylp4pWlg+X!lvI6;1C9V-A z!TD(=<%vb93;~Imc_n&&t|1C##(JiDh6V;-iWUM@8F{)mhFJI~|M~ylp4pWlg+X>gd_g1U^L-nW?+{+d*;fsh)Y1-44$rjF6*2U FngB;fF~I-; literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/sp_fin.png b/shit/simple_plant/textures/sp_fin.png new file mode 100644 index 0000000000000000000000000000000000000000..3c2d97d9034700baf4a1653aa2735a9e7e00103d GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;1C9V-A z!TD(=<%vb93;~Imc_n&&t|1C##(JiDh6V;-iWUM@C40I!hFJI~|M~ylp4pWlg+X<>D834?GpxlgMz1<#39tvWM`^M25|UAEX%=%yu00-g;;IPoQ-Sp00i_>zopr E0D8SclmGw# literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/sp_stem.png b/shit/simple_plant/textures/sp_stem.png new file mode 100644 index 0000000000000000000000000000000000000000..e5f3460ef3777f060e5ca7dec4b7afcc34d55453 GIT binary patch literal 214 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;1C9V-A z!TD(=<%vb93;~Imc_n&&t|1C##(JiDh6V;-iWUM@rF*(KhFJI~|M>skp4n~>rwVrn z^WuwFA6@0S+~IBPF;9cpqloc@S&DSw#>BXTFPWU`)H4_i|1I~GSl}*PHDiKkugXy- zGw}mQHY{adv(Z80)dXG1BNsb#6$NG4PSmxyD!c9!j4xwnIM?-Q28Wo=e4v#Kp00i_ I>zopr0LQ~c9{>OV literal 0 HcmV?d00001 diff --git a/shit/simple_plant/textures/sp_stem2.png b/shit/simple_plant/textures/sp_stem2.png new file mode 100644 index 0000000000000000000000000000000000000000..0cf455391f68e545b61dc4706a04a0d72b73240e GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;1C9V-A z!TD(=<%vb93;~Imc_n&&t|1C##(JiDh6V;-iWUM@wR*ZZhFJI?4R+*fFyOfDUArXz z6YD*jhYCrn#N2#(+Ecw3Y|*~pvLrSATE_X0zvs^YjBvQj%@d$5+# zCUc=yE~PZ)awB~slL>$SFMRM{uV&o=&KdGoj;!eQ$-L2ek)d*9c&>};bS8^SK8|Ob olb2kyV4b#YqHgH6POnYO9dCa$guTkC2Rews)78&qol`;+0A|`)q5uE@ literal 0 HcmV?d00001