Weird LUA Behaviour, Any Ideas?

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

Weird LUA Behaviour, Any Ideas?

Post by butch4343 »

Guys,

Im looking for a little help with this one as I cant figure out where I went wrong.

I have a scenario where I have a very limited number of Aircraft at Belize IAP, I believe the RAF could turn those aircraft in a lot less than the 5 hours specified, so I thought that I could create a LUA script that would automatically cut the ready time to 40 minutes.

So having used SCENEDIT _UNITX(), I figured that the code below should work:

unit = ScenEdit_UnitX()

ScenEdit_SetLoadout({side=unit.side, unitname=unit.name , LoadoutID = 0, TimeToReady_Minutes = 40, IgnoreMagazines='false'})

My trigger is Harriers remaining over IAP for 2 minutes

My Condition is Guatemala Is Hostile To NATO

My Script should take the unit details of the aircraft that tripped the trigger, (Whirlwind1/2/3/4) and it should use the default load out , and set the unit ready in 40 minutes, Unless I have missed something.

What happens is weird, the trigger fires, it sets one harrier to the 40 mins turn around even although its not left the ground, if any other harriers land back after missions they revert to the standard 6hrs turn around.

Can anyone see where I have gone wrong with this? Or can someone give me a pointer as to what am trying to achieve?

Thanks Guys

Butch
Attachments
Rumble In ..1985 V12.zip
(101.66 KiB) Downloaded 7 times
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Weird LUA Behaviour, Any Ideas?

Post by michaelm75au »

The time to ready is only applicable when the aircraft is landed. If set while in flight, it will get reset when the plane lands.
Michael
User avatar
Gunner98
Posts: 5966
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Weird LUA Behaviour, Any Ideas?

Post by Gunner98 »

Butch

If you set your Quick Turn Around settings in doctrine to 'Yes' the Harrier already has a pretty good turn around, some are better than others but here is a GR.5:


Image
Attachments
Harriersorti.jpg
Harriersorti.jpg (82.78 KiB) Viewed 392 times
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Weird LUA Behaviour, Any Ideas?

Post by butch4343 »

Gunner,

Thanks for the help, I had considered using the quick turn around setting, however, in this particular scenario I feel that even the Harriers excellent OTR time is too long. In this case, if they don't keep turning the jets as quickly as they can maintinance wont matter as the airfield will be over run anyways.

Regards

Butch
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Weird LUA Behaviour, Any Ideas?

Post by butch4343 »

ORIGINAL: michaelm75au

The time to ready is only applicable when the aircraft is landed. If set while in flight, it will get reset when the plane lands.


So just to clarify, what should happen, is :

Whirlwind 1 takes off flies a sortie then comes home, and as soon as it lands it should fire the LUA script and be ready to fly again in 40 minutes.

Whirlwind 2 then takes off flies a sortie then comes home, and as soon as it lands it should fire the LUA script and be ready to fly again in 40 minutes.

Except what seems to be happening is

Whirlwind 1 flies its sortie and then comes home and does as the above, But Whirlwind 2 comes home and has a ready time of 6 hrs.

Scen X() should take the unit details of the aircraft entering into the zone, and then apply the LUA script to that unit, except after the first mission it doesnt seem to.

Or am I not getting it? Maybe the trigger needs to be changed from remains in, to enters?

Sorry for sounding like a dummy mate

Regards

Butch
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Weird LUA Behaviour, Any Ideas?

Post by michaelm75au »

Ready time is set at the start of the readying stage after a plane lands and moves to its parking are.
What you probably need to do is once the plane lands, check its status and when it is 'Readying', set the new readyTime.
Possible:
Once the plane triggers the event, log it as a KeyStore value.
Then have another event that runs say every 5-10 minutes, that checks for any values in the KeyStore and runs against the value in the store:
ScenEdit_SetLoadout({side=unit.side, unitname=unit.name , LoadoutID = 0, TimeToReady_Minutes = 40, IgnoreMagazines='false'})
Michael
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: Weird LUA Behaviour, Any Ideas?

Post by butch4343 »

Guys,

Thanks for all the help and assistance. I got to the root of the problem, Basically it was ME being a donkey!


I used as remains in area , rather than a enters area trigger, I changed it last night and it worked bueatifully for me.

Thanks again though for all the wise words.

Regards

Butch
Post Reply

Return to “Lua Legion”