Jump to content

MOOSE - Mission Object Oriented Scripting Framework


Recommended Posts

On 3/27/2021 at 7:13 PM, Pikey said:

SETS are working fine. I took your sample and it worked. What didnt work was the env.info writing to the logs, dont get the assumption that if there was nothing then it didnt run, confused with the set not working, you can clearly see the objects. Try using Flush() or printing the entire set object out to the logs and you will see.

Yes, I know what you are asking for. It should work fine as it is, so I believe its a bug. You need to reprot that onto GH to get it fixed by the module author.

 

 

Let me just clarify something if you don't mind.  

 

The ForEachGroup(func) does not function like an :OnSpawnGroup(func) in that when new set members arrive, any code in the ForEachGroup(func) will not be run.  

 

I suspect the answer is "no, it will not be run." I think this was the source of my confusion.

 

It would be a great enhancement to the SET classes though. It could add something very similar to :OnSpawnGroup() e.g.

 

:OnAdd(func (grp)) 

 

which would run that callback function upon the addition of any item to the set.

 

 

 

 

 

 

[sIGPIC][/sIGPIC]

Are you ready to take your chopper flying skills to the next level?

Then check out http://www.blacksharkden.com/ Or visit us on Discord https://discord.gg/kaayJ5z and talk to some of our awesome pilots today.

Link to comment
Share on other sites

I have a problem, he does not see this unit for me.
A wants it to detect units in the zone upon respawning.

ZoneMash_1 = ZONE:New("ZoneMash2")
Mash_Spawn_1 = SPAWN:New("MashPiech1"):InitLimit( 1, 0):Spawn()
-------------
ZoneMash_1 = ZONE:New("ZoneMash2")
Test_Piech_1 = SCHEDULER:New( nil, 
function() MashPiech_001 = GROUP:FindByName("MashPiech#001")
  if MashPiech_001:IsPartlyOrCompletelyInZone(ZoneMash_1) then 
   trigger.action.outText('yes', 10)
            
  end 
 end, {}, 5, 5 )

 


Edited by hancerPL

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

I have a problem, server

 

2021-03-31 00:13:52.231 INFO    SCRIPTING: Error in SCHEDULER function:[string "C:\Users\GILDIA~1\AppData\Local\Temp\DCS.Gildia_S3\/~mis00005719.lua"]:79702: attempt to call method 'PlayerTakeOff' (a nil value)
2021-03-31 00:13:52.232 INFO    SCRIPTING: stack traceback:
	[string "C:\Users\GILDIA~1\AppData\Local\Temp\DCS.Gildia_S3\/~mis00005719.lua"]:8063: in function 'PlayerTakeOff'
	[string "C:\Users\GILDIA~1\AppData\Local\Temp\DCS.Gildia_S3\/~mis00005719.lua"]:79702: in function <[string "C:\Users\GILDIA~1\AppData\Local\Temp\DCS.Gildia_S3\/~mis00005719.lua"]:79687>
	(tail call): ?

 

 

Regarding Moose functions

 

-- Call take-off function.
  if _unit and _playername and _base then
    self:PlayerTakeOff(_unit, _baseName)
  end
end

 

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

  • 3 weeks later...

An FYI, We've been having a bit of a problem with the Moose build process recently. Glad to report Applevangelist has fixed Appveyor, it seemed that our old friend Flight Control's Appveyor account ran out leaving the Moose build process to die.

For 2.7 Airbases work, but theres no entries for them, just use the name as a string from the map for new airbases.
The new events are in, go wild with your imagination. Notable one is the Landing Quality Mark event. Grimes has updated Hoggit with the references, nothing really to add except player comments are next to useless, they only show ungraded carrier traps where ATC communication was not attempted. Now we can get player names and places from the LandingQualityMark, so you can make your DIscord bots go wild.

