Script Not updating RTB value when in an event action but will in LUA console?
Posted: Fri Dec 30, 2022 10:00 pm
The below script works in the LUA console so that when 12 people have been recovered in total the recovery SAR helo is automatically RTB,
but when worked into the event action it repeatedly will not update the unit to RTB?
Baffled and have been trying for some time, latest iteration tried the emulate console but that made no difference?
Thanks
K
but when worked into the event action it repeatedly will not update the unit to RTB?
Baffled and have been trying for some time, latest iteration tried the emulate console but that made no difference?
Any ideas what I am missing?
Tool_EmulateNoConsole(true)
ScenEdit_AddSide({name='test'})
local count = tonumber(ScenEdit_GetKeyValue ("SARCap"))
::WHO::
local ResPax = ScenEdit_UnitX()
local ResU = ScenEdit_UnitY()
print (ResU.unit.name)
ScenEdit_MsgBox(ResPax.crew..' crew saved by '..ResU.unit.name..' ',0)
local ResC = count+ResPax.crew
local newcount = tostring(ScenEdit_SetKeyValue ("SARCap", ResC))
local cupdate = tonumber(ScenEdit_GetKeyValue ("SARCap"))
ScenEdit_MsgBox('A total of '..cupdate..' crew members have been rescued so far.',1)
if ResPax.WasPickedUp then
if ResPax.type ~= 'Facility' and ResPax.crew >= 2 then
print (ResPax.crew)
local NuScore = (10*ResPax.crew)
ScenEdit_MsgBox( NuScore..' Points for rescue of '..ResPax.crew..' crew members.', 0)
local a=ScenEdit_GetScore("A")
ScenEdit_SetScore('A',(a+NuScore),''..NuScore..' Points for rescue of aircrew.')
elseif ResPax.dbid == 2046 or ResPax.crew == 1 then
local NuScore = (10*1)
ScenEdit_MsgBox( NuScore..' Points for rescue of one crew member.', 0)
local a=ScenEdit_GetScore("A")
ScenEdit_SetScore('A',(a+NuScore),''..NuScore..' Points for rescue of one crew member.')
end
local finalcount = tonumber(ScenEdit_GetKeyValue ("SARCap"))
if finalcount >=12 then
ScenEdit_SetUnit({name=ResU.unit.name, guid=ResU.unit.guid, RTB=true})
ScenEdit_MsgBox(ResU.unit.name..' has recovered '..cupdate..' crew and is returning to base', 1)
end
ScenEdit_RemoveSide({name='test'})
Tool_EmulateNoConsole(false)
end
Thanks
K