Page 1 of 1
changing weathe via LUA script
Posted: Sun Nov 22, 2020 3:56 am
by NETSCAPE
Is there any example scenario/lua of changing the weather based on a turn check, or changing the weather within a range of turns?
I have a big ol' Barbarossa multiplayer map just sitting idle because I don't know how to change the weather properly. ...it needs seasons or else it will be kinda silly.

Re: changing weathe via LUA script
Posted: Sun Nov 22, 2020 6:30 am
by jeannot le lapin
Lua Scripting Manual...there is an example with weather.
Be more precise in your request.
Re: changing weathe via LUA script
Posted: Tue Nov 24, 2020 4:04 am
by NETSCAPE
jeannot le lapin wrote: ↑Sun Nov 22, 2020 6:30 am
Lua Scripting Manual...there is an example with weather.
Be more precise in your request.
I have seen the example in the manual. It doesn't help me much.
Anyways, to be more specific than my op is...
I want to change the weather from summer, to fall, to winter - all within one scenario (Barbarossa AGC/AGN Multiplayer map).
I see this going one of two ways:
a) manually set all weather parameters for every turn, or a range of turns (ie a season)
-or-
b) adjust the percentage chances of clouds, rain ect to simulate season changes (this would obviously include changing to sub-zero temp in winter)
I understand all the weather options in the editor and there effects. I just don't know how to go about lua scripting the first method. I am not sure if the second method is even possible via lua.
Re: changing weathe via LUA script
Posted: Tue Nov 24, 2020 3:32 pm
by jeannot le lapin
Have you figured out Lua scripting or nothing at all?
I did not find an example in the scenarios

Re: changing weathe via LUA script
Posted: Tue Mar 30, 2021 12:53 pm
by cicciopastic
NETSCAPE wrote: ↑Tue Nov 24, 2020 4:04 am
I want to change the weather from summer, to fall, to winter - all within one scenario (Barbarossa AGC/AGN Multiplayer map).
I see this going one of two ways:
a) manually set all weather parameters for every turn, or a range of turns (ie a season)
-or-
b) adjust the percentage chances of clouds, rain ect to simulate season changes (this would obviously include changing to sub-zero temp in winter)
I understand all the weather options in the editor and there effects. I just don't know how to go about lua scripting the first method. I am not sure if the second method is even possible via lua.
hi netscape,
did u solve the wheather problem via LUA? i've got the same problem
Re: changing weathe via LUA script
Posted: Sat Apr 10, 2021 7:42 pm
by n0b0dy007
NETSCAPE wrote: ↑Tue Nov 24, 2020 4:04 am
I want to change the weather from summer, to fall, to winter - all within one scenario (Barbarossa AGC/AGN Multiplayer map).
I see this going one of two ways:
a) manually set all weather parameters for every turn, or a range of turns (ie a season)
-or-
b) adjust the percentage chances of clouds, rain ect to simulate season changes (this would obviously include changing to sub-zero temp in winter)
I understand all the weather options in the editor and there effects. I just don't know how to go about lua scripting the first method. I am not sure if the second method is even possible via lua.
As currently implemented, you'd have to go with option a. The relevant fields are:
Code: Select all
world.weather
world.ground_state
world.humidity
world.weather_forecast
world.cold_winter
For option b, the scenario Time & Date (specifically, Month and Season) and Weather parameters would have to be exposed via the Lua API, along with some methods to handle the changes you want. If they exist, they're not documented anywhere we can see.
At the risk of creating a redundant update problem (between the scenario definition in the editor and the corresponding scenario script), you could implement a
StartTurnAction effect function during round 0 to set the Time & Date and Weather parameters as properties on a Lua variable in your scenario script, then use/update it in one or more
NewRoundAction condition/effect functions as desired.
Re: changing weathe via LUA script
Posted: Sun Apr 11, 2021 6:17 am
by asuser
That is probably not enough.
We tested this with the weather settings in a LUA file and it didn't work (completely). Rain comes, but aircraft could still be used, despite the instruction/special command:
"air_operations = false" ...
... as a definition from the weather file.
This command could be added to your list.
My assumption is that if "dry" is set in the scenario parameters in the editor - "dry" has a higher priority and blocks the "no-fly" option. Was reported in the bug area some days ago.
Re: changing weathe via LUA script
Posted: Sat Nov 02, 2024 10:08 am
by sstejona
Can someone please show me what the lua script would look like if you want to change the weather in the scenario?
Thanks!