There's a few niggles here and there but I'd say we were in a good spot for Moose. The Moose team now consists of myself and Frank and a new manager role accepted from Applevangelist. Delta99 holds the Discord Admin. There is a small team of contributors who float about and a few key members on Discord that help people out starting to script. If you are interested in cutting your teeth on scripting in DCS, this is a good place to start, we've one of the lowest bars of entry for doing such a complex thing and its a very rewarding hobby to learn and good for a CV.

We recommend starting from here: https://github.com/FlightControl-Master/MOOSE_GUIDES/releases/download/v0.1-rc1/Moose_User_Guide.pdf

 

Thanks.

  • Thanks 3

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Il 29/3/2021 at 17:49, fargo007 ha scritto:

 

 

Let me just clarify something if you don't mind.  

 

The ForEachGroup(func) does not function like an :OnSpawnGroup(func) in that when new set members arrive, any code in the ForEachGroup(func) will not be run.  

 

I suspect the answer is "no, it will not be run." I think this was the source of my confusion.

 

It would be a great enhancement to the SET classes though. It could add something very similar to :OnSpawnGroup() e.g.

 

:OnAdd(func (grp)) 

 

which would run that callback function upon the addition of any item to the set.

 

 

 

 

 

 

 

 

Hi @fargo007 , hope this can be usefull:

yourSet:ForEachGroup(
  function (group)
    if group:IsActive() then
      -- the group is already active - do something
    else
      group:HandleEvent(EVENTS.Birth)
      function group:OnEventBirth(EventData)
        -- do something when group will be activated
      end
    end
  end
)


Edited by Kappa

--

[sIGPIC][/sIGPIC]

36° Stormo Virtuale - Italian Virtual Flight Community

www.36stormovirtuale.net

Link to comment
Share on other sites

Thanks Kappa!

 

The overarching issue I had was fundamentally misunderstanding that the ForEachGroup(func()) doesn't fire each time a new group gets added to the set. 

 

It has to be called via a scheduler or DO SCRIPT from the ME. 

 

What I would like to have is a callback function similar to :OnSpawnGroup(), where any time a new member joins a set, that function runs with the group object as its arg.  

 

 

[sIGPIC][/sIGPIC]

Are you ready to take your chopper flying skills to the next level?

Then check out http://www.blacksharkden.com/ Or visit us on Discord https://discord.gg/kaayJ5z and talk to some of our awesome pilots today.

Link to comment
Share on other sites

On 4/23/2021 at 1:19 PM, fargo007 said:

Thanks Kappa!

 

The overarching issue I had was fundamentally misunderstanding that the ForEachGroup(func()) doesn't fire each time a new group gets added to the set. 

 

It has to be called via a scheduler or DO SCRIPT from the ME. 

 

What I would like to have is a callback function similar to :OnSpawnGroup(), where any time a new member joins a set, that function runs with the group object as its arg.  

 

 

 

Has anyone poured over the SET documentation. I wouldn't doubt if such a thing exists although I don't think I've used it or looked for it before.

Link to comment
Share on other sites

I have an issue with RAT flights not respawing after landing (of after a crash FWIW); the code is as following:


local IL76=RAT:New("RAT_IL76")
IL76:StatusReports(false)
IL76:ATC_Messages(false)
IL76:SetTerminalType(AIRBASE.TerminalType.OpenBig)
IL76:ContinueJourney() 
IL76:RespawnAfterCrashON()
IL76:Spawn(2)
Two IL-76 are spawned at mission start but then disappear and never return after landing or crashing. Shouldn't they respawn?

I activated tracing at level 3 for the RAT class:

 

14:57:41.418  INFO  SCRIPTING  5956( 21)/I: BASE00000.TraceClass(Tracing class RAT) 
14:57:41.418  INFO  SCRIPTING  5929( 22)/I: BASE00000.TraceLevel(Tracing level 3) 

 

But I do not see any message related to aircrafts landing or crashing. Maybe the event handling is broken? How could I verifiy?

Link to comment
Share on other sites

20 hours ago, Delta99 said:

 

Has anyone poured over the SET documentation. I wouldn't doubt if such a thing exists although I don't think I've used it or looked for it before.

 

Yup, BTDT.

 

