changing weathe via LUA script

A forum to discuss custom scenarios, campaigns and modding in general.

Moderator: Panzer Corps 2 Moderators

Post Reply
NETSCAPE
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 127
Joined: Wed Apr 15, 2020 8:43 pm

changing weathe via LUA script

Post 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. :roll:
jeannot le lapin
1st Lieutenant - 15 cm sFH 18
1st Lieutenant - 15 cm sFH 18
Posts: 827
Joined: Sun Dec 10, 2017 3:29 pm

Re: changing weathe via LUA script

Post by jeannot le lapin »

Lua Scripting Manual...there is an example with weather.

Be more precise in your request.
NETSCAPE
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 127
Joined: Wed Apr 15, 2020 8:43 pm

Re: changing weathe via LUA script

Post 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.
jeannot le lapin
1st Lieutenant - 15 cm sFH 18
1st Lieutenant - 15 cm sFH 18
Posts: 827
Joined: Sun Dec 10, 2017 3:29 pm

Re: changing weathe via LUA script

Post by jeannot le lapin »

Have you figured out Lua scripting or nothing at all?

I did not find an example in the scenarios :(
cicciopastic
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 173
Joined: Mon Oct 26, 2015 9:01 pm

Re: changing weathe via LUA script

Post 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
n0b0dy007
Corporal - 5 cm Pak 38
Corporal - 5 cm Pak 38
Posts: 48
Joined: Sat Dec 07, 2019 3:52 pm

Re: changing weathe via LUA script

Post 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.
asuser
Sergeant Major - SdKfz 234/2 8Rad
Sergeant Major - SdKfz 234/2 8Rad
Posts: 628
Joined: Tue May 28, 2013 8:48 pm

Re: changing weathe via LUA script

Post 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.
sstejona
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 13
Joined: Mon Oct 30, 2017 11:58 am

Re: changing weathe via LUA script

Post 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!
Post Reply

Return to “Panzer Corps 2 Scenario Design”