Kestrel Ironworks Posted May 28, 2024 Posted May 28, 2024 Hey all, I have an issue while starting out trying to script for dcs, think I have the basics down but cant understand what I'm doing wrong... Posted the mission with the example script I am trying to use and any direction or tips would be great as have tried everything to get it working. Many thanks in advance Mission Test Zone 001 External Lights Test 001.miz
HC_Official Posted May 28, 2024 Posted May 28, 2024 (edited) go to %UserProfile%\saved games\dcs\logs Open dcs.log in a text editor (notepad++), this will show you any script errors and tell you which line the error is on usually start from bottom of log file and work backwards Edited May 28, 2024 by HC_Official No more pre-orders Click here for tutorials for using Virpil Hardware and Software Click here for Virpil Flight equipment dimensions and pictures. .
TEMPEST.114 Posted May 28, 2024 Posted May 28, 2024 1 hour ago, Kestrel Ironworks said: Hey all, I have an issue while starting out trying to script for dcs, think I have the basics down but cant understand what I'm doing wrong... Posted the mission with the example script I am trying to use and any direction or tips would be great as have tried everything to get it working. Many thanks in advance Mission Test Zone 001 External Lights Test 001.miz 10.35 kB · 3 downloads
Solution cfrag Posted May 28, 2024 Solution Posted May 28, 2024 (edited) 1 hour ago, Kestrel Ironworks said: Posted the mission with the example script I am trying to use and any direction or tips would be great as have tried everything to get it working. I feel it would be much better if you put in some more effort when requesting help. Everyone here loves to help, but if the question appears to be too low effort, people will answer in kind. Now, I recommend that you tell us: what you are trying to do How you approach this (usually showing the script helps a LOT) what went wrong, and how you know that that is wrong (a screenshot of the error helps) Now, to get you started, I looked at your code. You seem to be trying to get the AI to turn on/off navigation lights and some other stuff. The offending code line is unit:getController():setOption(AI.Option.NAVIGATION_LIGHTS, AI.Option.OFF) and the error is that the option is missing. Now the error is a bit misleading, and it seems that you never made sure that "AI.Option.NAVIGATION_LIGHTS" is a defined value in DCS. It is not. So AI.Option.NAVIGATION_LIGHTS returns nil, and that makes the error appear. Where did you get these values (like AI.Option.NAVIGATION_LIGHTS) from? Personally, I think that stringing together multiple invocations with ":" in Lua is asking for trouble. I recommend you get the controller, make sure that it's non-nil, and then invoke setOption on that. It's also faster since in your code the accessor to unit:getController() is executed multiple times. Edited May 28, 2024 by cfrag 1
TEMPEST.114 Posted May 28, 2024 Posted May 28, 2024 (edited) 1 hour ago, Kestrel Ironworks said: Hey all, I have an issue while starting out trying to script for dcs, think I have the basics down but cant understand what I'm doing wrong... Posted the mission with the example script I am trying to use and any direction or tips would be great as have tried everything to get it working. Many thanks in advance Mission Test Zone 001 External Lights Test 001.miz 10.35 kB · 3 downloads You haven't exactly given us a lot to work on; what are you trying to do and what is going wrong? My mind reading skills are rusty. ETA: https://wiki.hoggitworld.com/view/DCS_enum_AI If you'd searched the forums first, you'd have found out that there is no way to control AI nav lights or landing lights. Edited May 28, 2024 by TEMPEST.114
Kestrel Ironworks Posted May 28, 2024 Author Posted May 28, 2024 2 hours ago, cfrag said: Personally, I think that stringing together multiple invocations with ":" in Lua is asking for trouble. I recommend you get the controller, make sure that it's non-nil, and then invoke setOption on that. It's also faster since in your code the accessor to unit:getController() is executed multiple times. Firstly I will take onboard your criticism and apologize, you and others have made good points... Will try to be more specific and comprehensive in the future, my mistake was thinking running the mission would show the code and the subsequent error would be sufficient. My aim is to script events such as deactivating specific functions like Navigation lights or strobe lights on an AI Chinook in trigger zones. I got those values from googling and asking Bing AI scripting questions as I am going and probably using incorrect or outdated information. Your post has highlighted a lot of things I will look into, there's nothing like an experienced eye to highlight your most basic mistakes, most notably a list of values that are valid which would probably help a lot. (Thanks Tempest for the useful link) Thanks for tip highlighted in the quoted text I will look into that further, so new at this I have really shown my ass, have 15 or so years in the editor and only hours scripting Thankyou everyone for the extremely helpful pointers and tips everyone, managed a scripted hover and task pushing (haven't tested that one properly yet) since making this post and feel like I'm improving already.
cfrag Posted May 28, 2024 Posted May 28, 2024 Just now, Kestrel Ironworks said: My aim is to script Final warning: if you are only slightly susceptible, you will become addicted to mission scripting. You have been warned 1
Kestrel Ironworks Posted May 28, 2024 Author Posted May 28, 2024 2 hours ago, cfrag said: you will become addicted So that's why I cant stop doing it, bit like that brown powder everyone talks about
TEMPEST.114 Posted May 28, 2024 Posted May 28, 2024 (edited) Do NOT rely on any AI for scripting DCS - they have no idea of the API and the complexities of the scripting engine. They just make suggestions based on generalities. On top of that it's a braindead way of getting jobs done; you're not learning anything. If you want to learn scripting - do the work or ask for help. Us crazies love talking about scripting DCS. 5 hours ago, Kestrel Ironworks said: my mistake was thinking running the mission would show the code and the subsequent error would be sufficient We're a community but we're not your minions. It takes time and effort to download run and read your missions but if you'd just prefaced it with "I want to turn on/off nav lights on AI aircraft" we wouldn't even have had to bother downloading and looking at it - we'd just have told you it can't be done. Or you could have searched for that in the root M.E. forum; it comes up regularly. Edited May 28, 2024 by TEMPEST.114
Kestrel Ironworks Posted May 29, 2024 Author Posted May 29, 2024 23 hours ago, Kestrel Ironworks said: "Firstly I will take onboard your criticism and apologize" "there's nothing like an experienced eye to highlight your most basic mistakes" "I have really shown my ass, have 15 or so years in the editor and only hours scripting" I will refer you to my apology Did search the forum extensively but not about Nav lights, apologies for the oversight
Recommended Posts