All the iterator functions have to be called in essentially a scheduler.

[sIGPIC][/sIGPIC]

Are you ready to take your chopper flying skills to the next level?

Then check out http://www.blacksharkden.com/ Or visit us on Discord https://discord.gg/kaayJ5z and talk to some of our awesome pilots today.

Link to comment
Share on other sites

Is there a way to get ground vehicles to patrol on the road in a zone? PatrolZones() makes them go off-road, even if I have the unit set to "On road" in the ME. I even tried using PatrolZones( { ZONE:New( "Patrol Zone A" ) }, 45, "On road" ), but nothing I can do seems to work. Even with PatrolRouteRandom() and waypoints set on the road, they just go off-road. Any help would be appreciated. I am pretty new to this. Thanks. 

Link to comment
Share on other sites

Posted (edited)

 Hey all, so i haven't touched Lua for around 13 years (Zygor's for WoW) and i have only been poking around MOOSE for a few days so please bare with my noobish questions as i have a feeling that the problems i have are probably very simple for some people to solve.

 So I'm building a very simple CV training mission to practice some Case III Manoeuvre's and timings (for myself) with some AI traffic to actually have stacks waiting to land, Im looking to have the AI have a delayed start, I can do this with flags in the ME but not with MOOSE (yet) this is just so i can stagger the first spawn on the full deck and not have them block each other, then they are to proceed to basic waypoints defined in the ME until they land again, once landed they will despawn/respawn with a delay and then run the same thing again.

 I'm having luck using :InitRepeatOnEngineShutDown however in a flight of two when the lead plane lands and shuts down it respawns both planes immediately and usually with the 2nd still in the air on final.

 The extremely basic line I'm using is;
Spawn_ASM1 = SPAWN:New( "ASM1" ):InitKeepUnitNames():InitLimit(2, 0):InitRepeatOnEngineShutDown():Spawn()

This works, they spawn, take-off, land, park and respawn, but the timing is all instant, this will cause a problem with the 10+ aircraft that will be running on this at some point as having a flooded deck of things appearing and disappearing into different places, especially when the rear starboard elevator spawns use the front cats instead of 3 and 4, I'm already imagining the traffic jams on the deck.

So now for my questions;

 - Is there a way to initiate a delay after the engine shuts down but before respawn? or when the plane respawns but before it starts? (similar to ME uncontrolled method)

 I'm guessing that :SpawnScheduled() along with it's delay functions can do this but after hours of headache induced trying i can't find the correct Syntax for it to work, whenever i add it to the line, the line no longer works, i'm guessing this is a conflict with one of the other :Init parameters. (again it's been 13 years since I've even looked at anything Lua)

Is there a way in MOOSE to have all of a group landed and shutdown before the group respawns? 

 The only way i can see to do this (with my experience) is in the ME to trigger the respawn script from a flag that is activated when the last plane of the group has an altitude of lower than 'x' value (74(3) for cv i think) and a speed of <1 with a 'Time Since Flag' to delay the script long enough for both planes to land and shutdown before respawning however i think that would conflict with :InitRepeatOnEngineShutDown and also it doesn't seem to work with the above line as the script would need to be at the mission start in order to clone the group and to my knowledge when that happens the ME triggers don't respond to the new clone group as the group technically never spawned, i know there is a way to call the groups new name and then have that assigned to a trigger in MOOSE but i haven't gotten that far into it yet.

- :OnSpawnGroup, any help, greatly appreciated. 

 So i have been looking and reading through GitHub as well as posts here and it seems this little guy is a versatile little beast but i have 0 idea how he works, i am assuming it could fix my MOOSE delayed start problem as i believe i could start my planes Late Activated in ME so MOOSE can clone them and then use :OnSpawnGroup to set them into the UnControlled state (purely guessing here) and then time their starts from a control flag that would deactivate after around 15 minutes, enough time for everyone to start, taxi and take-off and then have the respawn script set to only work if that flag is false, this, in my mind anyway, would mean that the respawn script could not interfere with the initial spawn/delayed start and would then only come into play after that 15 minute flag is deactivated and set to false.

