ESAc_matador Posted May 5, 2016 Share Posted May 5, 2016 I made this code AttackUnit = { id = 'AttackUnit', params = { unitId = "unit", } } _group = Group.getByName("Group1") _controller = _group:getController() _controller:setTask(AttackUnit); first, I load the Mist, and 20 seconds later I run the script (Time more - do script) The aircraft is named "Group1" and the enemy "unit". What happen is the aircraft remove his WPs, and directly goes to the last WP (Land). I thought this order is like "unit task" in the mission editor... but nothing happens. There is not even an error message. I attached the mission. Any guru can help me out here?testscriptsettask.miz Link to comment Share on other sites More sharing options...
Grimes Posted May 5, 2016 Share Posted May 5, 2016 The unitId needs to be the unitsId not the unitname. http://wiki.hoggit.us/view/DCS_task_attackUnit Also when you set a task it eliminates the "mission" task assigned to the aircraft, so it forgets its route and RTBs since it wasn't given a valid task. Try using Controller:pushTask() 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 Link to comment Share on other sites More sharing options...
ESAc_matador Posted May 6, 2016 Author Share Posted May 6, 2016 (edited) Thanks, I thought, push task did not work. Thanks! This should work, then?. AttackUnit = { id = 'AttackUnit', params = { unitId = function () Unit.getID("unit") } } _group = Group.getByName("Group1") _controller = _group:getController() _controller:pushTask(AttackUnit); Edited May 6, 2016 by ESAc_matador Link to comment Share on other sites More sharing options...
ESAc_matador Posted May 6, 2016 Author Share Posted May 6, 2016 Well... Definetely. I dont know how to put the unitID... how to call the funciont unit.getID. Link to comment Share on other sites More sharing options...
St3v3f Posted May 6, 2016 Share Posted May 6, 2016 Try AttackUnit = { id = 'AttackUnit', params = { unitId = Unit.getByName("unit"):getID() } } _group = Group.getByName("Group1") _controller = _group:getController() _controller:pushTask(AttackUnit); aka: Baron [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
ESAc_matador Posted May 6, 2016 Author Share Posted May 6, 2016 (edited) Try AttackUnit = { id = 'AttackUnit', params = { unitId = Unit.getByName("unit"):getID() } } _group = Group.getByName("Group1") _controller = _group:getController() _controller:pushTask(AttackUnit); thank you!!! do yo know how can I stop the task, but keep in flying the his route??? i can stop, and then he come backs to the airport. I was doing Unit.getByName():getID("unit"). It works!!!! Edited May 6, 2016 by ESAc_matador Link to comment Share on other sites More sharing options...
ESAc_matador Posted May 6, 2016 Author Share Posted May 6, 2016 (edited) ops... now I cant make the attack stop. NoTask = { id = 'NoTask', params = { } } _group = Group.getByName("Group1") _controller = _group:getController() _controller:pushTask(NoTask); it does not seems to work. What I want is the flight Group1 keep going with its original flight plan. Edited May 6, 2016 by ESAc_matador Link to comment Share on other sites More sharing options...
FSFIan Posted May 6, 2016 Share Posted May 6, 2016 (edited) You want popTask(). The underlying data structure you are manipulating is a stack, so the "opposite" of a push is a pop. The image on that Wikipedia page might help you visualize what is going on (and why pushing NoTask does not have the desired effect). Edited May 6, 2016 by [FSF]Ian DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
ESAc_matador Posted May 6, 2016 Author Share Posted May 6, 2016 Ian;2769480']You want popTask(). The underlying data structure you are manipulating is a stack, so the "opposite" of a push is a pop. The image on that Wikipedia page might help you visualize what is going on (and why pushing NoTask does not have the desired effect). Yes! I checked most of the coomands, but I missed this one. I want to do some sdripts. One, is, with predefined triggerareas, send CAS fligths, to attack specifick areas, via Radio F10. Yes, you can do this via CA, but for single players, or even multi, with not so many people calling strikes in areas, looks nicer. With the Gazelle it is awesome, I already dI'd it via ME, but is too much work, too many flags, etc. So if I can do something prédite via lua, would be awesome. Also, I want to make a smarter infantry. They will hide from enemies (by becaming invisible) from the enemy when they are neither sooting nor moving during x time. So, you can use infantry as sneaky units, commandos insertion, ambushes, etc. When they are invisible, and an enemy unit get in range of fire, they will shoot and loose it's invisibility. I am getting there with the lua, starting to understand the philosophy, that is why I still need some help. Link to comment Share on other sites More sharing options...
ESAc_matador Posted May 6, 2016 Author Share Posted May 6, 2016 function stopattack() _group = Group.getByName("Group1") _controller = _group:getController() _controller:popTask(); trigger.action.outText("Disengaging!!!", 30) end it doesnt seems to work Link to comment Share on other sites More sharing options...
Grimes Posted May 6, 2016 Share Posted May 6, 2016 You can also click the button highlighted to get the ids for anything you want to hard-code into the script. 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 Link to comment Share on other sites More sharing options...
ESAc_matador Posted May 6, 2016 Author Share Posted May 6, 2016 You can also click the button highlighted to get the ids for anything you want to hard-code into the script. Oh, thank you. Grimes, I did not know that. Do you know how to stop the tasK? Link to comment Share on other sites More sharing options...
ESAc_matador Posted June 20, 2016 Author Share Posted June 20, 2016 i cant use the popTask yet... any help? Link to comment Share on other sites More sharing options...
FlightControl Posted June 20, 2016 Share Posted June 20, 2016 as we discussed, i'll look at this tomorrow :-) i think i know what you need ... [TABLE][sIGPIC][/sIGPIC]| Join MOOSE community on: DISCORD :thumbup: Website of the MOOSE LUA Framework. MOOSE framework Downloads. Check out Example Missions to try out and learn. MOOSE YouTube Channel for live demonstrations and tutorials. [/TABLE] Link to comment Share on other sites More sharing options...
FlightControl Posted June 21, 2016 Share Posted June 21, 2016 I've given you a comprehensive answer on the moose-group slack channel... have a look! [TABLE][sIGPIC][/sIGPIC]| Join MOOSE community on: DISCORD :thumbup: Website of the MOOSE LUA Framework. MOOSE framework Downloads. Check out Example Missions to try out and learn. MOOSE YouTube Channel for live demonstrations and tutorials. [/TABLE] Link to comment Share on other sites More sharing options...
ESAc_matador Posted June 21, 2016 Author Share Posted June 21, 2016 thanks! Link to comment Share on other sites More sharing options...
Recommended Posts