Page 1 of 1

Conception for a weather mod

PostPosted: Sun Aug 19, 2012 15:01
by PilzAdam
Hello everyone!
What do you think about this laggy way to create rain?
http://ompldr.org/vZjVxcQ/weather.zip
Start/stop rain with the command /rain

PostPosted: Sun Aug 19, 2012 17:09
by Echo
Nice effect!
Wouldn't it be enough if it would rain in a smaller cube around the player? Else you get strange moiree / repeating effects.

PostPosted: Sun Aug 19, 2012 18:21
by qwrwed
It's good, but typing /rain a second time doesnt seem to stop it, and like Echo said, there are lots of repeating effects.

PostPosted: Sun Aug 19, 2012 21:05
by rubenwardy
Is it sprites in 3d, or a image animation overlay?

image animation overlay is less laggy:

http://minetest.net/forum/viewtopic.php?pid=33583#p33583

PostPosted: Sun Aug 19, 2012 22:21
by leo_rockway
PilzAdam, you rock.

PostPosted: Mon Aug 20, 2012 00:24
by VanessaE
Very impressive! It looks like you're basically replacing all air nodes with an animated rain node. I might suggest adding a small random number to each raindrop's initial X/Z position to get rid of the moire pattern. Also, I would suggest a smoother animation - at least 4x as many frames (but with the same length of time for the loop).

PostPosted: Mon Aug 20, 2012 07:29
by Echo
Is it possible to detect the clouds in the sky? I never tried. If it is possible, then there should be rain only direct under the clouds.

PostPosted: Mon Aug 20, 2012 09:35
by PilzAdam
Echo wrote:Is it possible to detect the clouds in the sky? I never tried. If it is possible, then there should be rain only direct under the clouds.

Its not possible.

PostPosted: Mon Aug 20, 2012 09:36
by PilzAdam
Echo wrote:Nice effect!
Wouldn't it be enough if it would rain in a smaller cube around the player? Else you get strange moiree / repeating effects.

Thats not easy. But I see what i can do.

PostPosted: Mon Aug 20, 2012 09:36
by PilzAdam
qwrwed wrote:It's good, but typing /rain a second time doesnt seem to stop it, and like Echo said, there are lots of repeating effects.

It needs some time.

PostPosted: Mon Aug 20, 2012 09:37
by PilzAdam
rubenwardy wrote:Is it sprites in 3d, or a image animation overlay?

image animation overlay is less laggy:

http://minetest.net/forum/viewtopic.php?pid=33583#p33583

But how to do this in lua?

PostPosted: Mon Aug 20, 2012 09:37
by PilzAdam
VanessaE wrote:Very impressive! It looks like you're basically replacing all air nodes with an animated rain node. I might suggest adding a small random number to each raindrop's initial X/Z position to get rid of the moire pattern. Also, I would suggest a smoother animation - at least 4x as many frames (but with the same length of time for the loop).

This is not a mod so the graphics are very basic.

PostPosted: Mon Aug 20, 2012 09:59
by rubenwardy
PilzAdam wrote:
rubenwardy wrote:Is it sprites in 3d, or a image animation overlay?

image animation overlay is less laggy:

http://minetest.net/forum/viewtopic.php?pid=33583#p33583

But how to do this in lua?


isnt there a minetest.drawimageonscreen or similar command?

PostPosted: Sat Nov 24, 2012 17:10
by 4aiman
In the minecraft rain and snow effects seems to be just a textures on a 4 plains which "surround" player.
So I suggest following:
- create 4 entities 1x2x0 (plains)
- apply to each of them some animated rain texture on the one side and tranparent texture on the other (see "animated torches" mos)
- make this entities to face the player (see "snow" mod)
- re-place that entities around player on every server time tick
- coordinates should be like so: {-0.5, 0.5, -0.5} for the 1st one, {0.5, 0.5, -0.5} for the second, {-0.5, 0.5, 0.5} for the 3rd and {0.5, 0.5, 0.5} for the last one:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
 __ __ __
|  |  |  |
|__|/\|__|
| /|PP|\ |
|_\|__|/_|
|  |\/|  |
|__|__|__|

I tried to draw 9 blocks, PP = player and the diagonal lines = 4 entities, placed in rhombus-like shape.



This way every player would see animated side of his "raining entity" and would "see" empty "back side" of the other players' "raining entities".

I tried to do this on my own, but I'm not so good at lua or modding for minetest...
Someone with skill may check above things to make lightweight but working weather.

PostPosted: Sat Nov 24, 2012 17:21
by PilzAdam
This is a good idea!
I will code it when I have some time (within the next week).

