Keeping track of rain in mm

Your forum for all discussions around Modding.
sablerock
Posts: 119
Joined: Sat Dec 10, 2022 1:58 pm

Keeping track of rain in mm

Post by sablerock »

Is there anyway with LUA to get the rain stats when it rains?
sablerock
Posts: 119
Joined: Sat Dec 10, 2022 1:58 pm

Re: Keeping track of rain in mm

Post by sablerock »

Nobody??? Anybody???
Giants?????
Drmattymd
Posts: 805
Joined: Sun Oct 30, 2016 3:54 pm
Location: VA, USA

Re: Keeping track of rain in mm

Post by Drmattymd »

I have zero knowledge of writing LUA scripts but here are my thoughts on what it would take.
First, you would have to establish rain water as a fill type or other sort of tangible item.
Then you would have to establish a formula for amount of rain for how long and how hard it rains, so you would have to have different , lets call it rain densities.
Once you have that then calculating the amount of rain would be easy but you would need place to display that info, either incorporated into an existing GUI or have its own new GUI for that info.

So, I believe what you want to do could be done, but its not as simple as just showing the stats .
Playing on PC and PS4
sablerock
Posts: 119
Joined: Sat Dec 10, 2022 1:58 pm

Re: Keeping track of rain in mm

Post by sablerock »

No, that’s not what I want to do.
Rain is already built into base game. I want a method to calculate how much mm fell when triggered by base game
User avatar
Dogface
Posts: 1097
Joined: Mon Nov 28, 2016 3:02 pm
Location: PC ⛽ USA

Re: Keeping track of rain in mm

Post by Dogface »

Does rain affect crops?
It affects harvest efficiency, but does it affect growth?
XPModder
Posts: 76
Joined: Thu Oct 30, 2014 2:45 pm

Re: Keeping track of rain in mm

Post by XPModder »

Dogface wrote: Mon May 13, 2024 2:24 am Does rain affect crops?
It affects harvest efficiency, but does it affect growth?
In the basegame, no.
Would be cool to have that as a mod, but apart from combines etc checking if it rains when harvesting rain is purely a visual thing afaik. It definitely doesnt effect growth in any way. With the same settings, crops will grow at the same speed and have the same yield if it rains 24/7 for the whole time as if it doesnt rain once...
My guess to why that is would be that either Giants didnt see that as important and just havent gotten to it yet, or they deliberately decided against it to not frustrate players if they keep having terrible yield or the crops die due to too much or too little rain...
Das Universum ist unvorstellbar groß und wir sind im Vergleich dazu winzig.

Daher kann mir jemand der unter uns Winzlingen Unterschiede in Hautfarbe oder Herkunft sucht, nur Leid tun, weil seine Sichtweise so begrenzt ist!

Fremdenfeindlichkeit ist Menschenfeindlichkeit!
Drmattymd
Posts: 805
Joined: Sun Oct 30, 2016 3:54 pm
Location: VA, USA

Re: Keeping track of rain in mm

Post by Drmattymd »

sablerock wrote: Sun May 12, 2024 11:01 pm No, that’s not what I want to do.
Rain is already built into base game. I want a method to calculate how much mm fell when triggered by base game
Exactly, you want to calculate the quantity of rain. But you would have to do the things I said in order to that since there currently is no rain amounts. Rain is merely an esthetic at this point.
Playing on PC and PS4
sablerock
Posts: 119
Joined: Sat Dec 10, 2022 1:58 pm

Re: Keeping track of rain in mm

Post by sablerock »

Yes and me and XPMODDER is working on how we’re going to do it. You can’t harvest in rain, so there’s a system variable for that, meaning at some point that variable is reset so that harvesting can continue.
Drmattymd
Posts: 805
Joined: Sun Oct 30, 2016 3:54 pm
Location: VA, USA

Re: Keeping track of rain in mm

Post by Drmattymd »

But there is still no quantification of rain. Its simply, Raining, cant harvest, stops raining, resume harvest.
Playing on PC and PS4
TheSuBBie
Posts: 547
Joined: Wed Jun 10, 2020 11:38 am

Re: Keeping track of rain in mm

Post by TheSuBBie »

This might help

rainScale = g_currentMission.environment.weather:getRainFallScale()
Tiredasagiraffe
Posts: 55
Joined: Fri Nov 30, 2018 1:40 am

Re: Keeping track of rain in mm

Post by Tiredasagiraffe »

The likelihood of rain is defined by the environment.xml either base game or for each modded map if the modder has specified a custom environment.xml. And links to the above by The Subbie?
TheSuBBie
Posts: 547
Joined: Wed Jun 10, 2020 11:38 am

Re: Keeping track of rain in mm

Post by TheSuBBie »

Further to the above post the higher the preciptation the heavier the rain.
But for your premise to work you will have to assign a value in mm to the precipitation value

