Gunthrek Posted November 21, 2023 Posted November 21, 2023 Are there any guides out there that show how do to very basic things without requiring a deep dive in to full LUA? I realize that most serious programmers have a strong desire for people to learn the basics before dipping their toes into coding, but I'm a "learn by doing" kind of person, and to be perfectly frank it's a little frustrating to be expected to read through hours of material when all I really want to do are a few basic tasks that only require a few lines of code. I'm literally just trying to detect a player aircraft entering trigger zones and use a local variable to step through audio/visual instructions for a tutorial series I'm creating for the F18. I'm also using a button press in the cockpit to step the tutorial forward to display the next instruction. I've been doing all this with triggers in the ME and it works fine, but it's just so onerous to do it that way, especially if I need to go back and make corrections...or worse add a step to the process, which requires manually going back and reassigning each and every value to make it work. I'd love to be able to just use Notepad++ to make adjustments and then reload the file rather than having to painstakingly go back through each trigger to redo something when I realized I left something out or made a mistake. I've been trying to use AI to get code snippets, but I think the biggest problem is I don't understand how to access DCS global variables, and I keep getting the "attempt to access global X(a nil value)" message. The AI is useless for troubleshooting, and I haven't been able to find an answer after searching around on the internet. Is there some code I'm supposed to include at the beginning of a script, or in the mission editor as a separate script file, to give my local script access to all the standard DCS items? So I guess my questions are as follows: 1. How do I give my script access to the DCS global variables so I can access things like units and cockpit items? 2. How do I reference a trigger zone, and what is the procedure for detecting when an aircraft is inside it? Do I need to use coordinates, or does DCS track that and I can just compare the aircraft to the trigger in some way? 3. I already know where to find the values for cockpit items in the F18, but how do I point to them in the code and store them in a variable? Thanks in advance!
HC_Official Posted November 21, 2023 Posted November 21, 2023 (edited) maybe check the subforum all about scripting ? https://forum.dcs.world/forum/1160-scripting-tips-tricks-issues/ Edited November 21, 2023 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. .
Yurgon Posted November 21, 2023 Posted November 21, 2023 Jesus Christ the search function on this forum is horrendous. Took me 5 minutes to find that thread, and I knew its title precisely. Anyway, I've not updated the tutorial in ages, but I hope it's what you're looking for and it should still be accurate. 1 2
Gunthrek Posted November 21, 2023 Author Posted November 21, 2023 This is precisely my problem, lol. I definitely tried searching for things, but all I ever get are completely unrelated topics. Funny thing is that I read through and completed the tutorial you created as the first thing I did when I decided maybe I should give LUA a look, but you stopped short of showing how to reference a trigger zone that has already been created in the ME. I'm not really looking to get into anything super complex with the coding. I want to place units and triggers in the ME because it's a GUI, then rather than using a million triggers to step through mission tutorials, I'd like to just detect certain states and pop messages up on the screen. So for cockpit related things, I'm using the I/P push button to step to the next tutorial part. I'd like to be able to detect when the button is pushed and have a specified variable increment to the next step so the next block of text and voice is displayed. It would also be great if I could pop up blocks of text when the aircraft enters a named trigger zone from the ME so I can just do it all in the script file. I think this is all I'll really need for the entire training campaign I'm developing, and I really don't want to do hours of research to do two very simple things. 1
Yurgon Posted November 22, 2023 Posted November 22, 2023 17 minutes ago, Gunthrek said: how to reference a trigger zone that has already been created in the ME By far the best resource in this regard is the Simulator Scripting Engine documentation over on Hoggit World: https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation However, at a quick glance I only found a function trigger.misc.getZone() which doesn't have anything to do with detecting units in zone. I'm sure what you're looking for must be there, I just haven't done any scripting in DCS in ages and I can't provide any better pointers than the general hint regarding the SSE documentation. When you find a good solution, it would be cool if you can let us know how you solved it. (Or someone with actual knowledge comes by and can give you much more precise advice, like maybe @Grimes ).
Gunthrek Posted November 22, 2023 Author Posted November 22, 2023 Will do. I've been looking through those pages, but I can't find anything that deals with trigger zones created in the ME, so I'm also unsure how to proceed. I don't suppose you have any insight into referencing cockpit switch states?
Yurgon Posted November 22, 2023 Posted November 22, 2023 7 minutes ago, Gunthrek said: I don't suppose you have any insight into referencing cockpit switch states? Nope, sorry. I know Baltic Dragon queries the state of cockpit switches for various campaign triggers, and he's probably not the only one to do so. But I don't know whether that uses classical ME triggers or scripting, and either way the campaign missions are all protected and you can't see the triggers anyway. I found this thread from 5 years ago which didn't find a solution: And I know I've asked for the option to affect cockpit switches via the SSE 6 years ago, which I believe hasn't happened. So maybe there's no scripting access to cockpit arguments yet (neither read nor affect), or if there is, I'm not aware of it.
Recommended Posts