From 995789a790a1cffa01222004af778e61f9efe305 Mon Sep 17 00:00:00 2001 From: Misael Roman Date: Sat, 29 Sep 2012 20:21:47 -0500 Subject: [PATCH] added plants Added the first plants to the harrytest mod. These will be used for potions and such. --- htplants/depends.txt | 2 + htplants/init.lua | 86 +++++++++++++++++++++++++++ htplants/readme.txt | 1 + htplants/textures/plant_aconite.png | Bin 0 -> 387 bytes htplants/textures/plant_aloe.png | Bin 0 -> 317 bytes htplants/textures/plant_anjelica.png | Bin 0 -> 334 bytes htplants/textures/plant_arnica.png | Bin 0 -> 384 bytes htplants/textures/plant_asphodel.png | Bin 0 -> 353 bytes htplants/textures/plant_balm.png | Bin 0 -> 587 bytes htplants/textures/plant_trumpet.png | Bin 0 -> 349 bytes 10 files changed, 89 insertions(+) create mode 100644 htplants/depends.txt create mode 100644 htplants/init.lua create mode 100644 htplants/readme.txt create mode 100644 htplants/textures/plant_aconite.png create mode 100644 htplants/textures/plant_aloe.png create mode 100644 htplants/textures/plant_anjelica.png create mode 100644 htplants/textures/plant_arnica.png create mode 100644 htplants/textures/plant_asphodel.png create mode 100644 htplants/textures/plant_balm.png create mode 100644 htplants/textures/plant_trumpet.png diff --git a/htplants/depends.txt b/htplants/depends.txt new file mode 100644 index 0000000..3a7daa1 --- /dev/null +++ b/htplants/depends.txt @@ -0,0 +1,2 @@ +default + diff --git a/htplants/init.lua b/htplants/init.lua new file mode 100644 index 0000000..8196997 --- /dev/null +++ b/htplants/init.lua @@ -0,0 +1,86 @@ +math.randomseed(os.time()) + +local DEBUG = 1 + +local GROWING_DELAY = 500 -- larger numbers = ABM runs less often +local GROWCHANCE = 50 -- larger = less chance to grow + +local HTPLANTS = { + { "Aconite", "aconite", GROWING_DELAY*2, 15, GROWCHANCE*2 }, + { "Aloe", "aloe", GROWING_DELAY, 10, GROWCHANCE }, + { "Trumpet", "trumpet", GROWING_DELAY, 10, GROWCHANCE }, + { "Anjelica", "anjelica", GROWING_DELAY*2, 15, GROWCHANCE*2 }, + { "Arnica", "arnica", GROWING_DELAY, 10, GROWCHANCE*2 }, + { "Asphodel", "asphodel", GROWING_DELAY*2, 15, GROWCHANCE*2 }, + { "Balm", "balm", GROWING_DELAY, 10, GROWCHANCE }, +} + +local dbg = function(s) + if DEBUG == 1 then + print("[HTPLANTS] " .. s) + end +end + +local is_node_loaded = function(node_pos) + n = minetest.env:get_node_or_nil(node_pos) + if (n == nil) or (n.name == "ignore") then + return false + end + return true +end + +spawn_on_surfaces = function(spawndelay, spawnflower, spawnradius, spawnchance, spawnsurface, spawnavoid) + minetest.register_abm({ + nodenames = { spawnsurface }, + interval = spawndelay, + chance = spawnchance, + + 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) + if (n_top.name == "air") and is_node_loaded(p_top) then + if (minetest.env:find_node_near(p_top, spawnradius, spawnavoid) == nil ) + and (minetest.env:get_node_light(p_top, nil) > 4) then + dbg("Spawning "..spawnflower.." at ("..p_top.x..", "..p_top.y..", "..p_top.z..") on "..spawnsurface) + minetest.env:add_node(p_top, { name = spawnflower }) + end + end + end + }) +end + +-- On regular fertile ground, any flower except waterlilies can spawn + +for i in ipairs(HTPLANTS) do + local flowerdesc = HTPLANTS[i][1] + local flower = HTPLANTS[i][2] + local delay = HTPLANTS[i][3] + local radius = HTPLANTS[i][4] + local chance = HTPLANTS[i][5] + + minetest.register_node("htplants:plant_"..flower, { + description = flowerdesc, + drawtype = "plantlike", + tiles = { "plant_"..flower..".png" }, + inventory_image = "plant_"..flower..".png", + wield_image = "plant_"..flower..".png", + sunlight_propagates = true, + paramtype = "light", + walkable = false, + groups = { snappy = 3,flammable=2, flower=1 }, + sounds = default.node_sound_leaves_defaults(), + selection_box = { + type = "fixed", + fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }, + }, + }) + + + spawn_on_surfaces(delay, "htplants:plant_"..flower, radius, chance, "default:dirt_with_grass", "group:flower") + spawn_on_surfaces(delay, "htplants:plant_"..flower, radius, chance, "default:dirt", "group:flower") +end + +-- Crafts (none yet). + + +print("[htplants] Loaded!") diff --git a/htplants/readme.txt b/htplants/readme.txt new file mode 100644 index 0000000..f72ba6b --- /dev/null +++ b/htplants/readme.txt @@ -0,0 +1 @@ +This folder contains ingridients for potions. \ No newline at end of file diff --git a/htplants/textures/plant_aconite.png b/htplants/textures/plant_aconite.png new file mode 100644 index 0000000000000000000000000000000000000000..a88ea16c06ca432974694a0d78912db757a3a731 GIT binary patch literal 387 zcmV-}0et?6P)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ-2}wjjRCwClk}*reKp2Lfubh)p$GIoOM_Bthur3pd=yckg}oyeF#4E*h|-{(*sME6&DiPgdrI z={1mM3bXMVKmlBtV}k@ht{(QtqN;A37e=}!*gg!PSycUvfp>OK@3=C@n=Mz1df&Xg zlR+G&04!IFHa;}DbP{r9jy)XWC-Sv#O?zXkpJ9W9%bNq@FvSK*lS{Y3W;}_*6j$bQ zU7Q1OasLK@4HE5TAR=s{6__%)J>{-20wdrj=GK4U4FIyJ;^kyt0bUehE&`-GifjH z5e1&s+>%yRG0*v&6HfO`IJ+*L$1OodMQg_+hMC=yMKaHc+Sm2>t0%7&oj0Yi{i{3M zlb1$3mHOA8t@?Rpity`r1^@PAZ}-ZcY35D-Kk4kjHZ9+%WL5tIo$M361afBRsni+& z=UT+**-$&-M6hXL-;y;?O|I-ow@C@O#*|l>e72K)YG<0#6%Gc5Wml{xM&D`SWtj2Z zCjA0mz~QM$em%=4ubBB|eMZ{$#dnT6wLDV1>k#DeQNL>ad4{Cb$xCN(W%mKS!{F)a K=d#Wzp$PzNjdoQ4 literal 0 HcmV?d00001 diff --git a/htplants/textures/plant_anjelica.png b/htplants/textures/plant_anjelica.png new file mode 100644 index 0000000000000000000000000000000000000000..973478512abb1243ff538e364ff50ad04b4fde6b GIT binary patch literal 334 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP*5S+ zBgmJ5p-Pp3p`n?9;pcxK{gQ#9)PRBERRRNp)eHs(@%%~gN8NyGuXwsRhE&|zGRc~+ z$w8nko#W!ECWq8+Rn_GSE<{%_Sg^}5yg#U^p{cWA>!AY1$N7(Q%-(!5IO3@`)A!lO zv-=M-WOQ3@x%lt;g40YTkq&2UZZ{m4Dv4}ZC8^PAqddLC!A0iTUz^6IGxi-_9TspV z)HvWOkJi6Pm$@$erLjG1o96rYDCOJ8=Dtb}auK}bCh~0WPgMq<{9t*ZgTe~DWM4fx7&U0 literal 0 HcmV?d00001 diff --git a/htplants/textures/plant_arnica.png b/htplants/textures/plant_arnica.png new file mode 100644 index 0000000000000000000000000000000000000000..f4a3f04a2cda1f094009ce0fb0b5514f14b74d50 GIT binary patch literal 384 zcmV-`0e}99P)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ-21!IgRCwCNlD}%gP!z_0rxfm8`UDOE3t4;#!4BD?I5-x%+o5Bj6zKy9rE{rI zprbGLy<8g1HtQ$S4;b%1XZWir`%3AHCWd9QcVZYEuAIza=}(SiV({zdjlXAg^ZVcXa+iL-ocwLId`yDK(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ-(Md!>RCwBild)>!KoEw%iR|KFVdcXD7ik1}0C(44XAoRtgOA`YZQ6jJz~E`|oL!3_w_?94y=??1b6G1J4TAC7J5w}zh6 zPvdIsl>&mUtpTh4VNr;J0T!!z{x4t*E*#r(R{%zFxu*YGUKciA`T-ur&h&6fd*h{L zgZP5Es?zjB10b{MPW;fY`Sp#UYw<%v-j1a|=-`KjW0DhHFrxI+Z3e({ol1YuaR8^R z0HA3-04^JFO!86}`K*H`Rq3Ynm@f(d`QoMStq6!l@fkahXlR3Dl9zgHywts|&V}Li zE%##pT)GWdu2Wj44uCs=lnhkJ`J!Mn^f+Y&LD!PJJYx0{%XNxsP-QAgKY4j1yuPKX zN6@u=X88Q{DuBCtxFMNj(x}`4nN4>NknexmeEr#Q={94rg8Q-M&|G5n5h}2c`M8N{ z{XqwS-y-hNTmmrcopbR#B5%i{>d&S-3CGsej?g;&D91IM?&uFXoU)=e#$=L->EW8z z!w=1wK{CliN2($L^8EBFLD!ZuSIbxD+GLVRc?7eMT%{QRcMmtN8dps(*?+C}>i!YG Z4*&zh@v>{5qG134002ovPDHLkV1ll13Zei2 literal 0 HcmV?d00001 diff --git a/htplants/textures/plant_trumpet.png b/htplants/textures/plant_trumpet.png new file mode 100644 index 0000000000000000000000000000000000000000..ed3dfebcdd6ec60200889afdf99dbbcefe84880e GIT binary patch literal 349 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP*5S+ zBgmJ5p-Pp3p`n?9;pcxK{gQ#9)PRBERRRNp)eHs(@%%~gN8NyGAA7nuhE&`-6TFe@ zkONPx;L7N`MgT|RjzvvJBc$N zZ;ko%>C+Al&ybB$TDRnxV)zc7cI>H(WMgVr{d09g<;E$j3JgBS9rlFBfAn8{TY}-h z%N;DgSSPTbJ@q!Iu1msgma7C~T>Z*}U2NY3@2pF^^=`%XYAdsTrDgMHX#f8v@Ltqy z^3m-RRC?2Q2c8JJz%OH08$3@`!Mjn1_0NHYy6sD1kEE^t(Ehru^zo5xz2_Gd7rAFI s`28j=T$5Kp=>zj~)=4bp$?uXG+MX?cr7gMs0?@k*p00i_>zopr06`y#rT_o{ literal 0 HcmV?d00001