Tiramisu Posted November 5, 2019 Posted November 5, 2019 Not sure how to contact the authors of the scripting guide on Hoggit, but there is a typo on this page: https://wiki.hoggitworld.com/view/DCS_func_getDetectedTargets It should be Controller.Detection instead of Conroller.Detection. For people who copy stuff from that site, it may save some time. ;)
Tom_ Posted May 17, 2020 Posted May 17, 2020 Hello, I am trying to get something to work in the ME. function getFuel () local number = Unit.getFuel("test") if number < 0.4 then trigger.action.outText("returning true", 10) return true else trigger.action.outText("returning false", 10) return false end end I have this code in a Switch waypoint command Condition (LUA PREDICATE) It doesnt give an error but doesnt do anything else
Tiramisu Posted May 17, 2020 Posted May 17, 2020 DCS does not return errors any more for some strange reasons (or only on special occasions). So your code might be faulty even when you have no errors in DCS. First of all make sure that you define a unit table correctly. E.g. pUnit = Group.getByName( "Aircraft Group #001" ):getUnit( 1 )or pUnit = Unit.getByName( "Test Unit #001" )In addition you should write pUnit:getFuel()instead of Unit.getFuel("test")
hmleao Posted June 10, 2020 Posted June 10, 2020 Are there any lib files or something like that in DCS folder that I can import to my project in LDT so I can use autocomplete functions and all that good stuff? Just starting on scripting simple stuff before trying out MOOSE. Have been using hoggit for reference, but if there's something like that in DCS it would be much better.
Habu_69 Posted June 10, 2020 Posted June 10, 2020 Suggest you pose your question in Moose Discord channel where you will find help aplenty. AFAIK (and I am a scripting novice) DCS has no such libraries. I believe the more proficient Moose script writers have developed script modules for creating tables of airfields, aircraft types, etc. that run at mission start.
Yurgon Posted September 16, 2020 Author Posted September 16, 2020 ... Please open a new thread in the Mission Editor Discussion and Questions forum.
Yurgon Posted October 17, 2020 Author Posted October 17, 2020 ... Please open a new thread in the Input and Output section of the forum.
frostycab Posted February 8, 2021 Posted February 8, 2021 (edited) Hello again! Its the complete n00b again! Yay! I found a couple of LUA courses online that are actually really cheap until midnight tonight (GMT), and I'm wondering if someone can help me decide which one would be best for me to try with a view to being able to create simple scripts for DCS. (Even just understanding other people's scripts would be useful!) Is there any chance somebody could just have a quick glance at the overview for a couple of these and advise me which one you think would be most beneficial? https://www.udemy.com/course/lua-programming-master-the-basics/ https://www.udemy.com/course/lua-programming-become-a-master-of-lua/ https://www.udemy.com/course/lua-programming-course-a-path-to-your-career-in-lua/ https://www.udemy.com/course/luamasterclass/ https://www.udemy.com/course/lua-programming-master-the-fundamentals-for-beginners/ There seems to be a huge overlap, which I suppose one should expect, but it makes it hard to know which one to go for. As I said in an earlier post, my last experience with programming was using LOGO about 40 years ago when I was about 10, so I'm going in as a complete newbie. I'm already working my way through a free Python course from that site, and also just picked up another one entitled "LUA's Core Syntax" which I assume will have some overlap on basic principles, but would like to pick up one of these other courses which hopefully will be more relevant to what I need to know. Thanks everyone. Edited February 8, 2021 by frostycab 1
paulthomas Posted March 13, 2021 Posted March 13, 2021 (edited) Just trying to do a simple script. It works on lua demo but in game it gives me the following error. lua :3: unexpected symbol near ',' do local x = trigger.misc.getUserFlag('2') triggeraction.outText(x .. " points " .. 70) end also tied do local x = trigger.misc.getUserFlag('2') triggeraction.outText(x .. " points " .. , 70) end which gives the the error lua :3: unexpected symbol near ',' both in game and in lua demo Tried trigger.action as well. Its driving me mad. Any help would be welcome Thanks Edit Changes I make to my lua script dont take. When I look in the tmp file that dcs uses it completely different. Even if I change the var x to y in my file the temp version still reads x. Got it working but have to use do script instead of script file which is not ideal Edited March 13, 2021 by paulthomas additional info
paulthomas Posted March 13, 2021 Posted March 13, 2021 Anybody know how to make a helicopter just hover for a set amount of time. Also why doesn't units hits work on a barrage balloon?
609_Relentov Posted March 18, 2021 Posted March 18, 2021 On 3/13/2021 at 7:07 AM, paulthomas said: Changes I make to my lua script dont take. When I look in the tmp file that dcs uses it completely different. Even if I change the var x to y in my file the temp version still reads x. If you make a change to your lua file that's in a do script file event, you need to open the mission, go into the specific trigger, and re-click the button to load the script file again. Otherwise, it retains what the script file contained from the previous time you loaded it - i.e. it doesn't change the script file within the .mis file when you change the source script. 1
JetJake76 Posted March 29, 2021 Posted March 29, 2021 I work a lot with DCS Mission Editor, and started learning LUA about two weeks ago. As an excercise, I wrote a simple script allowing to call my flight for fuel reports. I found it useful in long range fighter sweeps or caps. To use it in a mission, two triggers have to be created: 1. ONCE trigger, with condition TIME MORE(5) and two actions - adding a radio item for report call, flag 1 value 1 - do script with code below: ------- Initialization ------- player = world.getPlayer() local playerFlight = Unit.getGroup(player) planesInFlight = Group.getUnits(playerFlight) 2. REPETITIVE ACTION trigger, with condition FLAG IS TRUE(1) and two actions: - do script with code below: ------- Fuel report ------- for i = 1, #planesInFlight do if Unit.isExist(planesInFlight[i]) then if Unit.getID(planesInFlight[i]) ~= Unit.getID(player) then trigger.action.outText(Unit.getCallsign(planesInFlight[i]) .. " fuel state: " .. math.floor(100 * Unit.getFuel(planesInFlight[i])) .. "%", 10) end end end - set flag 1 back to 0 What's the purpose of it? If a plane has full internal tanks, getFuel returns 1. If it has also external tanks, the returned value is above 1. I converted it to percents, it's more readable. Normally, my wingmen drop tanks during defensive maneuvers, having a missile fired at. It can be too late for them. Of course, I can order them to drop external tanks earlier. But having their fuel state reported, I can order them to do it just as they have 100% or less. This reduces drag and can save some fuel. I use "Drop ordnance command". Unfortunately, I can't find how to make them drop payload from specific pylons. Why did I use nested IFs? When I used one if with two expressions connected by AND, the script crashed, I don't know why. It happened after I lost a wingman in combat and call my fuel report. Here is a simple mission I created to test my scripts. 02 Scripting tests.miz 1
everest101 Posted April 29, 2021 Posted April 29, 2021 Don't feel ready to sink my head into LUA scripting just yet...but, Your example is very interesting. Thanks for sharing. MOBO/MSI X570-A PRO/PCIe 4. CPU/AMD RYZEN 9 3900X (12 CORE), RAM/DDR4-32 GB (3200MHZ with XMP activated on the MOBO), GPU/EVGA-RTX 3080Ti, HMD/PIMAX Crystal, HOTAS/Thrustmaster Cougar
Badass1982 Posted July 26, 2021 Posted July 26, 2021 (edited) I have a script I am trying to do something with but I have little to no experience with Lua at all. The following script works in my mission however once all the tasks requested are completed they cease to continue. I'm looking to make the last chunk (where the warehouse requests are made for the various trips) at the bare minimum loop over and over again but in a best case scenario , to be radomised as to when they are gonna happen , but again still repeating until the mission ends. Using The MOOSE framework. Also just started a Lua course but it's like Japanese to me. Caucaus Warehousing.lua Edited July 26, 2021 by Badass1982 Uploaded Script
okopanja Posted September 18, 2021 Posted September 18, 2021 Nice tutorial. Is there any official documentation? I tried several and mostly got dead links
Grimes Posted September 19, 2021 Posted September 19, 2021 On 9/18/2021 at 3:08 AM, okopanja said: Nice tutorial. Is there any official documentation? I tried several and mostly got dead links Hoggit wiki is where I try to keep scripting information up to date: https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation 1 2 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
TEMPEST.114 Posted November 1, 2022 Posted November 1, 2022 Does anyone know of a hand-holding tutorial on how to write your own spawn routine - especially the setting of specific waypoints/start positions and using a late activated mission editor added group as a template?
Recommended Posts