From cb0719b7dd63324a45432f83c4ac5f63db319a29 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 24 Mar 2013 14:40:18 +0100 Subject: [PATCH] Initial upload --- modpack.txt | 0 weather/command.lua | 15 +++++ weather/init.lua | 50 ++++++++++++++++ weather/rain.lua | 24 ++++++++ weather/snow.lua | 72 ++++++++++++++++++++++++ weather/textures/weather_rain.png | Bin 0 -> 3312 bytes weather/textures/weather_snow.png | Bin 0 -> 2120 bytes weather/textures/weather_snow_cover.png | Bin 0 -> 647 bytes 8 files changed, 161 insertions(+) create mode 100644 modpack.txt create mode 100644 weather/command.lua create mode 100644 weather/init.lua create mode 100644 weather/rain.lua create mode 100644 weather/snow.lua create mode 100644 weather/textures/weather_rain.png create mode 100644 weather/textures/weather_snow.png create mode 100644 weather/textures/weather_snow_cover.png diff --git a/modpack.txt b/modpack.txt new file mode 100644 index 0000000..e69de29 diff --git a/weather/command.lua b/weather/command.lua new file mode 100644 index 0000000..b9c4a09 --- /dev/null +++ b/weather/command.lua @@ -0,0 +1,15 @@ +minetest.register_privilege("weather", { + description = "Change the weather", + give_to_singleplayer = false +}) + +-- Set weather +minetest.register_chatcommand("setweather", { + params = "", + description = "Set weather to rain, snow or none", -- full description + privs = {weather = true}, + func = function(name, param) + weather = param + save_weather() + end +}) diff --git a/weather/init.lua b/weather/init.lua new file mode 100644 index 0000000..37777d7 --- /dev/null +++ b/weather/init.lua @@ -0,0 +1,50 @@ +-- Weather: +-- * rain +-- * snow +-- * wind (not implemented) + +assert(minetest.add_particlespawner, "I told you to run the latest GitHub!") + +addvectors = function (v1, v2) + return {x=v1.x+v2.x, y=v1.y+v2.y, z=v1.z+v2.z} +end + +save_weather = function () + local file = io.open(minetest.get_worldpath().."/weather", "w+") + file:write(weather) + file:close() +end + +read_weather = function () + local file = io.open(minetest.get_worldpath().."/weather", "r") + if not file then return end + local readweather = file:read() + file:close() + return readweather +end + +weather = read_weather() + +minetest.register_globalstep(function(dtime) + if weather == "rain" or weather == "snow" then + if math.random(1, 10000) == 1 then + weather = "none" + save_weather() + end + else + if math.random(1, 50000) == 1 then + weather = "rain" + save_weather() + end + if math.random(1, 50000) == 2 then + weather = "snow" + save_weather() + end + end +end) + +dofile(minetest.get_modpath("weather").."/rain.lua") +dofile(minetest.get_modpath("weather").."/snow.lua") +dofile(minetest.get_modpath("weather").."/command.lua") + + diff --git a/weather/rain.lua b/weather/rain.lua new file mode 100644 index 0000000..6e09e6c --- /dev/null +++ b/weather/rain.lua @@ -0,0 +1,24 @@ +-- Rain +minetest.register_globalstep(function(dtime) + if weather ~= "rain" then return end + for _, player in ipairs(minetest.get_connected_players()) do + local ppos = player:getpos() + + -- Make sure player is not in a cave/house... + if minetest.env:get_node_light(ppos, 0.5) ~= 15 then return end + + local minp = addvectors(ppos, {x=-9, y=7, z=-9}) + local maxp = addvectors(ppos, {x= 9, y=7, z= 9}) + + local vel = {x=0, y= -4, z=0} + local acc = {x=0, y=-9.81, z=0} + + minetest.add_particlespawner(25, 0.5, + minp, maxp, + vel, vel, + acc, acc, + 0.8, 0.8, + 25, 25, + false, "weather_rain.png", player:get_player_name()) + end +end) diff --git a/weather/snow.lua b/weather/snow.lua new file mode 100644 index 0000000..73fd62d --- /dev/null +++ b/weather/snow.lua @@ -0,0 +1,72 @@ +-- Snow +minetest.register_globalstep(function(dtime) + if weather ~= "snow" then return end + for _, player in ipairs(minetest.get_connected_players()) do + local ppos = player:getpos() + + -- Make sure player is not in a cave/house... + if minetest.env:get_node_light(ppos, 0.5) ~= 15 then return end + + local minp = addvectors(ppos, {x=-9, y=7, z=-9}) + local maxp = addvectors(ppos, {x= 9, y=7, z= 9}) + + local minp_deep = addvectors(ppos, {x=-10, y=3.2, z=-10}) + local maxp_deep = addvectors(ppos, {x= 10, y=2.6, z= 10}) + + local vel = {x=0, y= -0.5, z=0} + local acc = {x=0, y= -0.5, z=0} + + minetest.add_particlespawner(5, 0.5, + minp, maxp, + vel, vel, + acc, acc, + 5, 5, + 25, 25, + false, "weather_snow.png", player:get_player_name()) + + minetest.add_particlespawner(4, 0.5, + minp_deep, maxp_deep, + vel, vel, + acc, acc, + 4, 4, + 25, 25, + false, "weather_snow.png", player:get_player_name()) + end +end) + +local snow_box = +{ + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5} +} + +-- Snow cover +minetest.register_node("weather:snow_cover", { + tiles = {"weather_snow_cover.png"}, + drawtype = "nodebox", + paramtype = "light", + node_box = snow_box, + selection_box = snow_box, + groups = {not_in_creative_inventory = 1, crumbly = 3, attached_node = 1}, + drop = {} +}) + +--[[ Enable this section if you have a very fast PC +minetest.register_abm({ + nodenames = {"group:crumbly", "group:snappy", "group:cracky", "group:choppy"}, + neighbors = {"default:air"}, + interval = 10.0, + chance = 80, + action = function (pos, node, active_object_count, active_object_count_wider) + if weather == "snow" then + if minetest.registered_nodes[node.name].drawtype == "normal" + or minetest.registered_nodes[node.name].drawtype == "allfaces_optional" then + local np = addvectors(pos, {x=0, y=1, z=0}) + if minetest.env:get_node_light(np, 0.5) == 15 then + minetest.env:add_node(np, {name="weather:snow_cover"}) + end + end + end + end +}) +]] diff --git a/weather/textures/weather_rain.png b/weather/textures/weather_rain.png new file mode 100644 index 0000000000000000000000000000000000000000..39b153c44b72695e7c44e5ee1ca2c0d71146c1a7 GIT binary patch literal 3312 zcmeHJ30qUw7Tq@!A%e(YWfFpj0v5$0lLeCqEm8`^5fp4FQ=o#R3<{{^Mihq@iBiA; z!LPQWMNmtb6q_g@;Q`_Rs0@N72o|dt0f~gsdl`jxZ%#?3~Ped_MSval2u1N07+;@1OIR#J3zv z+-}mUu@c8T#70&L^G#g!v}^zW>wgmgZ;#wzfw>B*+3JPBeS#@VrAE@?gi9o)j>Lg9 zVtyhTJ-QP1Md{y=TQ50{MR<1R3@uB_0cDYp3JS}L#)GQPoltYnJhGMLJ7LNM%I_5C zvTPer9x054Z?=`cXwDpt9{nJ6>ND7Lc(A=j$BX*7~Lk<-UBHyWG^ ze@%Ov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qXCKB^d004`YZkMXzd;|=!T)`UHpp5s+C7*@_Fv>-9v2jN@U>eXa` zvEzTlZ@x1)wE8mwKt`AaNi3XM9RNtR_{s(|)Z-GiC=sa|^PD7<>(-VQ{uu#(8s5Lv zs}%tA!TkkVD5a#rLGtx9LzL**h%Gi2S6UQ^t9+UZc_cyf(sg?)$us?Dv<@)Vc}F`( zJer_2Z!~ylciH!;O$oLMto4M+;q2Xy5%}zu5`9d@>MGxlId3g!t8U>-t6TJ-DVeS- zlW3_U80?qMi({*kCZfAyH)WpZ^JN@02NT#K*;rqv0AxmC`?A;l5J(nY+?CgftBk|p zbW1M^pmFL`lC7iSSjN)%S=+vXsF7?lx(y_N!`Jht}0=0z&|t~(=sNcRCB zv&Mh2c~;H>RFBsm^}}Mp13{;RA1wfoNaoS<=vf0o1?G$ zLJ_=IDaoQqo8}{H96Mo0>`rf&khsUMc&Kg`3NPDhO84UkWUmvX>3;V?MWhv4Z6VP0 zI*pE@vD$+A0+U-8>3v0H2T@+{R+Y>QhHd^*Jt8@Y(yz4#KxFxptms_&93dMEq{IVAG#m^rUB9HK7^G{Z$`miUfvd7f@O5OM z8CoiRG$Zh(z?l+=s^p*^cy&EPd|w2%(^UszeP>%^EXj3^(0xM(Fa11sShD;krpU|6D#+#JgrdJ)VElv7uJ5;ddTC-I zeI@+*ER}*Bs?tqkBt6HuG_;D9biVutWM+4$Lt_WopDK@hmw~S3+RdWY&eY#V_X?yO zlx!E)9$~0yc}qm-6x^rJF0bp~#znI7!y+of-K0RGgWMcOX%I7ztPe{9feKo8-G(nF_1`{$B+7R<4gY_-~`m*c<== literal 0 HcmV?d00001 diff --git a/weather/textures/weather_snow.png b/weather/textures/weather_snow.png new file mode 100644 index 0000000000000000000000000000000000000000..8c44f7aff36360439073745ed99ede620c8093d4 GIT binary patch literal 2120 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&zE~)R&4Yzkn25lDE4H!+#K5uy^@npa^Gy zM`SSr1Gg{;GcwGYBLNg-FY)wsWxvZT!Kr3`guwil(-P*aT6O)<_q?}``x>V_`tVtBLVf|0fRXGB zA%}ervu3MG+{m@%YC6R5iPw+8X*r84(-UckK@HU(rs_|~SJ-2rA*67BbKz30nn;zX z;;ZH-%oCg#o=Bh26l$nBe`F&YkDkU_%OIAYY)Z>Hm$NC{_hV4Vu`*C?sJY)boAKa^ zyxV7!9QMs+aQHT50Vl)HYYY#1StjKFFthMqE#5AvuU5<`^GWxRmV>8BY2Ponqj-0*M<%Z^tPFyCMa9DG6#Qtk@f@eaNE`smBMubDsb z&P=TI(&Dq12if1Z?XIQHdA^3s5OJvmsAd;XZczbWXg_KP+9hTJDK7hc4f{`+T3?vH&B3Ihg6h_b#(& z#(O2l`zAVxFkEE;5}T zoLC=OzhS=*M*@(xD6Ic_RV;a%--=bMzTcbQzs)o~CFz@{OGO3!|(Kc7|1R(-JT?#smr8axX3Ef^I_yk;!*_z@!vipUJR>nuOZ zm>3oc_i8de`TZ`2nZdp63RLiBaFZG^17WukMKqx(H1zlJ$oYpShl@Os{;|R0jKl`f zdCVu;YCiAHE$_5(O)6$FF>ODkx%l4RgIN zpPrs#>VEr^<|n@2+;+2zWlaRbs#WuZ3*PTtZpNr^U#emH-$gf*&cw+43uO?x56l|C z%)dvM@3(8PN<`%?-)iG2`A?)fwE5nvwJgbIaM-7xcW7^k!8VT>Ob+`Pfo?t4VY{p# z2AKO=#MtjUvi)RJXIOao;0w)zDNH~yUk){4P+3;6So2}m%Lgm==RN|a_(N*K!t5u^ zEf_iG_^kW02B;!oVkh&2{5cE)7KOm%jU@;`LI>XO*vTSa+$;o45nC*FxN4p-_haCg x%jd(XaQ{s9W|o>erjVrGD~wu7GBmvY!zdWFSn=4BY5E|OJYD@<);T3K0RU0DKWP8} literal 0 HcmV?d00001 diff --git a/weather/textures/weather_snow_cover.png b/weather/textures/weather_snow_cover.png new file mode 100644 index 0000000000000000000000000000000000000000..9221a5ae8b71af9f88979dbaa707aadc32ac127d GIT binary patch literal 647 zcmV;20(kw2P)0b&F3{x_Ak zz=mNMnh7Pcuho?Ydj$s{4w;z&0~i1S01TixjR-^&P*ocPKyZ$TSb_IarfSbQ0*}XI zj`5N61mbHF0fRNVmnNXdYmD4M;k>rgdd<_zywX0-ORcM<^*y=MYowzrmg zf0(IRX8ycwmy}v-TI*!qh^RFH5uj>z)~X_#st~Djf#@UW)%)n&@q8jBnsbX0zzMJd z$+;Kjh`AEo_x-5#Wm%;6Lc}5XIrrlLpuhyEm<6*FI85bxAP?Dh{zLtVm?&g_dSRls<&nN znzM*F5q7|r5We5H91)4gk5UwPyWPC%#kraD-^+40`)x2l0W}+{y>|nC&0!*T hj)6V~h;&X7`5!$fP43hinl1nU002ovPDHLkV1m8A8EOCk literal 0 HcmV?d00001