[HOUNDS] CptTrips Posted February 9, 2023 Posted February 9, 2023 Hi guys. I have been trying to get interactive debugging working using the document in the MOOSE Git. I am not yet using MOOSE so I am using the alternative “loadfile” approach mentioned in the document. I am new to Lua and DCS, but I want to prove to myself debugging is possible before going to far down the road of learning Lua. I need true debugging or I suspect it wouldn’t be worth it to bother. It wouldn’t be worth the years it would take off my life. I have tried various ways and seem to be running into the same class of problem. Seems to be some kind of scoping issue. Probably some stupid simple Lua trick I am not doing right, I just haven’t figured it out. In testing I have an example that is not even involving debugging so is a good simple case. Say I have a script file “TryTest.lua”. Say the content looks something like: TryTest = function(count) –- do some trivial stuff looping through the country enum –- dump out some stuff to env.info end The contents of the function isn’t important because I am not getting that far. I have a trigger when my debug flag is true I go do a “_G.loadfile( full_path_name .. ‘TryTest.lua’) “ on mission start. I have a trigger when the player enters the zone that does a DoScript “TryTest(1)” When it fires it says it can’t find the global TryTest. *** If in the debug flag is false, then it does a DoScriptFile of the same code. In that case the same exact code works fine. The zone DoScript “TryTest(1)” is resolved. Same code the global TryTest is resolved when using DoSCriptFile, but not with loadfile. Some kind of scoping problem. Inversely, an earlier attempt it wasn’t a function, just the code inside the function that got loaded directly in the zone trigger. In that case it got to the code but it barfed when that code tried to index “country” which is a global DCS enum. So in this case, it was still a scoping issue in reverse. TLDR; I seem to be running into scoping issue with loadfile that I am not seeing with the same code loaded with DoScriptFile. As I said, I am a noob, so I assume I am missing something simple. Thanks in advance for any clues.
Recommended Posts