Anyway it's been a long few days of trying to learn something new and i'm probably over-complicating things so any help from you guys would be greatly received, i can add Miz and Lua files if needed but the 1 line of code is here and the mission is 1 cv and 2 f18's so nothing special so far, still early days 🙂

Thanks in advance.



 


Edited by AeroDan90

PC Specs                                                                           Owned Modules                                                                 Wishlist                                           

Ryzen 7 3700X                                                              F-18 - F-14 - FC3                                     AC-130 - Su-47 - Avro Vulcan - B-2 Spirit  

ASUS ROG STRIX X570-F                               Super Carrier - Persian Gulf                   F/A-18E/F Super Hornet - F-35 - B1/B Lancer 
EVGA GTX 1080Ti 11GB                                       Syria - KA-50 - Gazelle                                            E2-D - AH-64D (soon!) 
                         
32GB HyperX Predator DDR4@3200                         A-10C II                                                                F-4E  - Tornado GR4                               

Link to comment
Share on other sites

Hello

 

There is a problem with A2A Dispatcher, it advises against machines without EWR.

Quote

Detect_1 = SET_GROUP:New()
Detect_1:FilterPrefixes( { "Ewr1" } )
Detect_1:FilterStart()

Detection_1 = DETECTION_AREAS:New( Detect_1, 100000 )
Detection_1:SetRefreshTimeInterval( 20 )
RedCap_1 = AI_A2A_DISPATCHER:New( Detection_1 )
RedCap_1:SetTacticalDisplay( true )
RedCap_1:SetRefreshTimeInterval( 30 )
RedCap_1:SetEngageRadius( 30000 )
RedCap_1:SetSquadron( "Squadron1", AIRBASE.Caucasus.Maykop_Khanskaya, ( RedTemplate ) )
BorderZone_1 = ZONE_POLYGON:New( "BorderZone1" , GROUP:FindByName( "BorderZone1" ) )
RedCap_1:SetBorderZone(BorderZone_1)
RedCap_1:SetSquadronGrouping( "Squadron1", 2 )--UTILS.FeetToMeters(21000), UTILS.KnotsToKmph(300),     
RedCap_1:SetSquadronCap( "Squadron1", ZONE:New( "CapZone1"), UTILS.FeetToMeters(6000), UTILS.FeetToMeters(18000), 600, 800, 800, 1200, "RADIO" )
RedCap_1:SetSquadronCapInterval( "Squadron1", 1, 10, 600 )--300
RedCap_1:SetSquadronTakeoffInAir("Squadron1")
RedCap_1:SetDefaultLandingNearAirbase("Squadron1")

Name Ewr1, you can change freely and this is how patrols are reborn.

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

22 hours ago, AeroDan90 said:

 Hey all, so i haven't touched Lua for around 13 years (Zygor's for WoW) and i have only been poking around MOOSE for a few days so please bare with my noobish questions as i have a feeling that the problems i have are probably very simple for some people to solve.

 So I'm building a very simple CV training mission to practice some Case III Manoeuvre's and timings (for myself) with some AI traffic to actually have stacks waiting to land, Im looking to have the AI have a delayed start, I can do this with flags in the ME but not with MOOSE (yet) this is just so i can stagger the first spawn on the full deck and not have them block each other, then they are to proceed to basic waypoints defined in the ME until they land again, once landed they will despawn/respawn with a delay and then run the same thing again.

 I'm having luck using :InitRepeatOnEngineShutDown however in a flight of two when the lead plane lands and shuts down it respawns both planes immediately and usually with the 2nd still in the air on final.

 The extremely basic line I'm using is;
Spawn_ASM1 = SPAWN:New( "ASM1" ):InitKeepUnitNames():InitLimit(2, 0):InitRepeatOnEngineShutDown():Spawn()

