Page 1 of 1

Not saving SAR Enabled true value?

Posted: Fri Nov 25, 2022 12:45 pm
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

Re: Not saving SAR Enabled true value?

Posted: Sun Nov 27, 2022 9:19 pm
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)

Re: Not saving SAR Enabled true value?

Posted: Sun Nov 27, 2022 10:01 pm
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

Re: Not saving SAR Enabled true value?

Posted: Thu Dec 01, 2022 7:28 am
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.

Re: Not saving SAR Enabled true value?

Posted: Fri Dec 02, 2022 10:31 am
by KLAB
Obliged. Thank you.

Re: Not saving SAR Enabled true value?

Posted: Thu Dec 08, 2022 12:40 pm
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!