PostPosted: Sat Nov 24, 2012 19:44
by 4aiman
I managed to add entity in the player's position, but:
1. animation for texture didn't work, when I write smth like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
    textures = {             
             {name="rainanim.png"},
             {name="rainanim.png", animation={type="vertical_frames", aspect_w=48, aspect_h=48, length=3.0}},
},


2. I ended up in need to add "owner" property, so that if player goes offline, entities would be destroyed.

PostPosted: Sun Nov 25, 2012 11:23
by PilzAdam
There is no animation for entity. You have to change the object properties in on_step().

PostPosted: Mon Nov 26, 2012 09:09
by 4aiman
Sorry for stupid question, but....
Do I need to change textures property in the on_step() event or I should use set_properties and pass textures table as a parameter? :blush:

PostPosted: Mon Nov 26, 2012 09:26
by PilzAdam
4aiman wrote:Sorry for stupid question, but....

There are no stupid questions, just stupid answers ;-)
4aiman wrote:Do I need to change textures property in the on_step() event or I should use set_properties and pass textures table as a parameter? :blush:

You cant set the animation as a parameter in set_properties(). You need to setup a timer in on_step() like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
timer = 0,
on_step = function(self, dtime)
    self.timer = self.timer + dtime
    if self.timer < 0.25 then
        return
    end
    self.timer = 0
end,

After this you set the next texture of the animation:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local animation_frames = 8
[...]
timer = 0,
anim_step = 0,
on_step = function(self, dtime)
    self.timer = self.timer + dtime
    if self.timer < 0.25 then
        return
    end
    self.timer = 0
    self.anim_step = (self.anim_step+1)%animation_frames
    self.object:set_properties({
        textures = {
            "rain_inside_animated.png^[verticalframe:"..16*animation_frames..":"..self.anim_step},
            "rain_outside_animated.png^[verticalframe:"..16*animation_frames..":"..self.anim_step},
        },
    })
end,

Note: This is untested code.

PostPosted: Mon Feb 11, 2013 15:21
by Likwid H-Craft
Hey Adam I made my own rain textures for my, texture pack so if you like use it you can:D

PostPosted: Mon Feb 11, 2013 17:26
by 4aiman
It's better to wait for approval of particle spawners :)

PostPosted: Thu Feb 14, 2013 17:02
by Casimir
@PilzAdam
I tested that code, and it works so far that it is an animation. But it does not show a complete picture but only one horizontal line stretched. To be precise the lines 1 to 8.

It seems to me that those lines are incomplete:
PilzAdam wrote:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
        textures = {
            "rain_inside_animated.png^[verticalframe:"..16*animation_frames..":"..self.anim_step},
            "rain_outside_animated.png^[verticalframe:"..16*animation_frames..":"..self.anim_step},
        },

( replace }, at the end of the lines with .."]" to make it work)

edit:
Found it. It has to be
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
"rain_inside_animated.png^[verticalframe:"..animation_frames..":"..self.anim_step.."]"

PostPosted: Thu Feb 14, 2013 21:23
by chase programer
i want lava rain for fun =0 [img]dog[/img]

PostPosted: Thu Feb 14, 2013 23:53
by nomohakon
chase programer wrote:i want lava rain for fun =0 [img]dog[/img]

I guess acid rain will be better.

PostPosted: Fri Feb 15, 2013 02:09
by Josh
Having rain in the game would be a refreshing idea, expecially the players who have heatwaves in their countries ;)
We could also have lightning which could set fire to trees. And storms which damage the land.
Lightning and storms are probably impossible now. But later on it could be possible :D

PostPosted: Fri Feb 22, 2013 01:10
by GJH105775
qwrwed wrote:It's good, but typing /rain a second time doesnt seem to stop it, and like Echo said, there are lots of repeating effects.


"lik echo said, there are ... repeatting effects"

PostPosted: Tue Mar 11, 2014 07:39
by Gael de Sailly
How can I download this mod ? The link does not work.

PostPosted: Tue Mar 11, 2014 09:57
by 4aiman
You want another weather mod or inbuilt FM weather feature. Use search, as I don't have a link to provide. You may want to search for "snow" and "rain" ;)

PostPosted: Tue Mar 11, 2014 10:56
by fishyWET
Gael de Sailly wrote:How can I download this mod ? The link does not work.

Ompldr.org is down, therefore all downloads from that site won't be downloadable.
Try this https://forum.minetest.net/viewtopic.php?id=5245
or https://forum.minetest.net/viewtopic.php?id=6854

PostPosted: Tue Mar 11, 2014 12:42
by Gael de Sailly
Thank you :-)