commit c7d5ff00de3c0f2f2479509d449b4979d415b438 Author: Mat Date: Mon Aug 4 03:00:35 2014 +0100 Initial commit diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..7741c9c --- /dev/null +++ b/README.txt @@ -0,0 +1,4 @@ +rain 0.1.0 by paramat +For latest stable Minetest back to 0.4.8 +Depends default bucket +Licenses: code WTFPL, textures CC BY-SA diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..ba6a3b3 --- /dev/null +++ b/init.lua @@ -0,0 +1,109 @@ +-- rain 0.1.0 by paramat +-- For latest stable Minetest and back to 0.4.8 +-- Depends default bucket +-- License: code WTFPL, textures CC BY-SA + +-- Parameters + + + +-- Nodes + +minetest.register_node("rain:cloud", { + description = "Rain Cloud", + drawtype = "glasslike", + tiles = {"rain_cloud.png"}, + paramtype = "light", + is_ground_content = false, + sunlight_propagates = true, + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + post_effect_color = {a=23, r=241, g=248, b=255}, +}) + +minetest.register_node("rain:rain", { + description = "Rain", + drawtype = "plantlike", + tiles = { + { + name="rain_rain.png", + animation={type="vertical_frames", + aspect_w=16, aspect_h=16, length=0.25} + } + }, + paramtype = "light", + is_ground_content = false, + sunlight_propagates = true, + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, +}) + +-- ABM + +-- Spawn raincloud above grass + +minetest.register_abm({ + nodenames = {"default:dirt_with_grass"}, + interval = 13, + chance = 2048, + action = function(pos, node) + local x = pos.x + local y = pos.y + local z = pos.z + local c_air = minetest.get_content_id("air") + local c_rain = minetest.get_content_id("rain:rain") + local c_cloud = minetest.get_content_id("rain:cloud") + + local vm = minetest.get_voxel_manip() -- volume for cloud check + local pos1 = {x=x-64, y=104, z=z-64} + local pos2 = {x=x+95, y=104, z=z+95} + local emin, emax = vm:read_from_map(pos1, pos2) + local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) + local data = vm:get_data() + + for vi in area:iterp(emin, emax) do -- check volume is clear of cloud + if data[vi] == c_cloud then + return + end + end + + local vm = minetest.get_voxel_manip() + local pos1 = {x=x, y=y-48, z=z} + local pos2 = {x=x+31, y=y+134, z=z+31} + local emin, emax = vm:read_from_map(pos1, pos2) + local area = VoxelArea:new({MinEdge=emin, MaxEdge=emax}) + local data = vm:get_data() + local vvii = emax.x - emin.x + 1 -- vertical vi interval + -- local nvii = (emax.y - emin.y + 1) * vvii + + for y = 104, 135 do -- spawn cloud and rain columns + for k = 0, 31 do + local vi = area:index(x, y, z + k) + for i = 0, 31 do + data[vi] = c_cloud + if y == 104 and math.random() < 0.25 + and k >= 4 and k <= 27 and i >= 4 and i <= 27 then + local vir = vi - vvii + for fall = 1, 144 do + if data[vir] == c_air then + data[vir] = c_rain + else + break + end + vir = vir - vvii + end + end + vi = vi + 1 + end + end + end + + vm:set_data(data) + vm:write_to_map() + vm:update_map() + end, +}) diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..c73f8ae --- /dev/null +++ b/license.txt @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/textures/rain_cloud.png b/textures/rain_cloud.png new file mode 100644 index 0000000..192f9c8 Binary files /dev/null and b/textures/rain_cloud.png differ diff --git a/textures/rain_rain.png b/textures/rain_rain.png new file mode 100644 index 0000000..468daba Binary files /dev/null and b/textures/rain_rain.png differ