Liquid precipitation
Rainfall (including drizzle and rain) is usually measured using a rain gauge and expressed in units of millimeters (mm) of height or depth. Equivalently, it can be expressed as a physical quantity with dimension of volume of water per collection area, in units of liters per square meter (L/m2); as 1L=1dm3=1mm·m2, the units of area (m2) cancel out, resulting in simply "mm". This also corresponds to an area density expressed in kg/m2, if assuming that 1 liter of water has a mass of 1 kg (water density), which is acceptable for most practical purposes. The corresponding English unit used is usually inches. In Australia before metrication, rainfall was also measured in "points", each of which was defined as one-hundredth of an inch.[16]

https://wind101.net/raindrop/
XPModder
Posts: 76
Joined: Thu Oct 30, 2014 2:45 pm

Re: Keeping track of rain in mm

Post by XPModder »

When I get home later Ill take a look at g_currentMission.environment.weather and what functions and variables it contains.
I do also suspect that the game does not have a proper system for rain other then "it rains" and some kind of quantity (that you get via the getRainfallScale function)...
I agree that getting an amount of rain in mm per m² will probably require assigning a fix amount to a specific RainfallScale. The easiest would probably be to assign a certain amount of rain to a RainfallScale of 1 and then one can just multiply that with the rainfallScale to get the amount its currently raining...
Another thing to consider is the time. The amount of rain is measured depending on a certain amount of time. Like 1mm of rain in 1 hour is something completely different from 1mm of rain in 1 day...
There is no momentary measurement of rain. As in you cant say "Right now its raining 1mm". Its always relative to the time over which it is measured.
So overall I think the way to do a measurement of rain would be to assign a certain value to rainfallScale of 1 over 1 hour or similar.
Like defining, if it rains at a rainfallScale of 1 for exactly 1 hour (ingame time) that results in x mm.

Idk if it would make sense to define rain as a fillType for sablerock's use though. That might be unnecessary...
Though I cant help but think that it would also be kind of cool if a trailer sitting outside in the rain would slowly fill with water...
And vehicles getting a certain amount of dirt removed by rain (though ideally that would be capped so a absolutely filthy tractor doesnt get perfectly clean from sitting in the rain, but one if just a bit of dust and dirt on it might...)
Das Universum ist unvorstellbar groß und wir sind im Vergleich dazu winzig.

Daher kann mir jemand der unter uns Winzlingen Unterschiede in Hautfarbe oder Herkunft sucht, nur Leid tun, weil seine Sichtweise so begrenzt ist!

Fremdenfeindlichkeit ist Menschenfeindlichkeit!
XPModder
Posts: 76
Joined: Thu Oct 30, 2014 2:45 pm

Re: Keeping track of rain in mm

Post by XPModder »

Ok, I now have a list of all variables and functions in g_currentMission.environment.weather.
Ill just write down those that seem like they have something to do with rain here.

Code: Select all

isRainAllowed: true
timeSinceLastRain: 100200000
getIsRaining()
getTimeUntilRain()
getRainFallScale()
getGroundWetness()
getCurrentWeatherType()
getTimeSinceLastRain()
setIsRainAllowed()
I have written all functions with no parameters here, but this does not mean that they do not have any parameters. To my knowledge there is no easy way to get a list of parameters for a function in lua, so I cant actually get the parameters.
So read the "()" just as an indication that it is a function with an unknown number of parameters.

There is lots of stuff about temperature in there btw, but that doesnt really help about the rain issue...

So clearly the game has the ability to disable rain altogether via the setIsRainAllowed() function, which I bet is modifying the value of the isRainAllowed variable.
Other then that, there is the time since it last rained (not sure what unit that is in, but probably something like ms or s...
We already knew about getRainFallScale() and its not surprising to find getIsRaining() and getTimeSinceLastRain(). The later of which will probably just return the contents of the variable with that name.
getCurrentWeatherType() is probably not going to be any more helpful then getIsRaining().
getTimeUntilRain() and getGroundWetness() are kind of interesting, but I dont think they really help in this at all...

So in summary: There is nothing really there that would help with the problem in question apart from getRainFallScale() which we already knew about...
Das Universum ist unvorstellbar groß und wir sind im Vergleich dazu winzig.

Daher kann mir jemand der unter uns Winzlingen Unterschiede in Hautfarbe oder Herkunft sucht, nur Leid tun, weil seine Sichtweise so begrenzt ist!

Fremdenfeindlichkeit ist Menschenfeindlichkeit!
sablerock
Posts: 119
Joined: Sat Dec 10, 2022 1:58 pm

Re: Keeping track of rain in mm

Post by sablerock »

Well guys we’re getting somewhere!!
Maybe we can move forward with this.
Off course I’m going to need all the help I can get, if someone doesn’t surpass me!
If it works it will apply to whole map area, which I don’t really have problems with
Post Reply