Custom Environment Zones - LUA

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
gcommie
Posts: 18
Joined: Tue Apr 25, 2023 5:32 pm

Custom Environment Zones - LUA

Post by gcommie »

Is there a way of setting the weather in a Custom Environment Zone (CEZ) using LUA?
I can readily create a CEZ using ScenEdit_AddZone({...}) and then view the .weatherprofile, i.e. local CEZ = ScenEdit_AddZone({...}) and then print CEZ.weatherprofile.[temp | rainfall | undercloud | seastate], but not worked out how to alter the default values of 15, 0, 0, 0 respectively.
This is probably quite simple, but I'm new to using LUA.
TIA.
thewood1
Posts: 9930
Joined: Sun Nov 27, 2005 6:24 pm
Location: Boston

Re: Custom Environment Zones - LUA

Post by thewood1 »

There is a lua subforum in the mods section where someone might point you in the right direction.
thewood1
Posts: 9930
Joined: Sun Nov 27, 2005 6:24 pm
Location: Boston

Re: Custom Environment Zones - LUA

Post by thewood1 »

https://commandlua.github.io/assets/Wrappers.html

Use the "zone" wrapper to set the weatherprofile for a zone you add.

Screenshot 2023-11-19 183425.jpg
Screenshot 2023-11-19 183425.jpg (450.75 KiB) Viewed 763 times

I have never used it but, again, check the lua section in mods.
User avatar
lumiere
Posts: 267
Joined: Tue Mar 19, 2019 10:38 am

Re: Custom Environment Zones - LUA

Post by lumiere »

Note that new weather profile must be entered as whole table, like this one:
local cez = VP_GetSide({name="Nature"}):getcustomenvironmentzone("CEZ")
print(cez)
cez.weatherprofile = { rainfall = 5, seastate = 2, undercloud = 3, temp = 20 }
print(cez.weatherprofile)
Unlike ScenEdit_SetWeather(), setting parameters separately will not work.
--they won't work
cez.weatherprofile.rainfall = 5
cez.weatherprofile.seastate = 2
cez.undercloud = 3
cez.temp = 20
"How Do You Stay Calm With A 7,000 Ton Nuclear Predator Listening For Your Heartbeat?"
gcommie
Posts: 18
Joined: Tue Apr 25, 2023 5:32 pm

Re: Custom Environment Zones - LUA

Post by gcommie »

Thanks for the feedback.

thewood1, will try to remember to use the Command: Modern Operations series > Mods and Scenarios > Lua Legion subforum in future. Thanks for pointing it out.

lumiere, thanks for highlighting the syntax for using the wrapper. Don't think this is particularly well documented, but at least I now know how to change the values.

That said, FYI, I have found that running a simple script to create and then set a CEZ results in a error if I then select Missions + Ref. Points > Area / Reference Points Manager > Cust Env Zones > Edit CEZ Data and not all the values are set, though in the console all appears good
Orion Omega
Posts: 3
Joined: Sun Dec 01, 2019 4:11 pm
Location: Berlin

Re: Custom Environment Zones - LUA

Post by Orion Omega »

Thanks lumiere! I too got down to read the data but could not change it. "cez.temp = 20" all the time but nothing happend :D
Post Reply

Return to “Lua Legion”