From 905436c6bfe10d3caddf0fba9c9bd03200db5144 Mon Sep 17 00:00:00 2001 From: Izzy Date: Wed, 5 Jun 2019 18:13:25 -0600 Subject: [PATCH] lightning --- init.lua | 46 +++++++++++++++++++++++++++++++--- textures/storms_lightning.png | Bin 0 -> 707 bytes 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 textures/storms_lightning.png diff --git a/init.lua b/init.lua index 588e7a5..eb08eed 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,8 @@ +storms = {} + + local on = false local sky_defaults = nil @@ -23,6 +26,37 @@ local function get_noise(pos) end +local function randompos(center, dist) + return { + x = center.x + math.random(-dist, dist), + y = center.y, + z = center.z + math.random(-dist, dist), + } +end + + +local function do_lightning(cloudh, pos) + + local h = cloudh - 10 + + while h > -16 do + minetest.add_particle({ + pos = {x=pos.x, y=h, z=pos.z}, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0, z=0}, + expirationtime = .1, + size = 300, + collisiondetection = false, + vertical = true, + texture = "storms_lightning.png", + playername = "singleplayer" + }) + + h = h - 30 + end +end + + minetest.register_craftitem("storms:rainstick", { description = "Magic Rainstick", inventory_image = "default_stick.png^[colorize:gold:80", @@ -60,13 +94,19 @@ minetest.register_craftitem("storms:rainstick", { maxvel = vector.add(vel, {x=5, y=0.5, z=5}), minacc = {x=-0.1, y=0.1, z=-0.1}, maxacc = {x=0.1, y=0.3, z=0.1}, - minexptime = 5, - maxexptime = 10, + minexptime = 2, + maxexptime = 7, minsize = 300, maxsize = 400, texture = "storms_cloud.png^[colorize:black:120", }) + for i = 1,math.random(18) do + minetest.after(math.random(5), function() + do_lightning(pos.y, randompos(pos, 40)) + end) + end + --[[ minetest.add_particlespawner({ amount = 350, @@ -86,7 +126,7 @@ minetest.register_craftitem("storms:rainstick", { ]] if on then - minetest.after(10, function() + minetest.after(5, function() spawn_clouds() end) end diff --git a/textures/storms_lightning.png b/textures/storms_lightning.png new file mode 100644 index 0000000000000000000000000000000000000000..1741e81b6fa0beb0f9620e87845a80bf0ccd8b5a GIT binary patch literal 707 zcmV;!0zCbRP)W*VotJ=;#RC-Q9ub=Vx$!ex9BJ zwzs#z<>e(+9g=<|g``%oe(?Oo z#Rb^h+ywjk`{3Z)Fxg-KGR7m%rfRT|AFf%g~ zWx?|Da$4;VZf|eFz`#J1`mI(A^!4>c-5~^FG6X=o-Ht%-?(Tw}ogJ{Tu>r2GuF_LL zsFjr!u)4Y$WkcxyVJ1kHfR8meI0z;tCej^%IywK>l7NrEYe~YN09T2Gp6>=;6h%?x z4QhPnpI04x4#cWuLvj|#=Yk(VLL-wg!H~U+oV$MBKZY!ZDWq<#OHkV(O%df`rL8#UQ pWdG+6Byt91`DX=W0x|(zt6vOQxki1;MqmH{002ovPDHLkV1hMYId}j7 literal 0 HcmV?d00001