Not saving SAR Enabled true value?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
KLAB
Posts: 483
Joined: Tue Feb 27, 2007 5:24 pm

Not saving SAR Enabled true value?

Post by KLAB »

Help appreciated as I suspect this is a key store value issue which I have never got my head round:

So the SAR Script I have cobbled together using other people's script is triggered when an aircraft is shot down as follows:


local Mu=ScenEdit_UnitX()
local MuC= Mu.crew
print (MuC)
local elevation = World_GetElevation({latitude=Mu.latitude, longitude=Mu.longitude})
print (elevation)
if elevation < 0 then do
local i= 1, Mu.crew
for planes = 1, Mu.crew, 1 do
local SurvivorsS =
ScenEdit_AddUnit({
type='ship',
dbid=3725,
side='Aircrew',
name=Mu.name .. " " .. "Aircrew".." "..planes,
guid=Mu.guid .." ".."Aircrew".." "..planes,
latitude=Mu.latitude,
longitude=Mu.longitude})
SurvivorsS.SAR_enabled=true
end
end
elseif elevation > 0 then do
local i= 1, Mu.crew
for planes = 1, Mu.crew, 1 do
local SurvivorsL =
ScenEdit_AddUnit({
type='facility',
dbid=2046,
side='Aircrew',
name=Mu.name .. " " .. "Aircrew".." "..planes,
guid=Mu.guid .." ".."Aircrew".." "..planes,
latitude=Mu.latitude,
longitude=Mu.longitude})
SurvivorsL.SAR_enabled=true
end
end
end

It produces a downed aircrew on sea or land etc with one survivor for each crew member which when you check the wrapper is as follows the created unit is:

[object] = SAR_enabled
'Yes'

BUT....
When I save the game in the editor and reload in edit mode it the same downed aircrew(s) is/are then SAR_enabled = 'No'

Any help in what I am missing on how to preserve the values would be much appreciated. I am using this to self teach as I appreciate there are many better scripts than mine for SAR in circulation.

Regards
K
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: Not saving SAR Enabled true value?

Post by KnightHawk75 »

KLAB wrote: Fri Nov 25, 2022 12:45 pm ....
BUT....
When I save the game in the editor and reload in edit mode it the same downed aircrew(s) is/are then SAR_enabled = 'No'

Any help in what I am missing on how to preserve the values would be much appreciated. I am using this to self teach as I appreciate there are many better scripts than mine for SAR in circulation.

Regards
K

This sounds less like a lua script issue and more like an issue with the game not saving the state of the object to the save file.

I was able to replicate the problem in 1147.4x, did not check the newer beta's.

A simple test was new blank scenario... create side and a single unit, set units SAR_enabled=true on the single object. Save, reload, after reload same unit has SAR_Enabled = false. I would report this in tech support that unit SAR_enabled state is not being serialized and/or deserialized to/from save file property and note what version you've tested\testing with.

btw noticed the sar fields are also missing from lua documentation for the unit wrapper (old and new docs)
User avatar
KLAB
Posts: 483
Joined: Tue Feb 27, 2007 5:24 pm

Re: Not saving SAR Enabled true value?

Post by KLAB »

KnightHawk75 wrote: Sun Nov 27, 2022 9:19 pm
KLAB wrote: Fri Nov 25, 2022 12:45 pm ....
BUT....
When I save the game in the editor and reload in edit mode it the same downed aircrew(s) is/are then SAR_enabled = 'No'

Any help in what I am missing on how to preserve the values would be much appreciated. I am using this to self teach as I appreciate there are many better scripts than mine for SAR in circulation.

Regards
K

This sounds less like a lua script issue and more like an issue with the game not saving the state of the object to the save file.

I was able to replicate the problem in 1147.4x, did not check the newer beta's.

A simple test was new blank scenario... create side and a single unit, set units SAR_enabled=true on the single object. Save, reload, after reload same unit has SAR_Enabled = false. I would report this in tech support that unit SAR_enabled state is not being serialized and/or deserialized to/from save file property and note what version you've tested\testing with.

btw noticed the sar fields are also missing from lua documentation for the unit wrapper (old and new docs)
Thanks for the answer that's much appreciated.

It will save a great deal of time as my assumption is always that is my inept scripting that's to blame and I have been scratching my head for about a week!

Thanks again,
K
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: Not saving SAR Enabled true value?

Post by michaelm75au »

The next update will save the fields SAR_enabled, beingPickedUp and pickUpTarget; the first 2 were not in the save leading to the pickup being cancelled most of the time.
You also will be able to set the pickup target via Lua.
Michael
User avatar
KLAB
Posts: 483
Joined: Tue Feb 27, 2007 5:24 pm

Re: Not saving SAR Enabled true value?

Post by KLAB »

Obliged. Thank you.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: Not saving SAR Enabled true value?

Post by KnightHawk75 »

michaelm75au wrote: Thu Dec 01, 2022 7:28 am The next update will save the fields SAR_enabled, beingPickedUp and pickUpTarget; the first 2 were not in the save leading to the pickup being cancelled most of the time.
You also will be able to set the pickup target via Lua.
Thanks Michael!
Post Reply

Return to “Lua Legion”