From d293de1c4e82aadf62977af490160be4b128e0ce Mon Sep 17 00:00:00 2001 From: Victor Hackeridze Date: Mon, 2 Apr 2012 02:32:18 +0600 Subject: [PATCH] flowers updated to new api --- new_api/flowers/CREDITS | 1 + new_api/flowers/depends.txt | 1 + new_api/flowers/init.lua | 189 ++++++++++++++++++ new_api/flowers/textures/cotton.png | Bin 0 -> 680 bytes new_api/flowers/textures/flower_cotton.png | Bin 0 -> 315 bytes .../flowers/textures/flower_cotton_pot.png | Bin 0 -> 498 bytes .../textures/flower_dandelion_white.png | Bin 0 -> 169 bytes .../textures/flower_dandelion_white_pot.png | Bin 0 -> 464 bytes .../textures/flower_dandelion_yellow.png | Bin 0 -> 166 bytes .../textures/flower_dandelion_yellow_pot.png | Bin 0 -> 462 bytes new_api/flowers/textures/flower_pot.png | Bin 0 -> 405 bytes new_api/flowers/textures/flower_rose.png | Bin 0 -> 171 bytes new_api/flowers/textures/flower_rose_pot.png | Bin 0 -> 479 bytes new_api/flowers/textures/flower_tulip.png | Bin 0 -> 159 bytes new_api/flowers/textures/flower_tulip_pot.png | Bin 0 -> 470 bytes new_api/flowers/textures/flower_viola.png | Bin 0 -> 140 bytes new_api/flowers/textures/flower_viola_pot.png | Bin 0 -> 465 bytes new_api/flowers/textures/flower_waterlily.png | Bin 0 -> 221 bytes 18 files changed, 191 insertions(+) create mode 100644 new_api/flowers/CREDITS create mode 100644 new_api/flowers/depends.txt create mode 100644 new_api/flowers/init.lua create mode 100644 new_api/flowers/textures/cotton.png create mode 100644 new_api/flowers/textures/flower_cotton.png create mode 100644 new_api/flowers/textures/flower_cotton_pot.png create mode 100644 new_api/flowers/textures/flower_dandelion_white.png create mode 100644 new_api/flowers/textures/flower_dandelion_white_pot.png create mode 100644 new_api/flowers/textures/flower_dandelion_yellow.png create mode 100644 new_api/flowers/textures/flower_dandelion_yellow_pot.png create mode 100644 new_api/flowers/textures/flower_pot.png create mode 100644 new_api/flowers/textures/flower_rose.png create mode 100644 new_api/flowers/textures/flower_rose_pot.png create mode 100644 new_api/flowers/textures/flower_tulip.png create mode 100644 new_api/flowers/textures/flower_tulip_pot.png create mode 100644 new_api/flowers/textures/flower_viola.png create mode 100644 new_api/flowers/textures/flower_viola_pot.png create mode 100644 new_api/flowers/textures/flower_waterlily.png diff --git a/new_api/flowers/CREDITS b/new_api/flowers/CREDITS new file mode 100644 index 0000000..8be7ff7 --- /dev/null +++ b/new_api/flowers/CREDITS @@ -0,0 +1 @@ +Flower textures by erlehmann diff --git a/new_api/flowers/depends.txt b/new_api/flowers/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/new_api/flowers/depends.txt @@ -0,0 +1 @@ +default diff --git a/new_api/flowers/init.lua b/new_api/flowers/init.lua new file mode 100644 index 0000000..0e39b9a --- /dev/null +++ b/new_api/flowers/init.lua @@ -0,0 +1,189 @@ +--[[ +-- Flowers mod by ironzorg +--]] + +local DEBUG = 0 + +local FLOWERS = { + "rose", + "dandelion_yellow", + "dandelion_white", + "tulip", + "viola", + "cotton", +} + +local MAX_RATIO = 2000 +local GROWING_DELAY = 7200 + +local table_contains = function(t, v) + for _, i in ipairs(t) do + if (i == v) then + return true + end + end + + return false +end + +local is_node_in_cube = function(nodenames, node_pos, radius) + for x = node_pos.x - radius, node_pos.x + radius do + for y = node_pos.y - radius, node_pos.y + radius do + for z = node_pos.z - radius, node_pos.z + radius do + n = minetest.env:get_node_or_nil({x = x, y = y, z = z}) + if (n == nil) + or (n.name == 'ignore') + or (table_contains(nodenames, n.name) == true) then + return true + end + end + end + end + + return false +end + +local grow_blocks_on_surfaces = function(growdelay, grownames, surfaces) + for _, surface in ipairs(surfaces) do + minetest.register_abm({ + nodenames = { surface.name }, + interval = growdelay, + chance = 30, + action = function(pos, node, active_object_count, active_object_count_wider) + local p_top = { + x = pos.x, + y = pos.y + 1, + z = pos.z + } + local n_top = minetest.env:get_node(p_top) + local rnd = math.random(1, MAX_RATIO) + + if (MAX_RATIO - surface.chance < rnd) then + local flower_in_range = is_node_in_cube(grownames, p_top, surface.spacing) + if (n_top.name == "air") and (flower_in_range == false) then + local nnode = grownames[math.random(1, #grownames)] + minetest.env:add_node(p_top, { name = nnode }) + end + end + end + }) + end +end + +-- Nodes +for _, color in ipairs(FLOWERS) do + local fname = 'flower_' .. color + + minetest.register_node('flowers:' .. fname, { + description = "Flower: " .. color, + drawtype = 'plantlike', + visual_scale = FLOWERS_VISUAL_SCALE, + tile_images = { fname .. '.png' }, + inventory_image = fname .. '.png', + sunlight_propagates = true, + paramtype = 'light', + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/5-0.1, -1/2, -1/5-0.1, 1/5+0.1, 1/5+0.1, 1/5+0.1}, + }, + groups = {snappy=2}, + sounds = default.node_sound_leaves_defaults(), + }) +end + +minetest.register_node('flowers:flower_waterlily', { + description = "Flower: waterlily", + drawtype = 'raillike', + tile_images = { 'flower_waterlily.png', }, + inventory_image = 'flower_waterlily.png', + sunlight_propagates = true, + paramtype = 'light', + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -0.52, 1/2}, + }, + groups = {snappy=2}, + sounds = default.node_sound_leaves_defaults(), +}) + +-- Items +minetest.register_craftitem('flowers:flower_pot', { + description = "Flower pot", + image = 'flower_pot.png', + +}) + +minetest.register_craftitem('flowers:cotton', { + description = "Cotton", + image = 'cotton.png', + +}) + +for _, color in ipairs(FLOWERS) do + local fname = 'flower_' .. color + local pname = fname .. '_pot' + + minetest.register_craftitem('flowers:' .. pname, { + description = "Flower pot: " .. color, + image = pname .. '.png', + }) +end + +-- Crafts +minetest.register_craft({ + output = 'flowers:flower_pot 5', + recipe = { + {'default:clay_brick', '', 'default:clay_brick'}, + {'', 'default:clay_brick', ''}, + } +}) + +for _, color in ipairs(FLOWERS) do + local fname = 'flowers:flower_' .. color + local pname = fname .. '_pot' + + minetest.register_craft({ + output = pname .. ' 1', + recipe = { + {fname}, + {'flowers:flower_pot'}, + } + }) +end + +minetest.register_craft({ + output = 'flowers:cotton 1', + recipe = { + {'flowers:flower_cotton 1'}, + } +}) + +-- Make it grow ! +grow_blocks_on_surfaces(GROWING_DELAY * 2, { + "flowers:flower_rose", + "flowers:flower_dandelion_white", + "flowers:flower_viola", + }, { + {name = "dirt_with_grass", chance = 4, spacing = 15}, +}) + +grow_blocks_on_surfaces(GROWING_DELAY, { + "flowers:flower_dandelion_yellow", + "flowers:flower_tulip", + }, { + {name = "dirt_with_grass", chance = 2, spacing = 10}, +}) + +grow_blocks_on_surfaces(GROWING_DELAY*3, { + "flowers:flower_cotton", + }, { + {name = "dirt_with_grass", chance = 3, spacing = 12}, +}) + +grow_blocks_on_surfaces(GROWING_DELAY / 2, { + "flowers:flower_waterlily", + }, { + {name = "water_source", chance = 1, spacing = 15}, +}) diff --git a/new_api/flowers/textures/cotton.png b/new_api/flowers/textures/cotton.png new file mode 100644 index 0000000000000000000000000000000000000000..c184db25a22b83fddef424ab990e65b24903c44f GIT binary patch literal 680 zcmV;Z0$2TsP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipt` z3K<$u{=q>200JmUL_t(I%dL~KYZO5k#ecK8TeIC5=Yo32+CvecJvG zyaql3Pl0Pnsm^(VO=HZn(P-3)uYOk)!}d`@;sj_^?kn{;HQZ5#tGQpyh5-DY&h(@D96h$cYdp)eR?C zYPCjZ2z=k)%CgL{)?%$iYdr^*YciRzva*7;cKiGyeGozfgTa6(ifFgnxUNf*Bp74n z1gE|jA;b@@^<%BInwvNn3_dxIb3+JG6+&RGMF_!oJVr{1F@_)r=yWQL70(Y)*K0-AbW|YuPgg)9v)5u;e4ftaG=m`PZ!4!i_>o> zZRBk>5OAHZERwe46wkz_CN=IQXEa#Z=uU8HdbEPt4Wl zf7$>4ul0||-vbt=T{aO@=u38SVU$SLIbgt};<-qSm0{JYO;OqZ^KOeZnE2ke2<*t| z5p=&4^;_!DyXHo@1+T5%xjuAl_?*Rd`RCp9sgaXXB^%DC6n7N=E^d6lp_eKcxc#{3 zgBNBGj+j55@;>*(-B(h}pX{p(dcOGAt4n;-GcJDOX3g|*US9De6X*>FPgg&ebxsLQ E0C%Z(`~Uy| literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_cotton_pot.png b/new_api/flowers/textures/flower_cotton_pot.png new file mode 100644 index 0000000000000000000000000000000000000000..9432adf8ffcab9b8adeb6ce5d5308f2350d0ba45 GIT binary patch literal 498 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg)9v)63ga5_e%Yj0&nIRD+&iT2y zsd*(pE(3#eQEFmIYKlU6W=V#EyQgnJie4%^&^k{~7sn8b)4h}SdNDhSwC=Z#!}xg8gFT7w&KokxpKT87 z-#y~_tn$~7CY|4&rwq@%|6j=PVaMGIzg1j?yd8V5{#ZIiI)qb0_OZI=C%N@rQCkoE jn|s1&f{f$Zs`7n|kE*AYe|w<39u(T1u6{1-oD!M<`)A2a literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_dandelion_white.png b/new_api/flowers/textures/flower_dandelion_white.png new file mode 100644 index 0000000000000000000000000000000000000000..b22d6d4644b7cc8cc1ff653d9c58d163d2ec79db GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|l097o(u`H(92`!1w&QKh4$2!MF6?CM7Z6oM629UqUE1!^C9@uhz7< R#R08j@O1TaS?83{1OP(iJX8Px literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_dandelion_white_pot.png b/new_api/flowers/textures/flower_dandelion_white_pot.png new file mode 100644 index 0000000000000000000000000000000000000000..1b48fe6e963cd7bfa2fd241aa9ed243bf0a89e6b GIT binary patch literal 464 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!6#=yXs@#Xw?AcrO0(btiIVPik{pF~z5pDoGT z-GxB|1i2*>B!D8E1s;*b3=G`DAk4@xYYs?|y~NYkmHjpkn~1*ny)dWgKq1Kz*N775 z{M_8syb=cIqSVBa)D(sC%#sWRcTeAd@J2pypsgC7E{-7%|->(7JzT_0$Jh z*OXdvq_}mr2!t@TaWKXoICbt`*czRqm%=|N*06CqT03%oT<)CgGtvOw1 z)uLA{-*wcy{Mj5yhIQ-oMH+e+f1K~W>sQPgx4jl!=R=b3Ucb9DlXXJM^03XV@!uk2 zBBot=^<+zJ*4ig8Z-+Z95qvkJ_ndWX`hs1tr(fUo@^jziYh@PM$5X#U`mOT*kkE0n6a&>gTe~DWM4f D1XQw; literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_dandelion_yellow.png b/new_api/flowers/textures/flower_dandelion_yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..500adef8efb469520f44acb82102945520c3cc29 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|54w#*DsIMh&NDbHKmL;Z^NEG`g2}={2>}+hOr8IlpPHs{ z3a2JIa0sL}+}GLmUxi)C=kjLb{}1lnnDVWA;*tmlvnOZP*hgGtV%VT3^Xlr1|L#D$ O7(8A5T-G@yGywo3={m9i literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_dandelion_yellow_pot.png b/new_api/flowers/textures/flower_dandelion_yellow_pot.png new file mode 100644 index 0000000000000000000000000000000000000000..42a0cd7530a726cd72e217454cbcd92d6a12fba1 GIT binary patch literal 462 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!6#=yXs@#Xw?AcrO0(btiIVPik{pF~z5pDoGT z-GxB|1i2*>B!D8E1s;*b3=G`DAk4@xYYs?|y~NYkmHjpkn~1*tw~$|)Kq1Kz*N775 z{M_8syb=cIqSVBa)D(sC%#sWRcTeAd@J2pypsi}2E{-7&5IS(z<`9th2!^ zjx!kPC0#ZRDEq zMon{3yy=-aJD<<9W_DQJrgPw&Ym?%ZtQF~t<4$%OuE-bJvfp5F#PU~~T^9e+KC4_T z&e+xcwZ`rJeY=HDLBe`_vbOC#@z%|9?e3{d+LpcjzJ0M!PweBT7;b%yjzUWuIgtPq8*yS7L7DY(u zb*5C^iV8c%tl1FYk+9~V#Oc-gUFp};o(S-ZZMK>--;K*Lq37X?g=atdp6+?G;B>L- z>i)idm7sIV@wJ^-cR8|d%iqt@#K1Y{Iscr4{O4k_!{=Lj<^hA1!PC{xWt~$(69AQ6 BwTS=# literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_pot.png b/new_api/flowers/textures/flower_pot.png new file mode 100644 index 0000000000000000000000000000000000000000..1c16464ceb8e86d29deae07c146999df3d557fb0 GIT binary patch literal 405 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!6#=yXs@#Xw?AcrO0(btiIVPik{pF~z5pDoGT z-GxB|1i2*>B!D8E1s;*b3=G`DAk4@xYYs?|y~NYkmHjpkn~0`qY|fIeKq1Kz*N775 z{M_8syb=cIqSVBa)D(sC%#sWRcTeAd@J2pyprW^)E{-7{=f>&5IS;&y(ntm2MY zTR9XrZoF_P$R$9D93i85tXeK7<6< z6u;XmKjq=B*zlGA=PuhOp5|q_Z^NUF_fCBIBiGTjMA&ZLmtQBhmuwHcdbH?ie_H>< z^TyX-UHwxkAd|Ml?%|H_DGd8KwivzNHcPaiZ|C84yjNq_`MgRief9sV!Ma)8dFIom zs46@aXk~fEV|+YWU^DyjZ;Kfc(l;)<`!jP12a|E~`&H-v-Q4?km*c_M-OHvsItZ=w u&yca@Ir}TH>Fj6oPd4sM^IIm$)-dp&^()=HdxI{};|!jzelF{r5}E*4QlKjU literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_rose.png b/new_api/flowers/textures/flower_rose.png new file mode 100644 index 0000000000000000000000000000000000000000..4047d3ff25045e93dbb685eabd382c12df65e308 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|QaxQ9Lo7}w zCrGd|^Gkg6oR^sJB!D8E1s;*b3=G`DAk4@xYYs?|y~NYkmHjpkn}`le;n9FDppayVYeb22 zer|4RUI~M9QEFmIYKlU6W=V#EyQgnJcq5-U&{lI#7sn8b(@Q7Wdow!<9IfBH-OFIs zW)8)T8!sp=^>FAE_`n@;Gc#8^Y+BOG@D1C(8AotLE!oudzsp35xl2OSq}*JrN=UET z@<{kuqx`h{)w>x?92r;S-h6+kckvAI#dkG&AEhta8+CE+&rH?{2i=6Xd=1W5t72Fq z+m{{mRzG{`o7b S7hwntX9iDKKbLh*2~7ZBfV|cK literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_tulip.png b/new_api/flowers/textures/flower_tulip.png new file mode 100644 index 0000000000000000000000000000000000000000..56869979b0232f5001753de1495e0bdd956c60b3 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|B0XIkLo7}w zCrGe1%gpIc{PBP5q=)}^O0@moam7H;=*hF>Kc9R|z8{kbzjIFg6sxgFB!D8E1s;*b3=G`DAk4@xYYs?|y~NYkmHjpkn}`8ldHR!+Kq1Kz*N775 z{M_8syb=cIqSVBa)D(sC%#sWRcTeAd@J2pypsjkIE{-7+KXMajgFR&gBBS zxdIobbx27$w=6o4k&&Bq`ljiuMVeB-`IV$*|CW|&nk94VmsHFt7G+b=GIaPuXFFRwimTo9G3Xt;2+bF$oBh7nny;R{k^gtyENeSv9(JiJ-lygH`p^qEcox4b|5ZQxm+AE4%=epL zOSyPNwy%D+o8e3Oj!7HSmQP?vp0P8-fa0FN3G6 KpUXO@geCyHj=u>2 literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_viola.png b/new_api/flowers/textures/flower_viola.png new file mode 100644 index 0000000000000000000000000000000000000000..21e17bdedab64d71b333087d8513aecb6c130494 GIT binary patch literal 140 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|+&o9GliBFv_q`eYoB7>)^pUXO@geCxvrY$c3 literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_viola_pot.png b/new_api/flowers/textures/flower_viola_pot.png new file mode 100644 index 0000000000000000000000000000000000000000..db02084e2c9b3f9753c52673e0132f3bc848b123 GIT binary patch literal 465 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!6#=yXs@#Xw?AcrO0(btiIVPik{pF~z5pDoGT z-GxB|1i2*>B!D8E1s;*b3=G`DAk4@xYYs?|y~NYkmHjpkn}~s)59bj^ppayVYeb22 zer|4RUI~M9QEFmIYKlU6W=V#EyQgnJcq5-U&{j=P7sn8b(_1I)^PgSvI-Q$l-n^uS>%X7o%P^do1{wkhbLVU(ro(i)u3B zuJuM__hqa*d%2jwh{36e#f8&FB#zgxv_|zBE5iok@CWzKu$&N3P*A$D|NWy6zaow5 z1um`=`*G1&fiv7%WA5G)0kUiE*C=u@O=u|d$?~^%I$L;K?8lT$V8}9fy85}Sb4q9e E0GSZB6aWAK literal 0 HcmV?d00001 diff --git a/new_api/flowers/textures/flower_waterlily.png b/new_api/flowers/textures/flower_waterlily.png new file mode 100644 index 0000000000000000000000000000000000000000..0235d8499dfa133d595d653c2a551137ee8a9dbe GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|rhB?LhFF|V zPFP@G@%