This works, they spawn, take-off, land, park and respawn, but the timing is all instant, this will cause a problem with the 10+ aircraft that will be running on this at some point as having a flooded deck of things appearing and disappearing into different places, especially when the rear starboard elevator spawns use the front cats instead of 3 and 4, I'm already imagining the traffic jams on the deck.

So now for my questions;

 - Is there a way to initiate a delay after the engine shuts down but before respawn? or when the plane respawns but before it starts? (similar to ME uncontrolled method)

 I'm guessing that :SpawnScheduled() along with it's delay functions can do this but after hours of headache induced trying i can't find the correct Syntax for it to work, whenever i add it to the line, the line no longer works, i'm guessing this is a conflict with one of the other :Init parameters. (again it's been 13 years since I've even looked at anything Lua)

Is there a way in MOOSE to have all of a group landed and shutdown before the group respawns? 

 The only way i can see to do this (with my experience) is in the ME to trigger the respawn script from a flag that is activated when the last plane of the group has an altitude of lower than 'x' value (74(3) for cv i think) and a speed of <1 with a 'Time Since Flag' to delay the script long enough for both planes to land and shutdown before respawning however i think that would conflict with :InitRepeatOnEngineShutDown and also it doesn't seem to work with the above line as the script would need to be at the mission start in order to clone the group and to my knowledge when that happens the ME triggers don't respond to the new clone group as the group technically never spawned, i know there is a way to call the groups new name and then have that assigned to a trigger in MOOSE but i haven't gotten that far into it yet.

- :OnSpawnGroup, any help, greatly appreciated. 

 So i have been looking and reading through GitHub as well as posts here and it seems this little guy is a versatile little beast but i have 0 idea how he works, i am assuming it could fix my MOOSE delayed start problem as i believe i could start my planes Late Activated in ME so MOOSE can clone them and then use :OnSpawnGroup to set them into the UnControlled state (purely guessing here) and then time their starts from a control flag that would deactivate after around 15 minutes, enough time for everyone to start, taxi and take-off and then have the respawn script set to only work if that flag is false, this, in my mind anyway, would mean that the respawn script could not interfere with the initial spawn/delayed start and would then only come into play after that 15 minute flag is deactivated and set to false.

Anyway it's been a long few days of trying to learn something new and i'm probably over-complicating things so any help from you guys would be greatly received, i can add Miz and Lua files if needed but the 1 line of code is here and the mission is 1 cv and 2 f18's so nothing special so far, still early days 🙂

Thanks in advance.



 

 

There's a few ways of doing this of course. This is better over Discord since you have some discourse rather than one way and wait: https://discord.gg/bymwgEgp

SpawnScheduled() will look for the unit,group counts and only spawn when met. Whilst this is the simplest method, you have to wait for DCS to despawn the first ones, which, on a carrier can take a while whilst they are parked.

Catch the logic required for a direct spawn. This is more complicated, you have to look for something like the event that shuts down the engine being fired and catch the unit name then count them in code and if whatever you need ot happen, happens, then do your spawn. Lots of heavy lifting and not reuseable.

SCHEDULER class. Make something happen ontime and every time. One caveat with spawns is that unless you change the group names they overwrite and delete each other. You could check if its alive first. One of your solutions would be more fleshed out as something a bit barbaric like:

--top of the scheduler
unit1 = UNIT:FindByName('plane1')
if unit1:InAir() then
local ready=false
else ready=true
end
--do that 3 times and then

if ready==true then
SPAWN:New('plane4'):Spawn()
end
--bottom of the scheduler

I'd give it middle of the road for ugly, but I regularly code with a chainsaw and vodka and it will work... for that super specific occasion with specific names etc.

HOWEVER!
I did testing for Super Carrier last year with spawning and it is still fairly resilient. I can't remember the number (14?) but there's massive issues and all sorts so I will only try general guidance.

AI doesnt and shouldn't be set to recover and take off at the same time, its the rule because deck crew can't configure for both and trying will jam her. So, pick your time for recovery, pick your time for launching and stick to it like you should. That way you can launch a dozen at once. Also there are no API's for the deck crew and launch and recovery. So, dictate everything by the carriers movement first, get the timings for the windows, create schedules for launch and work out the recovery accordingly. That's it. Oh and get AIRBOSS class.



 

