ADHS Posted June 10, 2020 Posted June 10, 2020 Hello. At 1st, allow me to explain my thinking: I can't programming while i dont know the routines & the variables that an already engine is using. Ok, DCS Mission Editor language is LUA. But what about the script variables that DCS is using ? Blank! This is my thinking. Hense i am asking for the DCS variables that i can use in scripts. I couldn't find them anywhere. Just as visual limited enviroment inside the Mission Editor. Any further help to my search, will be appreciated. Thank you. Democracy was already invented, while Scrat was eating oak fruits.
ADHS Posted June 10, 2020 Author Posted June 10, 2020 (edited) For example: I want to get the number of CLIENTS that have connected, so to ACTIVATE equal number of enemies in front of them. Now, i have to: Unit A1 (from the A group of four) if is alive to INCREASE a FLAG COUNTER. And this multiply 36 times in ME, just to get the number of CLIENTS! What is the VARIABLE to get the SUM of the connected CLIENTS ? It should be that simple, like: VAR CLIENTS(i) What is the variable NAME ? PS: Is it secret ???:mad::mad::mad: Edited June 10, 2020 by ADHS Democracy was already invented, while Scrat was eating oak fruits.
Grimes Posted June 11, 2020 Posted June 11, 2020 https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation There aren't really any pre-defined variables in the sense of something that directly represents the number of clients that are alive. The only predefined variables deal with constants usually associated with country Ids, waypoint types, etc. There are scripting functions that you can run to get that data however. Absolutely basic check would be to use coalition.getPlayers() which returns a list of players. You can count the number of aircraft directly with lua by checking the size of the table. Or you can iterate and count up by the aircraft types so that 30 A-10Cs won't generate the same number of AI fighters as 30 F-14s. Other ways are similar, since you know the client unit names you can generate a list of them and iterate by checking Unit.getByName() on each to see if it is alive. If so add 1. When done you have the count. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
ADHS Posted June 11, 2020 Author Posted June 11, 2020 Grimes Thank you very much for your help and the link for the functions. Yes now i can find out what is going on. I really appreciate it my friend. Best wishes. Democracy was already invented, while Scrat was eating oak fruits.
Recommended Posts