ORIGINAL: Yokes
Should the second "if" be an "elseif"?
I'm not very familiar with lua yet, but in many other languages an "if" statement can only be followed by an "else", "elseif", or "end" statement.
Yokes
Quite right! I'd recommend making sure that val is set to a value, if its the first time GetKeyValue is called on 'LZ' it might be blank. Also note that GetKeyValue will always return a string:
This might work:
val = ScenEdit_GetKeyValue('LZ')
if val == nil or val == ''
val = '0'
end
if val == '0'
ScenEdit_AddFacility('Test', 'Landing Zone', 248, 0 , 'DEC', '11.1973239792203', '49.0965833574316')
ScenEdit_SetKeyValue('LZ', '1')
end
if val == '1'
ScenEdit_DeleteUnit({side="Test", name="Landing Zone"})
ScenEdit_SetKeyValue('LZ', '0')
end