10 hours ago, hancerPL said:

Hello

 

There is a problem with A2A Dispatcher, it advises against machines without EWR.

Name Ewr1, you can change freely and this is how patrols are reborn.

I'm sorry, I am unable to understand this, perhaps also join the Discord. We aren't aware of any bugs with Dispatcher, it hasnt changed fundamentally in years.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Posted (edited)
11 hours ago, Pikey said:




 

I'm sorry, I am unable to understand this, perhaps also join the Discord. We aren't aware of any bugs with Dispatcher, it hasnt changed fundamentally in years.

This should work in the presence of EWR. It is different for me on a mission, regardless of the existence of a radar station, patrols are sent into the air. I don't know how to explain it anymore.

sp59.miz

sp59_patrol.lua

 

A mission where we destroy EWR and planes are still reborn.


Edited by hancerPL

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

  • 3 weeks later...

Hi,I have a question....I want to add an AI unit,Set its ROE to “free"

My code is as follows:

 

 

local ah64d=RAT:New("RAT_AH64D")
ah64d:SetTakeoff("air")
ah64d:SetDeparture({"RAT_ZONE_1", "RAT_ZONE_2"})
ah64d:RAT:SetROE("free")
ah64d:SetROT ("passive")
ah64d:Spawn(10)

 

but ai ROE always is "hold"...Where's my problem?

Link to comment
Share on other sites

  • 4 weeks later...
On 12/27/2020 at 12:38 AM, Dispatch said:

I am experiencing issue with ATIS, just recently..

Will not work anymore in any everyday missions ? 

 

 

working well again, updated Moose.lua (Include - static) 12/29

 

I have added Cyprus airports and it works fine.

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
On 4/23/2021 at 7:19 PM, fargo007 said:

Thanks Kappa!

 

The overarching issue I had was fundamentally misunderstanding that the ForEachGroup(func()) doesn't fire each time a new group gets added to the set. 

 

It has to be called via a scheduler or DO SCRIPT from the ME. 

 

What I would like to have is a callback function similar to :OnSpawnGroup(), where any time a new member joins a set, that function runs with the group object as its arg.  

 

 

Check out the Finite State Machine for Moose in SET_Groups documentaion. The OnAfterAdded is already implemented.

Moose framework contributor

Link to comment
Share on other sites

35 minutes ago, Wingthor said:

Check out the Finite State Machine for Moose in SET_Groups documentaion. The OnAfterAdded is already implemented.

 

Thanks man, will do!

[sIGPIC][/sIGPIC]

Are you ready to take your chopper flying skills to the next level?

Then check out http://www.blacksharkden.com/ Or visit us on Discord https://discord.gg/kaayJ5z and talk to some of our awesome pilots today.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Following this Tutorial

 

Gives me:

 

2021-08-29 15:19:43.207 INFO    EDTERRAINGRAPHICS41:     surface5 gc() LOD 3 530 squares
2021-08-29 15:19:43.207 INFO    EDTERRAINGRAPHICS41: surface5 gc() 5.418600 ms
2021-08-29 15:19:43.216 ERROR   SCRIPTING: Mission script error: [string "BASE:TraceAll(true)..."]:1: attempt to index global 'BASE' (a nil value)
stack traceback:
	[C]: ?
	[string "BASE:TraceAll(true)..."]:1: in main chunk
2021-08-29 15:19:43.217 INFO    VISUALIZER: Preload() camera=-86106.763171, 6054.383040, -241357.710694 radius=150000.000000
2021-08-29 15:19:43.217 INFO    EDTERRAINGRAPHICS41: ITerrainGraphicsImpl4::forceLoading(): pos=(-86106.8, 6054.38, -241358), radius=150000
2021-08-29 15:19:43.232 INFO    EDTERRAINGRAPHICS41: surface5 clean up LOD 0: left 12  released 11

 

Where should i define a base?

 

thanks!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...