xcandiottix Posted March 4, 2023 Posted March 4, 2023 (edited) Consider the following code: --Event handler set up --... if(event_id == 3) then --landing if(event == nil or event.place == nil or event.place.getDesc == nil or event.place:getDesc() == nil) then --This is not an airbase, etc return else --Do something end end If a helicopter lands at an oil derrick on the Caucuses map I get the following error at the second if statement in the code above: 2023-03-04 17:59:35.473 ERROR SCRIPTING (Main): Mission script error: [string "C:\dynamicCampaign\events.lua"]:266: Airbase doesn't exist stack traceback: [C]: ? [C]: in function 'getDesc' How can I avoid this error? It seems that calling getDesc() is making DCS error out in this case. Landings at other airbases or the ground works as expected. For additional color, here is the DCS event in the logs for the very same landing: 2023-03-04 17:59:35.473 INFO Scripting (Main): event:initiator_unit_type=SA342M,type=land,initiatorPilotName=blah,initiator_coalition=2,initiator_ws_type1=1,t=10532.934,initiator_object_id=16781581,initiatorMissionID=273, Edited March 4, 2023 by xcandiottix I created and maintain Operation Candyland, a DCS Open Beta server. Since 2019, Operation Candyland has been one of the best persistent campaigns running on DCS. Featuring ALL modern US and Russian Air, Ground, and Sea forces dynamically controlled by a standalone AI controller. At any given time, there are over 500 units on the map without any lag or desync due to the standalone nature of the system. Experience one of the best multiday campaign experiences in DCS either solo or with a group of other pilots. Both new and veteran DCS pilots will find Operation Candyland a refreshing challenge where no two campaigns are ever the same. Challenge yourself by reaching the top of a custom scoreboard which grades you based on your sortie performance and experience a custom F10 fog of war system which reveals units based on your coalition's current level of command and control. Rescue downed friendly pilots or captured downed enemy pilots in order to extract valuable intel to progress the mission. Learn more at: https://discord.gg/operation-candyland
TEMPEST.114 Posted March 4, 2023 Posted March 4, 2023 event.place.getDesc == nil or event.place:getDesc() You have a . instead of a colon on the first part.
xcandiottix Posted March 4, 2023 Author Posted March 4, 2023 (edited) I added that to make sure that there was actually a variable named getDesc before running the function. You can imagine the table structure is something like this: pseudo code event = {} event.place = {} event.place.getDesc = function() There are times that getDesc doesn't exist and calling it triggers an error, such as, when someone lands in a field. The field has no desc so straight away calling getDesc() will throw an error. Edited March 4, 2023 by xcandiottix I created and maintain Operation Candyland, a DCS Open Beta server. Since 2019, Operation Candyland has been one of the best persistent campaigns running on DCS. Featuring ALL modern US and Russian Air, Ground, and Sea forces dynamically controlled by a standalone AI controller. At any given time, there are over 500 units on the map without any lag or desync due to the standalone nature of the system. Experience one of the best multiday campaign experiences in DCS either solo or with a group of other pilots. Both new and veteran DCS pilots will find Operation Candyland a refreshing challenge where no two campaigns are ever the same. Challenge yourself by reaching the top of a custom scoreboard which grades you based on your sortie performance and experience a custom F10 fog of war system which reveals units based on your coalition's current level of command and control. Rescue downed friendly pilots or captured downed enemy pilots in order to extract valuable intel to progress the mission. Learn more at: https://discord.gg/operation-candyland
Recommended Posts